Skip to content

Commit

Permalink
fix check os on AllowNatTraversal
Browse files Browse the repository at this point in the history
  • Loading branch information
tqk2811 committed Dec 25, 2023
1 parent 9177623 commit 525b879
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/TqkLibrary.Proxy/ProxyServers/BaseProxyServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using TqkLibrary.Proxy.Handlers;
Expand Down Expand Up @@ -62,7 +63,9 @@ public void StartListen(bool allowNatTraversal = false)
{
if (!this._tcpListener.Server.IsBound)
{
if(Environment.OSVersion.Platform.ToString().StartsWith("Win"))
#if !NET462
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
#endif
{
this._tcpListener.AllowNatTraversal(allowNatTraversal);
}
Expand Down Expand Up @@ -121,7 +124,7 @@ private async Task _PreProxyWorkAsync(TcpClient tcpClient)
}
}
}
catch(ObjectDisposedException ode)
catch (ObjectDisposedException ode)
{
_logger?.LogInformation(ode, nameof(_PreProxyWorkAsync));
}
Expand Down

0 comments on commit 525b879

Please sign in to comment.