Skip to content

Commit

Permalink
Merge pull request #60 from micahmo/release/v2.0.2
Browse files Browse the repository at this point in the history
Release/v2.0.2
  • Loading branch information
micahmo authored Sep 27, 2022
2 parents a758a9e + 2c93c1a commit 17b6bc2
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 31 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.1.0</AssemblyVersion>
<FileVersion>2.0.1.0</FileVersion>
<InformationalVersion>2.0.1.0</InformationalVersion>
<AssemblyVersion>2.0.2.0</AssemblyVersion>
<FileVersion>2.0.2.0</FileVersion>
<InformationalVersion>2.0.2.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.1"
#define MyAppVersion "2.0.2"
#define MyAppPublisher "Micah Morrison"
#define MyAppURL "https://github.com/micahmo/WgServerforWindows"
#define MyAppExeName "WgServerforWindows.exe"
Expand Down
50 changes: 31 additions & 19 deletions WgServerforWindows/Models/ClientConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public ClientConfiguration(ClientConfigurationList parentList)
Action = (conf, prop) =>
{
IPNetwork serverNetwork = IPNetwork.Parse(serverConfiguration.AddressProperty.Value);
var possibleAddresses = serverNetwork.ListIPAddress().Skip(2).SkipLast(1).ToList(); // Skip reserved .0 and .1 and .255.
var possibleAddresses = serverNetwork.ListIPAddress().Skip(2).SkipLast(1); // Skip reserved .0 and .1 and .255.

// If the current address is already in range, we're done
if (possibleAddresses.Select(a => a.ToString()).Contains(prop.Value))
if (IPAddress.TryParse(prop.Value, out var currentAddress) && serverNetwork.Contains(currentAddress))
{
return;
}
Expand All @@ -77,29 +77,41 @@ public ClientConfiguration(ClientConfigurationList parentList)
{
string result = default;

// First, try parsing with IPNetwork to see if it's in CIDR format
if (IPNetwork.TryParse(obj.Value, out var network))
if (string.IsNullOrEmpty(obj.Value))
{
// Can't be empty
result = Resources.ClientAddressValidationError;
}
else
{
// At this point, we know it's a valid network. Let's see how many addresses are in range
if (network.Usable > 1)
// Handle multiple comma-separated values
foreach (string address in obj.Value.Split(new[] { ',' }).Select(a => a.Trim()))
{
// It's CIDR, but it defines more than one address.
// However, IPNetwork has a quirk that parses single addresses (without mask) as a range.
// So now let's see if it's a single address
if (IPAddress.TryParse(obj.Value, out _) == false)
// First, try parsing with IPNetwork to see if it's in CIDR format
if (IPNetwork.TryParse(address, out var network))
{
// If we get here, it passed CIDR parsing, but it defined more than one address (i.e., had a mask). It's bad!
// At this point, we know it's a valid network. Let's see how many addresses are in range
if (network.Usable > 1)
{
// It's CIDR, but it defines more than one address.
// However, IPNetwork has a quirk that parses single addresses (without mask) as a range.
// So now let's see if it's a single address
if (IPAddress.TryParse(address, out _) == false)
{
// If we get here, it passed CIDR parsing, but it defined more than one address (i.e., had a mask). It's bad!
result = Resources.ClientAddressValidationError;
}
// Else, it's a single address as parsed by IPAddress, so we're good!
}
// Else
// It's in CIDR notation and only defines a single address (/32) so we're good!
}
else
{
// Not even IPNetwork could parse it, so it's really bad!
result = Resources.ClientAddressValidationError;
}
// Else, it's a single address as parsed by IPAddress, so we're good!
}
// Else
// It's in CIDR notation and only defines a single address (/32) so we're good!
}
else
{
// Not even IPNetwork could parse it, so it's really bad!
result = Resources.ClientAddressValidationError;
}

return result;
Expand Down
2 changes: 1 addition & 1 deletion WgServerforWindows/Properties/Resources.Designer.cs

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

2 changes: 1 addition & 1 deletion WgServerforWindows/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ Current value: {1}</value>
<value>Specify which IPs will be routed from the client to the server. Use 0.0.0.0/0 to route everything. Optionally specify multiple routes, separated by commas, like 10.0.0.0/8, 192.168.1.0/24</value>
</data>
<data name="ClientAddressValidationError" xml:space="preserve">
<value>Client address must be a single IP address, such as 10.232.0.2 or 10.232.0.2/32</value>
<value>Client address must be at least one IP address, such as 10.232.0.2 or 10.232.0.2/32</value>
</data>
<data name="DnsAddressValidationError" xml:space="preserve">
<value>DNS address(es) must be valid IPs, such as 8.8.8.8</value>
Expand Down
12 changes: 6 additions & 6 deletions WireGuardServerForWindows/VersionInfo2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<!-- 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.1.0</Version>
<ReleaseDate>2022-06-11</ReleaseDate>
<Version>2.0.2.0</Version>
<ReleaseDate>2022-09-27</ReleaseDate>
<!-- Default download -->
<DownloadLink>https://github.com/micahmo/WgServerforWindows/releases/download/v2.0.1/WS4WSetup-2.0.1.exe</DownloadLink>
<DownloadFileName>WS4WSetup-2.0.1.exe</DownloadFileName>
<DownloadLink>https://github.com/micahmo/WgServerforWindows/releases/download/v2.0.2/WS4WSetup-2.0.2.exe</DownloadLink>
<DownloadFileName>WS4WSetup-2.0.2.exe</DownloadFileName>
<!-- Release notes -->
<VersionNotes> - Add DNS Search Domains to client config (#50)
- Allow customizing Allowed IPs per client config (#36)</VersionNotes>
<VersionNotes> - Support client IP address generation in IPv6 range (#54)
- Allow mutliple client IPs (#54)</VersionNotes>
<ReleaseNotes></ReleaseNotes>
</AppUpdate>

0 comments on commit 17b6bc2

Please sign in to comment.