Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.1.2.0</AssemblyVersion>
<FileVersion>2.1.2.0</FileVersion>
<InformationalVersion>2.1.2.0</InformationalVersion>
<AssemblyVersion>2.1.3.0</AssemblyVersion>
<FileVersion>2.1.3.0</FileVersion>
<InformationalVersion>2.1.3.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.1.2"
#define MyAppVersion "2.1.3"
#define MyAppPublisher "Micah Morrison"
#define MyAppURL "https://github.com/micahmo/WgServerforWindows"
#define MyAppExeName "WgServerforWindows.exe"
Expand Down
70 changes: 70 additions & 0 deletions WgServerforWindows/Models/TunnelServicePrerequisite.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using System;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Windows.Input;
using SharpConfig;
using WgAPI;
using WgAPI.Commands;
using WgServerforWindows.Controls;
using WgServerforWindows.Properties;

namespace WgServerforWindows.Models
Expand Down Expand Up @@ -35,6 +38,73 @@ public TunnelServicePrerequisite(TunnelServiceNameSubCommand tunnelServiceNameSu

public override async void Resolve()
{
try
{
// Load the server config and check the listen port
ServerConfiguration serverConfiguration = new ServerConfiguration().Load<ServerConfiguration>(Configuration.LoadFromFile(ServerConfigurationPrerequisite.ServerDataPath));
string listenPort = serverConfiguration.ListenPortProperty.Value;

if (int.TryParse(listenPort, out int listenPortInt))
{
IPEndPoint[] tcpEndPoints = IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners();
IPEndPoint[] udpEndPoints = IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners();

bool anyTcpListener = tcpEndPoints.Any(endpoint => endpoint.Port == listenPortInt);
bool anyUdpListener = udpEndPoints.Any(endpoint => endpoint.Port == listenPortInt);

if (anyUdpListener)
{
// Give the user strong warning about UDP listener
bool canceled = false;
UnhandledErrorWindow portWarningDialog = new UnhandledErrorWindow();
portWarningDialog.DataContext = new UnhandledErrorWindowModel
{
Title = Resources.PotentialPortConflict,
Text = string.Format(Resources.UDPPortConflictMessage, listenPort),
SecondaryButtonText = Resources.Cancel,
SecondaryButtonAction = () =>
{
canceled = true;
portWarningDialog.Close();
}
};
portWarningDialog.ShowDialog();

if (canceled)
{
return;
}
}
else if (anyTcpListener)
{
// Give the user less strong warning about TCP listener
bool canceled = false;
UnhandledErrorWindow portWarningDialog = new UnhandledErrorWindow();
portWarningDialog.DataContext = new UnhandledErrorWindowModel
{
Title = Resources.PotentialPortConflict,
Text = string.Format(Resources.TCPPortConflictMessage, listenPort),
SecondaryButtonText = Resources.Cancel,
SecondaryButtonAction = () =>
{
canceled = true;
portWarningDialog.Close();
}
};
portWarningDialog.ShowDialog();

if (canceled)
{
return;
}
}
}
}
catch
{
// If we can't verify the listen port, it's ok.
}

WaitCursor.SetOverrideCursor(Cursors.Wait);

using (TemporaryFile temporaryFile = new(ServerConfigurationPrerequisite.ServerWGPath, ServerConfigurationPrerequisite.ServerWGPathWithCustomTunnelName))
Expand Down
27 changes: 27 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.

9 changes: 9 additions & 0 deletions WgServerforWindows/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -620,4 +620,13 @@ Note: It is preferable to use a domain name with DDNS to avoid dynamic WAN IPs.<
<data name="DontShowAgain" xml:space="preserve">
<value>Don't Show Again</value>
</data>
<data name="PotentialPortConflict" xml:space="preserve">
<value>Potential Port Conflict</value>
</data>
<data name="UDPPortConflictMessage" xml:space="preserve">
<value>Another process is listening on UDP Port {0} which may conflict with WireGuard. If you continue, WS4W may fail to install the tunnel service. Do you wish to proceed?</value>
</data>
<data name="TCPPortConflictMessage" xml:space="preserve">
<value>Another process is listening on TCP Port {0}. Since WireGuard uses UDP, there should not (but there may) be a conflict. Do you wish to proceed?</value>
</data>
</root>
12 changes: 5 additions & 7 deletions WireGuardServerForWindows/VersionInfo2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
<!-- 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.1.2.0</Version>
<ReleaseDate>2025-02-20</ReleaseDate>
<Version>2.1.3.0</Version>
<ReleaseDate>2025-03-05</ReleaseDate>
<!-- Default download -->
<DownloadLink>https://github.com/micahmo/WgServerforWindows/releases/download/v2.1.2/WS4WSetup-2.1.2.exe</DownloadLink>
<DownloadFileName>WS4WSetup-2.1.2.exe</DownloadFileName>
<DownloadLink>https://github.com/micahmo/WgServerforWindows/releases/download/v2.1.3/WS4WSetup-2.1.3.exe</DownloadLink>
<DownloadFileName>WS4WSetup-2.1.3.exe</DownloadFileName>
<!-- Release notes -->
<VersionNotes> - Added the ability to customize the tunnel service name (#104)
- Delay the WS4W Set NetIPAddress task (#108)
- Show a warning if the user is running with a temporary profile (#122)</VersionNotes>
<VersionNotes> - Show warning if another process is listening on the configured WireGuard server port (#138 and #188)</VersionNotes>
<ReleaseNotes></ReleaseNotes>
</AppUpdate>
Loading