Unverified Commit 500ceade authored by honfika's avatar honfika Committed by GitHub

Merge pull request #720 from justcoding121/master

beta
parents bc6e3810 11fdeac1
......@@ -155,6 +155,9 @@ or when server terminates connection from proxy.</p>
<div>
<a class="xref" href="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_IsTransparent">SessionEventArgsBase.IsTransparent</a>
</div>
<div>
<a class="xref" href="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_IsSocks">SessionEventArgsBase.IsSocks</a>
</div>
<div>
<a class="xref" href="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_Exception">SessionEventArgsBase.Exception</a>
</div>
......
......@@ -390,7 +390,7 @@ public IPEndPoint ClientEndPoint { get; }</code></pre>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_Exception.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.Exception%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/EventArguments/SessionEventArgsBase.cs/#L146">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs/#L151">View Source</a>
</span>
<a id="Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_Exception_" data-uid="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.Exception*"></a>
<h4 id="Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_Exception" data-uid="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.Exception">Exception</h4>
......@@ -478,6 +478,37 @@ public IPEndPoint ClientEndPoint { get; }</code></pre>
</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_EventArguments_SessionEventArgsBase_IsSocks.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsSocks%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/EventArguments/SessionEventArgsBase.cs/#L146">View Source</a>
</span>
<a id="Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_IsSocks_" data-uid="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsSocks*"></a>
<h4 id="Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_IsSocks" data-uid="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsSocks">IsSocks</h4>
<div class="markdown level1 summary"><p>Is this a SOCKS endpoint?</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public bool IsSocks { get; }</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_EventArguments_SessionEventArgsBase_IsTransparent.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsTransparent%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>
......@@ -702,7 +733,7 @@ public HttpWebClient WebSession { get; }</code></pre>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_Dispose.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.Dispose%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/EventArguments/SessionEventArgsBase.cs/#L151">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs/#L156">View Source</a>
</span>
<a id="Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_Dispose_" data-uid="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.Dispose*"></a>
<h4 id="Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_Dispose" data-uid="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.Dispose">Dispose()</h4>
......@@ -718,7 +749,7 @@ public HttpWebClient WebSession { get; }</code></pre>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_TerminateSession.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.TerminateSession%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/EventArguments/SessionEventArgsBase.cs/#L199">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs/#L204">View Source</a>
</span>
<a id="Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_TerminateSession_" data-uid="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.TerminateSession*"></a>
<h4 id="Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_TerminateSession" data-uid="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.TerminateSession">TerminateSession()</h4>
......@@ -736,7 +767,7 @@ public HttpWebClient WebSession { get; }</code></pre>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_DataReceived.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.DataReceived%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/EventArguments/SessionEventArgsBase.cs/#L170">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs/#L175">View Source</a>
</span>
<h4 id="Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_DataReceived" data-uid="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.DataReceived">DataReceived</h4>
<div class="markdown level1 summary"><p>Fired when data is received within this session from client/server.</p>
......@@ -766,7 +797,7 @@ public HttpWebClient WebSession { get; }</code></pre>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_DataSent.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.DataSent%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/EventArguments/SessionEventArgsBase.cs/#L165">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs/#L170">View Source</a>
</span>
<h4 id="Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_DataSent" data-uid="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.DataSent">DataSent</h4>
<div class="markdown level1 summary"><p>Fired when data is sent within this session to server/client.</p>
......
......@@ -152,6 +152,9 @@
<div>
<a class="xref" href="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_IsTransparent">SessionEventArgsBase.IsTransparent</a>
</div>
<div>
<a class="xref" href="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_IsSocks">SessionEventArgsBase.IsSocks</a>
</div>
<div>
<a class="xref" href="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_Exception">SessionEventArgsBase.Exception</a>
</div>
......
This diff is collapsed.
......@@ -732,6 +732,19 @@ references:
isSpec: "True"
fullName: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsHttps
nameWithType: SessionEventArgsBase.IsHttps
- uid: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsSocks
name: IsSocks
href: api/Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_IsSocks
commentId: P:Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsSocks
fullName: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsSocks
nameWithType: SessionEventArgsBase.IsSocks
- uid: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsSocks*
name: IsSocks
href: api/Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_IsSocks_
commentId: Overload:Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsSocks
isSpec: "True"
fullName: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsSocks
nameWithType: SessionEventArgsBase.IsSocks
- uid: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsTransparent
name: IsTransparent
href: api/Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_IsTransparent
......
......@@ -140,6 +140,11 @@ namespace Titanium.Web.Proxy.EventArguments
/// </summary>
public bool IsTransparent => ProxyEndPoint is TransparentProxyEndPoint;
/// <summary>
/// Is this a SOCKS endpoint?
/// </summary>
public bool IsSocks => ProxyEndPoint is SocksProxyEndPoint;
/// <summary>
/// The last exception that happened.
/// </summary>
......
......@@ -90,7 +90,7 @@ namespace Titanium.Web.Proxy
request.Method = requestLine.Method;
request.HttpVersion = requestLine.Version;
if (!args.IsTransparent)
if (!args.IsTransparent && !args.IsSocks)
{
// proxy authorization check
if (connectRequest == null && await checkAuthorization(args) == false)
......
......@@ -99,7 +99,7 @@ namespace Titanium.Web.Proxy
response.Locked = true;
if (!args.IsTransparent)
if (!args.IsTransparent && !args.IsSocks)
{
response.Headers.FixProxyHeaders();
}
......
using System;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Titanium.Web.Proxy.Extensions;
......@@ -48,13 +49,76 @@ namespace Titanium.Web.Proxy
}
else if (buffer[0] == 5)
{
if (buffer[1] == 0 || buffer[2] != 0)
int authenticationMethodCount = buffer[1];
if (read < authenticationMethodCount + 2)
{
return;
}
buffer[1] = 0;
int acceptedMethod = 255;
for (int i = 0; i < authenticationMethodCount; i++)
{
int method = buffer[i + 2];
if (method == 0 && ProxyBasicAuthenticateFunc == null)
{
acceptedMethod = 0;
break;
}
if (method == 2)
{
acceptedMethod = 2;
break;
}
}
buffer[1] = (byte)acceptedMethod;
await stream.WriteAsync(buffer, 0, 2, cancellationToken);
if (acceptedMethod == 255)
{
// no acceptable method
return;
}
if (acceptedMethod == 2)
{
read = await stream.ReadAsync(buffer, 0, buffer.Length, cancellationToken);
if (read < 3 || buffer[0] != 1)
{
// authentication version should be 1
return;
}
int userNameLength = buffer[1];
if (read < 3 + userNameLength)
{
return;
}
string userName = Encoding.ASCII.GetString(buffer, 2, userNameLength);
int passwordLength = buffer[2 + userNameLength];
if (read < 3 + userNameLength + passwordLength)
{
return;
}
string password = Encoding.ASCII.GetString(buffer, 3 + userNameLength, passwordLength);
bool success = true;
if (ProxySchemeAuthenticateFunc != null)
{
success = await ProxyBasicAuthenticateFunc.Invoke(null, userName, password);
}
buffer[1] = success ? (byte)0 : (byte)1;
await stream.WriteAsync(buffer, 0, 2, cancellationToken);
if (!success)
{
return;
}
}
read = await stream.ReadAsync(buffer, 0, buffer.Length, cancellationToken);
if (read < 10 || buffer[1] != 1)
{
......
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