Skip to content

Commit 55e9197

Browse files
authored
Merge pull request #151 from micahmo/release/v2.0.11
Release/v2.0.11
2 parents 913f6a2 + 1e9eb13 commit 55e9197

File tree

8 files changed

+53
-42
lines changed

8 files changed

+53
-42
lines changed

Directory.Build.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<Project>
22
<PropertyGroup>
33
<!-- Keep in sync with WS4WSetupScript.iss and VersionInfo.xml -->
4-
<AssemblyVersion>2.0.10.0</AssemblyVersion>
5-
<FileVersion>2.0.10.0</FileVersion>
6-
<InformationalVersion>2.0.10.0</InformationalVersion>
4+
<AssemblyVersion>2.0.11.0</AssemblyVersion>
5+
<FileVersion>2.0.11.0</FileVersion>
6+
<InformationalVersion>2.0.11.0</InformationalVersion>
77
<Authors>Micah Morrison</Authors>
88
<Product>WS4W</Product>
99
</PropertyGroup>

Installer/WS4WSetupScript.iss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define MyAppNameOld "WireGuard Server For Windows"
22
#define MyAppName "Wg Server for Windows"
3-
#define MyAppVersion "2.0.10"
3+
#define MyAppVersion "2.0.11"
44
#define MyAppPublisher "Micah Morrison"
55
#define MyAppURL "https://github.com/micahmo/WgServerforWindows"
66
#define MyAppExeName "WgServerforWindows.exe"

WgServerforWindows/Models/ClientConfiguration.cs

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public ClientConfiguration(ClientConfigurationList parentList)
3636
// Server properties
3737
PresharedKeyProperty.TargetTypes.Add(typeof(ServerConfiguration));
3838
PublicKeyProperty.TargetTypes.Add(typeof(ServerConfiguration));
39-
ServerPersistentKeepaliveProperty.TargetTypes.Add(typeof(ServerConfiguration));
4039

4140
ServerConfigurationPrerequisite.EnsureConfigFile();
4241
var serverConfiguration = new ServerConfiguration().Load<ServerConfiguration>(Configuration.LoadFromFile(ServerConfigurationPrerequisite.ServerDataPath));
@@ -195,6 +194,39 @@ public ClientConfiguration(ClientConfigurationList parentList)
195194
};
196195
Properties.Add(allowedIpsProperty);
197196

197+
// This is a client property which goes in the client's (peer) section of the server's config,
198+
// so it should be defined and configured here, and should be targeted to the server's config.
199+
ConfigurationProperty PersistentKeepaliveProperty = new ConfigurationProperty(this)
200+
{
201+
PersistentPropertyName = "PersistentKeepalive",
202+
Name = nameof(PersistentKeepaliveProperty),
203+
DefaultValue = 0.ToString(),
204+
Validation = new ConfigurationPropertyValidation
205+
{
206+
Validate = prop =>
207+
{
208+
string result = default;
209+
210+
if (string.IsNullOrEmpty(prop.Value) || int.TryParse(prop.Value, out _) == false)
211+
{
212+
result = Resources.PersistentKeepaliveValidationError;
213+
}
214+
215+
return result;
216+
}
217+
}
218+
};
219+
// On load, do a migration of the old value from the server config, if needed.
220+
PersistentKeepaliveProperty.OnLoadAction = _ =>
221+
{
222+
if (string.IsNullOrEmpty(PersistentKeepaliveProperty.Value))
223+
{
224+
PersistentKeepaliveProperty.Value = serverConfiguration.ServerPersistentKeepaliveProperty.Value ?? 0.ToString();
225+
}
226+
};
227+
Properties.Add(PersistentKeepaliveProperty);
228+
PersistentKeepaliveProperty.TargetTypes.Add(typeof(ServerConfiguration));
229+
198230
// Adjust index of properties and resort
199231
AddressProperty.Index = 1;
200232
DnsProperty.Index = 2;
@@ -347,16 +379,6 @@ public ClientConfiguration(ClientConfigurationList parentList)
347379
};
348380
private ConfigurationProperty _fullDnsProperty;
349381

350-
// Note: This is really a server property, but it goes in the in the (peer) client section of the server's config.
351-
// So we'll trick the config generator by putting it in the client, targeting it to the server, and returning the server's value,
352-
// which the server will set on the client while saving
353-
public ConfigurationProperty ServerPersistentKeepaliveProperty => _persistentKeepaliveProperty ??= new ConfigurationProperty(this)
354-
{
355-
PersistentPropertyName = "PersistentKeepalive",
356-
IsHidden = true
357-
};
358-
private ConfigurationProperty _persistentKeepaliveProperty;
359-
360382
// Note: This is a client-specific property. It goes in the peer (client) section of the server's config, and is thus targeted to the server config type.
361383
// However, it also goes in the peer (server) section of the client config.
362384
// Therefore, it must also be defined on the server, targeted to the client, and return this client's value.

WgServerforWindows/Models/ConfigurationBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public ConfigurationBase Load(Configuration configuration)
5353
}
5454

5555
TopLevelActions.ForEach(a => a.OnLoadAction?.Invoke(this));
56+
Properties.ForEach(p => p.OnLoadAction?.Invoke(this));
5657

5758
return this;
5859
}

WgServerforWindows/Models/ConfigurationProperty.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ public string DefaultValue
7373

7474
public HashSet<Type> TargetTypes { get; } = new HashSet<Type>();
7575

76+
/// <summary>
77+
/// An action to be invoked after the configuration has been loaded
78+
/// </summary>
79+
public Action<ConfigurationBase> OnLoadAction { get; set; }
80+
7681
#region Commands
7782

7883
public ICommand ExecuteActionCommand => _executeActionCommand ??= new RelayCommand(() =>

WgServerforWindows/Models/ServerConfiguration.cs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -215,28 +215,12 @@ public ServerConfiguration()
215215
};
216216
private EndpointConfigurationProperty _endpointProperty;
217217

218-
// Note: Although this property is configured on the server, it goes in the peer (client) section of the server's config,
219-
// which means it also has to be defined on the client, targeted to the server's config.
220-
// The client should return the server's value, and the server should not target this property to any config type.
221-
public ConfigurationProperty PersistentKeepaliveProperty => _persistentKeepaliveProperty ??= new ConfigurationProperty(this)
218+
// This property is now configured on the client (and targeted to the client's (peer) section in the server config).
219+
// It exists here only for backwards compatibility, since it used to be configured here.
220+
public ConfigurationProperty ServerPersistentKeepaliveProperty => _persistentKeepaliveProperty ??= new ConfigurationProperty(this)
222221
{
223-
PersistentPropertyName = "PersistentKeepalive", // Don't really need this since it isn't saved from here
224-
Name = nameof(PersistentKeepaliveProperty),
225-
DefaultValue = 0.ToString(),
226-
Validation = new ConfigurationPropertyValidation
227-
{
228-
Validate = prop =>
229-
{
230-
string result = default;
231-
232-
if (string.IsNullOrEmpty(prop.Value) || int.TryParse(prop.Value, out _) == false)
233-
{
234-
result = Resources.PersistentKeepaliveValidationError;
235-
}
236-
237-
return result;
238-
}
239-
}
222+
PersistentPropertyName = "PersistentKeepalive",
223+
IsHidden = true
240224
};
241225
private ConfigurationProperty _persistentKeepaliveProperty;
242226

WgServerforWindows/Models/ServerConfigurationPrerequisite.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ private void SaveWG(ServerConfiguration serverConfiguration)
181181

182182
if (clientConfiguration.IsEnabledProperty.Value == true.ToString())
183183
{
184-
clientConfiguration.ServerPersistentKeepaliveProperty.Value = serverConfiguration.PersistentKeepaliveProperty.Value;
185184
configuration = configuration.Merge(clientConfiguration.ToConfiguration<ServerConfiguration>());
186185
}
187186
}

WireGuardServerForWindows/VersionInfo2.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<!-- Things to update: Version, Date, Release Notes -->
33
<AppUpdate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/micahmo/WgServerforWindows/master/WireGuardServerForWindows/AppUpdate.xsd">
5-
<Version>2.0.10.0</Version>
6-
<ReleaseDate>2023-04-19</ReleaseDate>
5+
<Version>2.0.11.0</Version>
6+
<ReleaseDate>2024-02-05</ReleaseDate>
77
<!-- Default download -->
8-
<DownloadLink>https://github.com/micahmo/WgServerforWindows/releases/download/v2.0.10/WS4WSetup-2.0.10.exe</DownloadLink>
9-
<DownloadFileName>WS4WSetup-2.0.10.exe</DownloadFileName>
8+
<DownloadLink>https://github.com/micahmo/WgServerforWindows/releases/download/v2.0.11/WS4WSetup-2.0.11.exe</DownloadLink>
9+
<DownloadFileName>WS4WSetup-2.0.11.exe</DownloadFileName>
1010
<!-- Release notes -->
11-
<VersionNotes> - Specify a custom subnet range for NAT network</VersionNotes>
11+
<VersionNotes> - Allow PersistentKeepalive to be configured per client</VersionNotes>
1212
<ReleaseNotes></ReleaseNotes>
1313
</AppUpdate>

0 commit comments

Comments
 (0)