Unverified Commit 06cb6ee8 authored by honfika's avatar honfika Committed by GitHub

Merge pull request #802 from justcoding121/master

beta
parents 0399f114 4aa42678
......@@ -129,7 +129,7 @@
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Models_ExternalProxyType.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Models.ExternalProxyType%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A" class="contribution-link">Improve this Doc</a>
</li>
<li>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Models/ExternalProxy.cs/#L117" class="contribution-link">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Models/ExternalProxy.cs/#L119" class="contribution-link">View Source</a>
</li>
</ul>
</div>
......
......@@ -129,7 +129,7 @@
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Models_IExternalProxy_HostName.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Models.IExternalProxy.HostName%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Models/IExternalProxy.cs/#L30">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Models/IExternalProxy.cs/#L32">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Models_IExternalProxy_HostName_" data-uid="Titanium.Web.Proxy.Models.IExternalProxy.HostName*"></a>
<h4 id="Titanium_Web_Proxy_Models_IExternalProxy_HostName" data-uid="Titanium.Web.Proxy.Models.IExternalProxy.HostName">HostName</h4>
......@@ -160,7 +160,7 @@
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Models_IExternalProxy_Password.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Models.IExternalProxy.Password%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Models/IExternalProxy.cs/#L25">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Models/IExternalProxy.cs/#L27">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Models_IExternalProxy_Password_" data-uid="Titanium.Web.Proxy.Models.IExternalProxy.Password*"></a>
<h4 id="Titanium_Web_Proxy_Models_IExternalProxy_Password" data-uid="Titanium.Web.Proxy.Models.IExternalProxy.Password">Password</h4>
......@@ -191,7 +191,7 @@
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Models_IExternalProxy_Port.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Models.IExternalProxy.Port%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Models/IExternalProxy.cs/#L35">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Models/IExternalProxy.cs/#L37">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Models_IExternalProxy_Port_" data-uid="Titanium.Web.Proxy.Models.IExternalProxy.Port*"></a>
<h4 id="Titanium_Web_Proxy_Models_IExternalProxy_Port" data-uid="Titanium.Web.Proxy.Models.IExternalProxy.Port">Port</h4>
......@@ -217,6 +217,36 @@
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Models_IExternalProxy_ProxyDnsRequests.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Models.IExternalProxy.ProxyDnsRequests%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Models/IExternalProxy.cs/#L17">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Models_IExternalProxy_ProxyDnsRequests_" data-uid="Titanium.Web.Proxy.Models.IExternalProxy.ProxyDnsRequests*"></a>
<h4 id="Titanium_Web_Proxy_Models_IExternalProxy_ProxyDnsRequests" data-uid="Titanium.Web.Proxy.Models.IExternalProxy.ProxyDnsRequests">ProxyDnsRequests</h4>
<div class="markdown level1 summary"></div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">bool ProxyDnsRequests { get; set; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.boolean">Boolean</a></td>
<td></td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Models_IExternalProxy_ProxyType.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Models.IExternalProxy.ProxyType%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
......@@ -283,7 +313,7 @@
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Models_IExternalProxy_UserName.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Models.IExternalProxy.UserName%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Models/IExternalProxy.cs/#L20">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Models/IExternalProxy.cs/#L22">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Models_IExternalProxy_UserName_" data-uid="Titanium.Web.Proxy.Models.IExternalProxy.UserName*"></a>
<h4 id="Titanium_Web_Proxy_Models_IExternalProxy_UserName" data-uid="Titanium.Web.Proxy.Models.IExternalProxy.UserName">UserName</h4>
......@@ -316,7 +346,7 @@
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Models_IExternalProxy_ToString.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Models.IExternalProxy.ToString%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Models/IExternalProxy.cs/#L37">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Models/IExternalProxy.cs/#L39">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Models_IExternalProxy_ToString_" data-uid="Titanium.Web.Proxy.Models.IExternalProxy.ToString*"></a>
<h4 id="Titanium_Web_Proxy_Models_IExternalProxy_ToString" data-uid="Titanium.Web.Proxy.Models.IExternalProxy.ToString">ToString()</h4>
......
......@@ -217,7 +217,7 @@
"api/Titanium.Web.Proxy.Models.ExternalProxy.html": {
"href": "api/Titanium.Web.Proxy.Models.ExternalProxy.html",
"title": "Class ExternalProxy | Titanium Web Proxy",
"keywords": "Class ExternalProxy An upstream proxy this proxy uses if any. Inheritance Object ExternalProxy Implements IExternalProxy Inherited Members Object.Equals(Object) Object.Equals(Object, Object) Object.ReferenceEquals(Object, Object) Object.GetHashCode() Object.GetType() Object.MemberwiseClone() Namespace : Titanium.Web.Proxy.Models Assembly : Titanium.Web.Proxy.dll Syntax public class ExternalProxy : IExternalProxy Constructors | Improve this Doc View Source ExternalProxy() Initializes a new instance of the ExternalProxy class. Declaration public ExternalProxy() | Improve this Doc View Source ExternalProxy(String, Int32) Initializes a new instance of the ExternalProxy class. Declaration public ExternalProxy(string hostName, int port) Parameters Type Name Description String hostName Name of the host. Int32 port The port. | Improve this Doc View Source ExternalProxy(String, Int32, String, String) Initializes a new instance of the ExternalProxy class. Declaration public ExternalProxy(string hostName, int port, string userName, string password) Parameters Type Name Description String hostName Name of the host. Int32 port The port. String userName Name of the user. String password The password. Properties | Improve this Doc View Source BypassLocalhost Bypass this proxy for connections to localhost? Declaration public bool BypassLocalhost { get; set; } Property Value Type Description Boolean | Improve this Doc View Source HostName Host name. Declaration public string HostName { get; set; } Property Value Type Description String | Improve this Doc View Source Password Password. Declaration public string Password { get; set; } Property Value Type Description String | Improve this Doc View Source Port Port. Declaration public int Port { get; set; } Property Value Type Description Int32 | Improve this Doc View Source ProxyType Declaration public ExternalProxyType ProxyType { get; set; } Property Value Type Description ExternalProxyType | Improve this Doc View Source UseDefaultCredentials Use default windows credentials? Declaration public bool UseDefaultCredentials { get; set; } Property Value Type Description Boolean | Improve this Doc View Source UserName Username. Declaration public string UserName { get; set; } Property Value Type Description String Methods | Improve this Doc View Source ToString() returns data in Hostname:port format. Declaration public override string ToString() Returns Type Description String Overrides Object.ToString() Implements IExternalProxy"
"keywords": "Class ExternalProxy An upstream proxy this proxy uses if any. Inheritance Object ExternalProxy Implements IExternalProxy Inherited Members Object.Equals(Object) Object.Equals(Object, Object) Object.ReferenceEquals(Object, Object) Object.GetHashCode() Object.GetType() Object.MemberwiseClone() Namespace : Titanium.Web.Proxy.Models Assembly : Titanium.Web.Proxy.dll Syntax public class ExternalProxy : IExternalProxy Constructors | Improve this Doc View Source ExternalProxy() Initializes a new instance of the ExternalProxy class. Declaration public ExternalProxy() | Improve this Doc View Source ExternalProxy(String, Int32) Initializes a new instance of the ExternalProxy class. Declaration public ExternalProxy(string hostName, int port) Parameters Type Name Description String hostName Name of the host. Int32 port The port. | Improve this Doc View Source ExternalProxy(String, Int32, String, String) Initializes a new instance of the ExternalProxy class. Declaration public ExternalProxy(string hostName, int port, string userName, string password) Parameters Type Name Description String hostName Name of the host. Int32 port The port. String userName Name of the user. String password The password. Properties | Improve this Doc View Source BypassLocalhost Bypass this proxy for connections to localhost? Declaration public bool BypassLocalhost { get; set; } Property Value Type Description Boolean | Improve this Doc View Source HostName Host name. Declaration public string HostName { get; set; } Property Value Type Description String | Improve this Doc View Source Password Password. Declaration public string Password { get; set; } Property Value Type Description String | Improve this Doc View Source Port Port. Declaration public int Port { get; set; } Property Value Type Description Int32 | Improve this Doc View Source ProxyDnsRequests Declaration public bool ProxyDnsRequests { get; set; } Property Value Type Description Boolean | Improve this Doc View Source ProxyType Declaration public ExternalProxyType ProxyType { get; set; } Property Value Type Description ExternalProxyType | Improve this Doc View Source UseDefaultCredentials Use default windows credentials? Declaration public bool UseDefaultCredentials { get; set; } Property Value Type Description Boolean | Improve this Doc View Source UserName Username. Declaration public string UserName { get; set; } Property Value Type Description String Methods | Improve this Doc View Source ToString() returns data in Hostname:port format. Declaration public override string ToString() Returns Type Description String Overrides Object.ToString() Implements IExternalProxy"
},
"api/Titanium.Web.Proxy.Models.ExternalProxyType.html": {
"href": "api/Titanium.Web.Proxy.Models.ExternalProxyType.html",
......@@ -237,7 +237,7 @@
"api/Titanium.Web.Proxy.Models.IExternalProxy.html": {
"href": "api/Titanium.Web.Proxy.Models.IExternalProxy.html",
"title": "Interface IExternalProxy | Titanium Web Proxy",
"keywords": "Interface IExternalProxy Namespace : Titanium.Web.Proxy.Models Assembly : Titanium.Web.Proxy.dll Syntax public interface IExternalProxy Properties | Improve this Doc View Source BypassLocalhost Bypass this proxy for connections to localhost? Declaration bool BypassLocalhost { get; set; } Property Value Type Description Boolean | Improve this Doc View Source HostName Host name. Declaration string HostName { get; set; } Property Value Type Description String | Improve this Doc View Source Password Password. Declaration string Password { get; set; } Property Value Type Description String | Improve this Doc View Source Port Port. Declaration int Port { get; set; } Property Value Type Description Int32 | Improve this Doc View Source ProxyType Declaration ExternalProxyType ProxyType { get; set; } Property Value Type Description ExternalProxyType | Improve this Doc View Source UseDefaultCredentials Use default windows credentials? Declaration bool UseDefaultCredentials { get; set; } Property Value Type Description Boolean | Improve this Doc View Source UserName Username. Declaration string UserName { get; set; } Property Value Type Description String Methods | Improve this Doc View Source ToString() Declaration string ToString() Returns Type Description String"
"keywords": "Interface IExternalProxy Namespace : Titanium.Web.Proxy.Models Assembly : Titanium.Web.Proxy.dll Syntax public interface IExternalProxy Properties | Improve this Doc View Source BypassLocalhost Bypass this proxy for connections to localhost? Declaration bool BypassLocalhost { get; set; } Property Value Type Description Boolean | Improve this Doc View Source HostName Host name. Declaration string HostName { get; set; } Property Value Type Description String | Improve this Doc View Source Password Password. Declaration string Password { get; set; } Property Value Type Description String | Improve this Doc View Source Port Port. Declaration int Port { get; set; } Property Value Type Description Int32 | Improve this Doc View Source ProxyDnsRequests Declaration bool ProxyDnsRequests { get; set; } Property Value Type Description Boolean | Improve this Doc View Source ProxyType Declaration ExternalProxyType ProxyType { get; set; } Property Value Type Description ExternalProxyType | Improve this Doc View Source UseDefaultCredentials Use default windows credentials? Declaration bool UseDefaultCredentials { get; set; } Property Value Type Description Boolean | Improve this Doc View Source UserName Username. Declaration string UserName { get; set; } Property Value Type Description String Methods | Improve this Doc View Source ToString() Declaration string ToString() Returns Type Description String"
},
"api/Titanium.Web.Proxy.Models.ProxyAuthenticationContext.html": {
"href": "api/Titanium.Web.Proxy.Models.ProxyAuthenticationContext.html",
......
......@@ -2669,6 +2669,19 @@ references:
isSpec: "True"
fullName: Titanium.Web.Proxy.Models.ExternalProxy.Port
nameWithType: ExternalProxy.Port
- uid: Titanium.Web.Proxy.Models.ExternalProxy.ProxyDnsRequests
name: ProxyDnsRequests
href: api/Titanium.Web.Proxy.Models.ExternalProxy.html#Titanium_Web_Proxy_Models_ExternalProxy_ProxyDnsRequests
commentId: P:Titanium.Web.Proxy.Models.ExternalProxy.ProxyDnsRequests
fullName: Titanium.Web.Proxy.Models.ExternalProxy.ProxyDnsRequests
nameWithType: ExternalProxy.ProxyDnsRequests
- uid: Titanium.Web.Proxy.Models.ExternalProxy.ProxyDnsRequests*
name: ProxyDnsRequests
href: api/Titanium.Web.Proxy.Models.ExternalProxy.html#Titanium_Web_Proxy_Models_ExternalProxy_ProxyDnsRequests_
commentId: Overload:Titanium.Web.Proxy.Models.ExternalProxy.ProxyDnsRequests
isSpec: "True"
fullName: Titanium.Web.Proxy.Models.ExternalProxy.ProxyDnsRequests
nameWithType: ExternalProxy.ProxyDnsRequests
- uid: Titanium.Web.Proxy.Models.ExternalProxy.ProxyType
name: ProxyType
href: api/Titanium.Web.Proxy.Models.ExternalProxy.html#Titanium_Web_Proxy_Models_ExternalProxy_ProxyType
......@@ -2893,6 +2906,19 @@ references:
isSpec: "True"
fullName: Titanium.Web.Proxy.Models.IExternalProxy.Port
nameWithType: IExternalProxy.Port
- uid: Titanium.Web.Proxy.Models.IExternalProxy.ProxyDnsRequests
name: ProxyDnsRequests
href: api/Titanium.Web.Proxy.Models.IExternalProxy.html#Titanium_Web_Proxy_Models_IExternalProxy_ProxyDnsRequests
commentId: P:Titanium.Web.Proxy.Models.IExternalProxy.ProxyDnsRequests
fullName: Titanium.Web.Proxy.Models.IExternalProxy.ProxyDnsRequests
nameWithType: IExternalProxy.ProxyDnsRequests
- uid: Titanium.Web.Proxy.Models.IExternalProxy.ProxyDnsRequests*
name: ProxyDnsRequests
href: api/Titanium.Web.Proxy.Models.IExternalProxy.html#Titanium_Web_Proxy_Models_IExternalProxy_ProxyDnsRequests_
commentId: Overload:Titanium.Web.Proxy.Models.IExternalProxy.ProxyDnsRequests
isSpec: "True"
fullName: Titanium.Web.Proxy.Models.IExternalProxy.ProxyDnsRequests
nameWithType: IExternalProxy.ProxyDnsRequests
- uid: Titanium.Web.Proxy.Models.IExternalProxy.ProxyType
name: ProxyType
href: api/Titanium.Web.Proxy.Models.IExternalProxy.html#Titanium_Web_Proxy_Models_IExternalProxy_ProxyType
......
......@@ -27,6 +27,8 @@ namespace Titanium.Web.Proxy.Models
public ExternalProxyType ProxyType { get; set; }
public bool ProxyDnsRequests { get; set; }
/// <summary>
/// Username.
/// </summary>
......
......@@ -14,6 +14,8 @@
ExternalProxyType ProxyType { get; set; }
bool ProxyDnsRequests { get; set; }
/// <summary>
/// Username.
/// </summary>
......
......@@ -287,8 +287,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
CancellationToken cancellationToken)
{
// deny connection to proxy end points to avoid infinite connection loop.
if (Server.ProxyEndPoints.Any(x => x.Port == remotePort)
&& NetworkHelper.IsLocalIpAddress(remoteHostName))
if (Server.ProxyEndPoints.Any(x => x.Port == remotePort)
&& NetworkHelper.IsLocalIpAddress(remoteHostName))
{
throw new Exception($"A client is making HTTP request to one of the listening ports of this proxy {remoteHostName}:{remotePort}");
}
......@@ -341,7 +341,7 @@ retry:
string hostname = remoteHostName;
int port = remotePort;
if (externalProxy != null && externalProxy.ProxyType == ExternalProxyType.Http)
if (externalProxy != null)
{
hostname = externalProxy.HostName;
port = externalProxy.Port;
......@@ -375,8 +375,7 @@ retry:
? ProxyTypes.Socks4
: ProxyTypes.Socks5;
var proxyIpAddresses = await Dns.GetHostAddressesAsync(externalProxy.HostName);
proxySocket.ProxyEndPoint = new IPEndPoint(proxyIpAddresses[0], externalProxy.Port);
proxySocket.ProxyEndPoint = new IPEndPoint(ipAddresses[0], port);
if (!string.IsNullOrEmpty(externalProxy.UserName) && externalProxy.Password != null)
{
proxySocket.ProxyUser = externalProxy.UserName;
......@@ -405,9 +404,31 @@ retry:
tcpServerSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
}
var connectTask = socks
? ProxySocketConnectionTaskFactory.CreateTask((ProxySocket.ProxySocket)tcpServerSocket, ipAddress, port)
: SocketConnectionTaskFactory.CreateTask(tcpServerSocket, ipAddress, port);
Task connectTask;
if (socks)
{
if (externalProxy!.ProxyDnsRequests)
{
connectTask = ProxySocketConnectionTaskFactory.CreateTask((ProxySocket.ProxySocket)tcpServerSocket, remoteHostName, remotePort);
}
else
{
// todo: resolve only once when the SOCKS proxy has multiple addresses (and the first address fails)
var remoteIpAddresses = await Dns.GetHostAddressesAsync(remoteHostName);
if (remoteIpAddresses == null || remoteIpAddresses.Length == 0)
{
throw new Exception($"Could not resolve the SOCKS remote hostname {remoteHostName}");
}
// todo: use the 2nd, 3rd... remote addresses when first fails
connectTask = ProxySocketConnectionTaskFactory.CreateTask((ProxySocket.ProxySocket)tcpServerSocket, remoteIpAddresses[0], remotePort);
}
}
else
{
connectTask = SocketConnectionTaskFactory.CreateTask(tcpServerSocket, ipAddress, port);
}
await Task.WhenAny(connectTask, Task.Delay(proxyServer.ConnectTimeOutSeconds * 1000, cancellationToken));
if (!connectTask.IsCompleted || !tcpServerSocket.Connected)
......@@ -423,6 +444,7 @@ retry:
{
// ignore
}
try
{
#if NET45
......@@ -741,6 +763,7 @@ retry:
}
}
}
cache.Clear();
}
finally
......@@ -784,6 +807,11 @@ retry:
return ((ProxySocket.ProxySocket)state).BeginConnect(address, port, requestCallback, state);
}
static IAsyncResult beginConnect(string hostName, int port, AsyncCallback requestCallback, object state)
{
return ((ProxySocket.ProxySocket)state).BeginConnect(hostName, port, requestCallback, state);
}
static void endConnect(IAsyncResult asyncResult)
{
((ProxySocket.ProxySocket)asyncResult.AsyncState).EndConnect(asyncResult);
......@@ -793,6 +821,11 @@ retry:
{
return Task.Factory.FromAsync(beginConnect, endConnect, ipAddress, port, state: socket);
}
public static Task CreateTask(ProxySocket.ProxySocket socket, string hostName, int port)
{
return Task.Factory.FromAsync(beginConnect, endConnect, hostName, port, state: socket);
}
}
}
}
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