Commit c2994bc7 authored by justcoding121's avatar justcoding121

system proxy do not support non-windows env

parent fc153521
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
...@@ -149,7 +149,7 @@ namespace Titanium.Web.Proxy.Network ...@@ -149,7 +149,7 @@ namespace Titanium.Web.Proxy.Network
set set
{ {
// For Mono (or Non-Windows) only Bouncy Castle is supported // For Mono (or Non-Windows) only Bouncy Castle is supported
if (!RunTime.IsWindows || RunTime.IsRunningOnMono) if (!RunTime.IsWindows)
{ {
value = CertificateEngine.BouncyCastle; value = CertificateEngine.BouncyCastle;
} }
...@@ -662,7 +662,7 @@ namespace Titanium.Web.Proxy.Network ...@@ -662,7 +662,7 @@ namespace Titanium.Web.Proxy.Network
/// <returns>True if success.</returns> /// <returns>True if success.</returns>
public bool TrustRootCertificateAsAdmin(bool machineTrusted = false) public bool TrustRootCertificateAsAdmin(bool machineTrusted = false)
{ {
if (!RunTime.IsWindows || RunTime.IsRunningOnMono) if (!RunTime.IsWindows)
{ {
return false; return false;
} }
...@@ -805,7 +805,7 @@ namespace Titanium.Web.Proxy.Network ...@@ -805,7 +805,7 @@ namespace Titanium.Web.Proxy.Network
/// <returns>Should also remove from machine store?</returns> /// <returns>Should also remove from machine store?</returns>
public bool RemoveTrustedRootCertificateAsAdmin(bool machineTrusted = false) public bool RemoveTrustedRootCertificateAsAdmin(bool machineTrusted = false)
{ {
if (!RunTime.IsWindows || RunTime.IsRunningOnMono) if (!RunTime.IsWindows)
{ {
return false; return false;
} }
......
...@@ -280,7 +280,7 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -280,7 +280,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
}; };
//linux has a bug with socket reuse in .net core. //linux has a bug with socket reuse in .net core.
if (proxyServer.ReuseSocket && (RunTime.IsWindows || RunTime.IsRunningOnMono)) if (proxyServer.ReuseSocket && RunTime.IsWindows)
{ {
tcpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); tcpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
} }
......
...@@ -102,7 +102,7 @@ namespace Titanium.Web.Proxy ...@@ -102,7 +102,7 @@ namespace Titanium.Web.Proxy
ProxyEndPoints = new List<ProxyEndPoint>(); ProxyEndPoints = new List<ProxyEndPoint>();
tcpConnectionFactory = new TcpConnectionFactory(this); tcpConnectionFactory = new TcpConnectionFactory(this);
if (!RunTime.IsRunningOnMono && RunTime.IsWindows && !RunTime.IsUwpOnWindows) if (RunTime.IsWindows && !RunTime.IsUwpOnWindows)
{ {
systemProxySettingsManager = new SystemProxyManager(); systemProxySettingsManager = new SystemProxyManager();
} }
...@@ -511,9 +511,10 @@ namespace Titanium.Web.Proxy ...@@ -511,9 +511,10 @@ namespace Titanium.Web.Proxy
/// </summary> /// </summary>
public void DisableSystemProxy(ProxyProtocolType protocolType) public void DisableSystemProxy(ProxyProtocolType protocolType)
{ {
if (RunTime.IsRunningOnMono) if (!RunTime.IsWindows)
{ {
throw new Exception("Mono Runtime do not support system proxy settings."); throw new NotSupportedException(@"Setting system proxy settings are only supported in Windows.
Please manually confugure you operating system to use this proxy's port and address.");
} }
systemProxySettingsManager.RemoveProxy(protocolType); systemProxySettingsManager.RemoveProxy(protocolType);
...@@ -524,9 +525,10 @@ namespace Titanium.Web.Proxy ...@@ -524,9 +525,10 @@ namespace Titanium.Web.Proxy
/// </summary> /// </summary>
public void DisableAllSystemProxies() public void DisableAllSystemProxies()
{ {
if (RunTime.IsRunningOnMono) if (!RunTime.IsWindows)
{ {
throw new Exception("Mono Runtime do not support system proxy settings."); throw new NotSupportedException(@"Setting system proxy settings are only supported in Windows.
Please manually confugure you operating system to use this proxy's port and address.");
} }
systemProxySettingsManager.DisableAllProxy(); systemProxySettingsManager.DisableAllProxy();
...@@ -600,7 +602,7 @@ namespace Titanium.Web.Proxy ...@@ -600,7 +602,7 @@ namespace Titanium.Web.Proxy
throw new Exception("Proxy is not running."); throw new Exception("Proxy is not running.");
} }
if (!RunTime.IsRunningOnMono && RunTime.IsWindows && !RunTime.IsUwpOnWindows) if (RunTime.IsWindows && !RunTime.IsUwpOnWindows)
{ {
bool setAsSystemProxy = ProxyEndPoints.OfType<ExplicitProxyEndPoint>() bool setAsSystemProxy = ProxyEndPoints.OfType<ExplicitProxyEndPoint>()
.Any(x => x.IsSystemHttpProxy || x.IsSystemHttpsProxy); .Any(x => x.IsSystemHttpProxy || x.IsSystemHttpsProxy);
...@@ -633,7 +635,7 @@ namespace Titanium.Web.Proxy ...@@ -633,7 +635,7 @@ namespace Titanium.Web.Proxy
endPoint.Listener = new TcpListener(endPoint.IpAddress, endPoint.Port); endPoint.Listener = new TcpListener(endPoint.IpAddress, endPoint.Port);
//linux/macOS has a bug with socket reuse in .net core. //linux/macOS has a bug with socket reuse in .net core.
if (ReuseSocket && (RunTime.IsWindows || RunTime.IsRunningOnMono)) if (ReuseSocket && RunTime.IsWindows)
{ {
endPoint.Listener.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); endPoint.Listener.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
} }
......
...@@ -27,7 +27,7 @@ namespace Titanium.Web.Proxy ...@@ -27,7 +27,7 @@ namespace Titanium.Web.Proxy
public partial class ProxyServer public partial class ProxyServer
{ {
private bool isWindowsAuthenticationEnabledAndSupported => private bool isWindowsAuthenticationEnabledAndSupported =>
EnableWinAuth && RunTime.IsWindows && !RunTime.IsRunningOnMono; EnableWinAuth && RunTime.IsWindows;
/// <summary> /// <summary>
/// This is the core request handler method for a particular connection from client. /// This is the core request handler method for a particular connection from client.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment