Skip to content

Commit

Permalink
Merge pull request #97 from micahmo/release/v2.0.8
Browse files Browse the repository at this point in the history
Release/v2.0.8
  • Loading branch information
micahmo authored Feb 14, 2023
2 parents 14efd9a + f591202 commit 684907f
Show file tree
Hide file tree
Showing 15 changed files with 191 additions and 18 deletions.
6 changes: 3 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project>
<PropertyGroup>
<!-- Keep in sync with WS4WSetupScript.iss and VersionInfo.xml -->
<AssemblyVersion>2.0.7.0</AssemblyVersion>
<FileVersion>2.0.7.0</FileVersion>
<InformationalVersion>2.0.7.0</InformationalVersion>
<AssemblyVersion>2.0.8.0</AssemblyVersion>
<FileVersion>2.0.8.0</FileVersion>
<InformationalVersion>2.0.8.0</InformationalVersion>
<Authors>Micah Morrison</Authors>
<Product>WS4W</Product>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Installer/WS4WSetupScript.iss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define MyAppNameOld "WireGuard Server For Windows"
#define MyAppName "Wg Server for Windows"
#define MyAppVersion "2.0.7"
#define MyAppVersion "2.0.8"
#define MyAppPublisher "Micah Morrison"
#define MyAppURL "https://github.com/micahmo/WgServerforWindows"
#define MyAppExeName "WgServerforWindows.exe"
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ However, if you experience the following error message when enabling Internet Sh

> Note: This issue is often triggered after creating a new virtual switch for a VM. The manual workaround should only be needed once after that and does not affect the virtual switch.
# Compatibility
WS4W has been tested and is known to work on Windows Server (2012 R2 and newer) and Windows Desktop (10 and newer).

# Attribution

WireGuard is a registered trademark of Jason A. Donenfeld.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using WgServerforWindows.Models;

namespace WgServerforWindows.Controls
Expand All @@ -21,6 +20,13 @@ protected override void OnActivated(EventArgs e)
WaitCursor.SetOverrideCursor(null);
}

protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);

AppSettings.Instance.Tracker.Track(this);
}

#region Event handlers

private void SaveButton_Click(object sender, RoutedEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
Text="{Binding Name, Converter={StaticResource ResourceStringConverter}, StringFormat={x:Static properties:Resources.PropertyNameFormat}}"
ToolTip="{Binding Name, Converter={StaticResource ResourceStringConverter}}"
VerticalAlignment="Center"/>
<TextBox x:Name="tb" Grid.Column="1" IsReadOnly="{Binding IsReadOnly}"
<TextBox x:Name="tb" Grid.Column="1" IsReadOnly="{Binding IsReadOnly}" IsEnabled="{Binding IsEnabled}"
Text="{Binding Value, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}"
ToolTipService.ShowDuration="60000"
VerticalContentAlignment="Center">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Windows;
using System.Windows.Input;
using WgServerforWindows.Models;

namespace WgServerforWindows.Controls
{
Expand All @@ -19,6 +19,13 @@ protected override void OnActivated(EventArgs e)
WaitCursor.SetOverrideCursor(null);
}

protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);

AppSettings.Instance.Tracker.Track(this);
}

#region Event handlers

private void SaveButton_Click(object sender, RoutedEventArgs e)
Expand Down
86 changes: 85 additions & 1 deletion WgServerforWindows/Models/ClientConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;
Expand Down Expand Up @@ -225,6 +226,15 @@ public ClientConfiguration(ClientConfigurationList parentList)
};
private ConfigurationProperty _index;

// Do not target this to any WG config. We only want it in the data.
public ConfigurationProperty IsEnabledProperty => _isEnabled ??= new ConfigurationProperty(this)
{
PersistentPropertyName = "IsEnabled",
DefaultValue = true.ToString(),
IsHidden = true
};
private ConfigurationProperty _isEnabled;

/// <summary>
/// This is a funny one. This is first defined on the server. Then the user can import that default value into the client config.
/// Then the property needs to go to the server and be targeted to the client's config (under the server/peer section).
Expand Down Expand Up @@ -355,10 +365,64 @@ public ClientConfiguration(ClientConfigurationList parentList)
PersistentPropertyName = "PresharedKey",
Name = nameof(PresharedKeyProperty),
IsReadOnly = true, // Don't allow manual clearing; this would require a full resync anyway. See README.
Index = int.MaxValue // Put it at the end
Index = int.MaxValue - 1 // Put it at the end
};
private ConfigurationProperty _presharedKeyProperty;

public ConfigurationProperty LatestHandshakeProperty => _latestHandshakeProperty ??= new ConfigurationProperty(this)
{
Name = nameof(LatestHandshakeProperty),
Description = Resources.LatestHandshakePropertyDescription,
IsReadOnly = true,
IsCalculated = true,
GetValueFunc = () =>
{
string result = default;

if (PublicKeyProperty.Value != null)
{
WaitCursor.SetOverrideCursor(Cursors.Wait);

// Get the current status
string status = new WireGuardExe().ExecuteCommand(new ShowCommand(ServerConfigurationPrerequisite.WireGuardServerInterfaceName));

bool foundClient = false;
foreach (string line in status.Split(Environment.NewLine))
{
if (line.Contains("peer:"))
{
foundClient = false;
}

if (line.Contains(PublicKeyProperty.Value))
{
foundClient = true;
}

if (foundClient && line.Contains("latest handshake:"))
{
result = Regex.Replace(line, @"\s*latest handshake:\s*", string.Empty);
break;
}
}

WaitCursor.SetOverrideCursor(null);
}

return result;
},
Action = new ConfigurationPropertyAction(this)
{
Name = nameof(Resources.LatestHandshakePropertyAction),
Action = (conf, prop) =>
{
LatestHandshakeProperty.RaisePropertyChanged(nameof(LatestHandshakeProperty.Value));
}
},
Index = int.MaxValue
};
private ConfigurationProperty _latestHandshakeProperty;

public ConfigurationPropertyAction DeleteAction => _deleteAction ??= new ConfigurationPropertyAction(this)
{
Name = nameof(Resources.DeleteAction),
Expand All @@ -373,6 +437,26 @@ public ClientConfiguration(ClientConfigurationList parentList)
};
private ConfigurationPropertyAction _deleteAction;

public ConfigurationPropertyAction DisableAction => _disableAction ??= new ConfigurationPropertyAction(this)
{
Name = nameof(Resources.Disable),
OnLoadAction = conf =>
{
// If we're loading, we need to set the button state based on the loaded value of IsEnabled
DisableAction.Name = bool.TryParse(IsEnabledProperty.Value, out bool isEnabled) && isEnabled ? nameof(Resources.Disable) : nameof(Resources.Enable);
},
Action = (conf, prop) =>
{
if (bool.TryParse(IsEnabledProperty.Value, out bool isEnabled))
{
bool newValue = !isEnabled;
IsEnabledProperty.Value = newValue.ToString();
DisableAction.Name = newValue ? nameof(Resources.Disable) : nameof(Resources.Enable);
}
}
};
private ConfigurationPropertyAction _disableAction;

public ConfigurationPropertyAction GenerateQrCodeAction => _generateQrCodeAction ??= new ConfigurationPropertyAction(this)
{
Name = nameof(Resources.GenerateQrCodeAction),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public override void Configure()
}

// Save to WG
foreach (ClientConfiguration clientConfiguration in clientConfigurations.List)
foreach (ClientConfiguration clientConfiguration in clientConfigurations.List.Where(c => c.IsEnabledProperty.Value == true.ToString()))
{
SaveWG(clientConfiguration);
}
Expand Down
2 changes: 2 additions & 0 deletions WgServerforWindows/Models/ConfigurationBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public ConfigurationBase Load(Configuration configuration)
}
}

TopLevelActions.ForEach(a => a.OnLoadAction?.Invoke(this));

return this;
}

Expand Down
2 changes: 2 additions & 0 deletions WgServerforWindows/Models/ConfigurationProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public string DefaultValue

public bool IsReadOnly { get; set; }

public bool IsEnabled { get; set; } = true;

public bool IsHidden { get; set; }

/// <summary>
Expand Down
5 changes: 5 additions & 0 deletions WgServerforWindows/Models/ConfigurationPropertyAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public Func<ConfigurationProperty, bool> DependencySatisfiedFunc

public Action<ConfigurationBase, ConfigurationProperty> Action { get; set; }

/// <summary>
/// An action to be invoked after the configuration has been loaded
/// </summary>
public Action<ConfigurationBase> OnLoadAction { get; set; }

public ICommand ExecuteActionCommand => _executeActionCommand ??= new RelayCommand(() =>
{
Action?.Invoke(_parentConfiguration, null);
Expand Down
9 changes: 6 additions & 3 deletions WgServerforWindows/Models/ServerConfigurationPrerequisite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,12 @@ private void SaveWG(ServerConfiguration serverConfiguration)
foreach (string clientConfigurationFile in Directory.GetFiles(ClientConfigurationsPrerequisite.ClientDataDirectory, "*.conf"))
{
var clientConfiguration = new ClientConfiguration(null).Load<ClientConfiguration>(Configuration.LoadFromFile(clientConfigurationFile));
clientConfiguration.ServerPersistentKeepaliveProperty.Value = serverConfiguration.PersistentKeepaliveProperty.Value;

configuration = configuration.Merge(clientConfiguration.ToConfiguration<ServerConfiguration>());

if (clientConfiguration.IsEnabledProperty.Value == true.ToString())
{
clientConfiguration.ServerPersistentKeepaliveProperty.Value = serverConfiguration.PersistentKeepaliveProperty.Value;
configuration = configuration.Merge(clientConfiguration.ToConfiguration<ServerConfiguration>());
}
}
}

Expand Down
45 changes: 45 additions & 0 deletions WgServerforWindows/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions WgServerforWindows/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ Current value: {1}</value>
<data name="DeleteAction" xml:space="preserve">
<value>Delete</value>
</data>
<data name="Disable" xml:space="preserve">
<value>Disable</value>
</data>
<data name="Enable" xml:space="preserve">
<value>Enable</value>
</data>
<data name="ConfirmDeleteClient" xml:space="preserve">
<value>Are you sure you want to delete the client?</value>
</data>
Expand Down Expand Up @@ -557,4 +563,13 @@ Note: It is preferable to use a domain name with DDNS to avoid dynamic WAN IPs.<
<data name="ClientCount" xml:space="preserve">
<value>Count: {0}</value>
</data>
<data name="LatestHandshakeProperty" xml:space="preserve">
<value>Latest Handshake</value>
</data>
<data name="LatestHandshakePropertyDescription" xml:space="preserve">
<value>Displays the time at which this client most recently connected to the server. This field is purely informational.</value>
</data>
<data name="LatestHandshakePropertyAction" xml:space="preserve">
<value>Refresh</value>
</data>
</root>
13 changes: 7 additions & 6 deletions WireGuardServerForWindows/VersionInfo2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
<!-- Things to update: Version, Date, Release Notes -->
<AppUpdate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/micahmo/WgServerforWindows/master/WireGuardServerForWindows/AppUpdate.xsd">
<Version>2.0.7.0</Version>
<ReleaseDate>2023-02-13</ReleaseDate>
<Version>2.0.8.0</Version>
<ReleaseDate>2023-02-14</ReleaseDate>
<!-- Default download -->
<DownloadLink>https://github.com/micahmo/WgServerforWindows/releases/download/v2.0.7/WS4WSetup-2.0.7.exe</DownloadLink>
<DownloadFileName>WS4WSetup-2.0.7.exe</DownloadFileName>
<DownloadLink>https://github.com/micahmo/WgServerforWindows/releases/download/v2.0.8/WS4WSetup-2.0.8.exe</DownloadLink>
<DownloadFileName>WS4WSetup-2.0.8.exe</DownloadFileName>
<!-- Release notes -->
<VersionNotes> - Improve client configuration UI (expand/collapse/filter/count)
- Fix issue were clients could not be configured before server</VersionNotes>
<VersionNotes> - Add the ability to disable individual clients (#61)
- Show each client's latest handshake in the client configuration UI (#61)
- Remember the size/position of the server/client configuration windows</VersionNotes>
<ReleaseNotes></ReleaseNotes>
</AppUpdate>

0 comments on commit 684907f

Please sign in to comment.