Commit b0bf63bb authored by justcoding121's avatar justcoding121

#242 Fix external proxy

parent 83cca8a5
......@@ -21,7 +21,7 @@ namespace Titanium.Web.Proxy.Models
/// <summary>
/// Bypass this proxy for connections to localhost?
/// </summary>
public bool BypassForLocalhost { get; set; }
public bool BypassLocalhost { get; set; }
/// <summary>
/// Username.
......
......@@ -39,10 +39,37 @@ namespace Titanium.Web.Proxy.Network.Tcp
TcpClient client;
CustomBufferedStream stream;
bool isLocalhost = (externalHttpsProxy != null || externalHttpProxy != null) && NetworkHelper.IsLocalIpAddress(remoteHostName);
bool useHttpsProxy = externalHttpsProxy != null && externalHttpsProxy.HostName != remoteHostName && externalHttpsProxy.BypassForLocalhost && !isLocalhost;
bool useHttpProxy = externalHttpProxy != null && externalHttpProxy.HostName != remoteHostName && externalHttpProxy.BypassForLocalhost && !isLocalhost;
bool useHttpProxy = false;
//check if external proxy is set for HTTP
if (!isHttps && externalHttpProxy != null
&& externalHttpProxy.HostName != remoteHostName)
{
useHttpProxy = true;
//check if we need to ByPass
if (externalHttpProxy.BypassLocalhost
&& NetworkHelper.IsLocalIpAddress(remoteHostName))
{
useHttpProxy = false;
}
}
bool useHttpsProxy = false;
//check if external proxy is set for HTTPS
if (isHttps && externalHttpsProxy != null
&& externalHttpsProxy.HostName != remoteHostName)
{
useHttpsProxy = true;
//check if we need to ByPass
if (externalHttpsProxy.BypassLocalhost
&& NetworkHelper.IsLocalIpAddress(remoteHostName))
{
useHttpsProxy = false;
}
}
if (isHttps)
{
......
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