Commit 1e8cf7e2 authored by Honfika's avatar Honfika

Use proxy renamed to use upstream proxy

parent d49448ea
...@@ -16,7 +16,7 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -16,7 +16,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
internal ExternalProxy UpStreamHttpsProxy { get; set; } internal ExternalProxy UpStreamHttpsProxy { get; set; }
internal ExternalProxy UpStreamProxy => UseProxy ? IsHttps ? UpStreamHttpsProxy : UpStreamHttpProxy : null; internal ExternalProxy UpStreamProxy => UseUpstreamProxy ? IsHttps ? UpStreamHttpsProxy : UpStreamHttpProxy : null;
internal string HostName { get; set; } internal string HostName { get; set; }
...@@ -24,7 +24,7 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -24,7 +24,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
internal bool IsHttps { get; set; } internal bool IsHttps { get; set; }
internal bool UseProxy { get; set; } internal bool UseUpstreamProxy { get; set; }
/// <summary> /// <summary>
/// Http version /// Http version
......
...@@ -32,18 +32,18 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -32,18 +32,18 @@ namespace Titanium.Web.Proxy.Network.Tcp
internal async Task<TcpConnection> CreateClient(ProxyServer server, string remoteHostName, int remotePort, Version httpVersion, bool isHttps, internal async Task<TcpConnection> CreateClient(ProxyServer server, string remoteHostName, int remotePort, Version httpVersion, bool isHttps,
ExternalProxy externalHttpProxy, ExternalProxy externalHttpsProxy) ExternalProxy externalHttpProxy, ExternalProxy externalHttpsProxy)
{ {
bool useProxy = false; bool useUpstreamProxy = false;
var externalProxy = isHttps ? externalHttpsProxy : externalHttpProxy; var externalProxy = isHttps ? externalHttpsProxy : externalHttpProxy;
//check if external proxy is set for HTTP/HTTPS //check if external proxy is set for HTTP/HTTPS
if (externalProxy != null && !(externalProxy.HostName == remoteHostName && externalProxy.Port == remotePort)) if (externalProxy != null && !(externalProxy.HostName == remoteHostName && externalProxy.Port == remotePort))
{ {
useProxy = true; useUpstreamProxy = true;
//check if we need to ByPass //check if we need to ByPass
if (externalProxy.BypassLocalhost && NetworkHelper.IsLocalIpAddress(remoteHostName)) if (externalProxy.BypassLocalhost && NetworkHelper.IsLocalIpAddress(remoteHostName))
{ {
useProxy = false; useUpstreamProxy = false;
} }
} }
...@@ -53,7 +53,7 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -53,7 +53,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
try try
{ {
//If this proxy uses another external proxy then create a tunnel request for HTTP/HTTPS connections //If this proxy uses another external proxy then create a tunnel request for HTTP/HTTPS connections
if (useProxy) if (useUpstreamProxy)
{ {
#if NET45 #if NET45
client = new TcpClient(server.UpStreamEndPoint); client = new TcpClient(server.UpStreamEndPoint);
...@@ -136,7 +136,7 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -136,7 +136,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
HostName = remoteHostName, HostName = remoteHostName,
Port = remotePort, Port = remotePort,
IsHttps = isHttps, IsHttps = isHttps,
UseProxy = useProxy, UseUpstreamProxy = useUpstreamProxy,
TcpClient = client, TcpClient = client,
StreamReader = new CustomBinaryReader(stream, server.BufferSize), StreamReader = new CustomBinaryReader(stream, server.BufferSize),
Stream = stream, Stream = stream,
......
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