diff --git a/src/TqkLibrary.Proxy/ProxyServers/BaseProxyServer.cs b/src/TqkLibrary.Proxy/ProxyServers/BaseProxyServer.cs index 33f0f31..182ad71 100644 --- a/src/TqkLibrary.Proxy/ProxyServers/BaseProxyServer.cs +++ b/src/TqkLibrary.Proxy/ProxyServers/BaseProxyServer.cs @@ -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; @@ -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); } @@ -121,7 +124,7 @@ private async Task _PreProxyWorkAsync(TcpClient tcpClient) } } } - catch(ObjectDisposedException ode) + catch (ObjectDisposedException ode) { _logger?.LogInformation(ode, nameof(_PreProxyWorkAsync)); }