Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Titanium-Web-Proxy
Commits
b296e183
Commit
b296e183
authored
Apr 14, 2018
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nuget update + CancellationToken parameters added
parent
86a1db20
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
44 additions
and
40 deletions
+44
-40
Titanium.Web.Proxy.Examples.Wpf.csproj
...Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.csproj
+2
-2
packages.config
Examples/Titanium.Web.Proxy.Examples.Wpf/packages.config
+1
-1
BeforeSslAuthenticateEventArgs.cs
...eb.Proxy/EventArguments/BeforeSslAuthenticateEventArgs.cs
+1
-1
SessionEventArgsBase.cs
Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs
+3
-3
ExplicitClientHandler.cs
Titanium.Web.Proxy/ExplicitClientHandler.cs
+9
-9
HttpWriter.cs
Titanium.Web.Proxy/Helpers/HttpWriter.cs
+4
-3
TcpConnectionFactory.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+5
-4
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+7
-5
Titanium.Web.Proxy.csproj
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
+2
-2
Titanium.Web.Proxy.nuspec
Titanium.Web.Proxy/Titanium.Web.Proxy.nuspec
+2
-2
TransparentClientHandler.cs
Titanium.Web.Proxy/TransparentClientHandler.cs
+6
-6
packages.config
Titanium.Web.Proxy/packages.config
+2
-2
No files found.
Examples/Titanium.Web.Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.csproj
View file @
b296e183
...
@@ -51,8 +51,8 @@
...
@@ -51,8 +51,8 @@
<WarningLevel>
4
</WarningLevel>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<Reference
Include=
"StreamExtended, Version=1.0.14
1
.0, Culture=neutral, PublicKeyToken=bbfa0f1d54f50043, processorArchitecture=MSIL"
>
<Reference
Include=
"StreamExtended, Version=1.0.14
7
.0, Culture=neutral, PublicKeyToken=bbfa0f1d54f50043, processorArchitecture=MSIL"
>
<HintPath>
..\..\packages\StreamExtended.1.0.14
1
-beta\lib\net45\StreamExtended.dll
</HintPath>
<HintPath>
..\..\packages\StreamExtended.1.0.14
7
-beta\lib\net45\StreamExtended.dll
</HintPath>
</Reference>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Data"
/>
<Reference
Include=
"System.Data"
/>
...
...
Examples/Titanium.Web.Proxy.Examples.Wpf/packages.config
View file @
b296e183
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
packages
>
<
package
id
=
"StreamExtended"
version
=
"1.0.14
1
-beta"
targetFramework
=
"net45"
/>
<
package
id
=
"StreamExtended"
version
=
"1.0.14
7
-beta"
targetFramework
=
"net45"
/>
</
packages
>
</
packages
>
\ No newline at end of file
Titanium.Web.Proxy/EventArguments/BeforeSslAuthenticateEventArgs.cs
View file @
b296e183
...
@@ -5,7 +5,7 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -5,7 +5,7 @@ namespace Titanium.Web.Proxy.EventArguments
{
{
public
class
BeforeSslAuthenticateEventArgs
:
EventArgs
public
class
BeforeSslAuthenticateEventArgs
:
EventArgs
{
{
internal
CancellationTokenSource
TaskCancellationSource
;
internal
readonly
CancellationTokenSource
TaskCancellationSource
;
internal
BeforeSslAuthenticateEventArgs
(
CancellationTokenSource
taskCancellationSource
)
internal
BeforeSslAuthenticateEventArgs
(
CancellationTokenSource
taskCancellationSource
)
{
{
...
...
Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs
View file @
b296e183
...
@@ -23,7 +23,7 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -23,7 +23,7 @@ namespace Titanium.Web.Proxy.EventArguments
protected
readonly
ExceptionHandler
ExceptionFunc
;
protected
readonly
ExceptionHandler
ExceptionFunc
;
internal
CancellationTokenSource
c
ancellationTokenSource
;
internal
readonly
CancellationTokenSource
C
ancellationTokenSource
;
/// <summary>
/// <summary>
/// Constructor to initialize the proxy
/// Constructor to initialize the proxy
...
@@ -40,7 +40,7 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -40,7 +40,7 @@ namespace Titanium.Web.Proxy.EventArguments
{
{
BufferSize
=
bufferSize
;
BufferSize
=
bufferSize
;
ExceptionFunc
=
exceptionFunc
;
ExceptionFunc
=
exceptionFunc
;
this
.
c
ancellationTokenSource
=
cancellationTokenSource
;
C
ancellationTokenSource
=
cancellationTokenSource
;
ProxyClient
=
new
ProxyClient
();
ProxyClient
=
new
ProxyClient
();
WebSession
=
new
HttpWebClient
(
bufferSize
,
request
);
WebSession
=
new
HttpWebClient
(
bufferSize
,
request
);
...
@@ -151,7 +151,7 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -151,7 +151,7 @@ namespace Titanium.Web.Proxy.EventArguments
/// </summary>
/// </summary>
public
void
TerminateSession
()
public
void
TerminateSession
()
{
{
c
ancellationTokenSource
.
Cancel
();
C
ancellationTokenSource
.
Cancel
();
}
}
}
}
}
}
Titanium.Web.Proxy/ExplicitClientHandler.cs
View file @
b296e183
...
@@ -44,7 +44,7 @@ namespace Titanium.Web.Proxy
...
@@ -44,7 +44,7 @@ namespace Titanium.Web.Proxy
if
(
await
HttpHelper
.
IsConnectMethod
(
clientStream
)
==
1
)
if
(
await
HttpHelper
.
IsConnectMethod
(
clientStream
)
==
1
)
{
{
//read the first line HTTP command
//read the first line HTTP command
string
httpCmd
=
await
clientStreamReader
.
ReadLineAsync
();
string
httpCmd
=
await
clientStreamReader
.
ReadLineAsync
(
cancellationTokenSource
.
Token
);
if
(
string
.
IsNullOrEmpty
(
httpCmd
))
if
(
string
.
IsNullOrEmpty
(
httpCmd
))
{
{
return
;
return
;
...
@@ -110,7 +110,7 @@ namespace Titanium.Web.Proxy
...
@@ -110,7 +110,7 @@ namespace Titanium.Web.Proxy
await
clientStreamWriter
.
WriteResponseAsync
(
response
);
await
clientStreamWriter
.
WriteResponseAsync
(
response
);
var
clientHelloInfo
=
await
SslTools
.
PeekClientHello
(
clientStream
);
var
clientHelloInfo
=
await
SslTools
.
PeekClientHello
(
clientStream
,
cancellationTokenSource
.
Token
);
bool
isClientHello
=
clientHelloInfo
!=
null
;
bool
isClientHello
=
clientHelloInfo
!=
null
;
if
(
isClientHello
)
if
(
isClientHello
)
...
@@ -150,7 +150,7 @@ namespace Titanium.Web.Proxy
...
@@ -150,7 +150,7 @@ namespace Titanium.Web.Proxy
options
.
ClientCertificateRequired
=
false
;
options
.
ClientCertificateRequired
=
false
;
options
.
EnabledSslProtocols
=
SupportedSslProtocols
;
options
.
EnabledSslProtocols
=
SupportedSslProtocols
;
options
.
CertificateRevocationCheckMode
=
X509RevocationMode
.
NoCheck
;
options
.
CertificateRevocationCheckMode
=
X509RevocationMode
.
NoCheck
;
await
sslStream
.
AuthenticateAsServerAsync
(
options
,
new
CancellationToken
(
false
)
);
await
sslStream
.
AuthenticateAsServerAsync
(
options
,
cancellationTokenSource
.
Token
);
//HTTPS server created - we can now decrypt the client's traffic
//HTTPS server created - we can now decrypt the client's traffic
clientStream
=
new
CustomBufferedStream
(
sslStream
,
BufferSize
);
clientStream
=
new
CustomBufferedStream
(
sslStream
,
BufferSize
);
...
@@ -173,7 +173,7 @@ namespace Titanium.Web.Proxy
...
@@ -173,7 +173,7 @@ namespace Titanium.Web.Proxy
}
}
}
}
if
(
c
onnectArgs
.
c
ancellationTokenSource
.
IsCancellationRequested
)
if
(
cancellationTokenSource
.
IsCancellationRequested
)
{
{
throw
new
Exception
(
"Session was terminated by user."
);
throw
new
Exception
(
"Session was terminated by user."
);
}
}
...
@@ -182,7 +182,7 @@ namespace Titanium.Web.Proxy
...
@@ -182,7 +182,7 @@ namespace Titanium.Web.Proxy
if
(!
decryptSsl
||
!
isClientHello
)
if
(!
decryptSsl
||
!
isClientHello
)
{
{
//create new connection
//create new connection
using
(
var
connection
=
await
GetServerConnection
(
connectArgs
,
true
))
using
(
var
connection
=
await
GetServerConnection
(
connectArgs
,
true
,
cancellationTokenSource
.
Token
))
{
{
if
(
isClientHello
)
if
(
isClientHello
)
{
{
...
@@ -195,8 +195,8 @@ namespace Titanium.Web.Proxy
...
@@ -195,8 +195,8 @@ namespace Titanium.Web.Proxy
try
try
{
{
// clientStream.Available sbould be at most BufferSize because it is using the same buffer size
// clientStream.Available sbould be at most BufferSize because it is using the same buffer size
await
clientStream
.
ReadAsync
(
data
,
0
,
available
);
await
clientStream
.
ReadAsync
(
data
,
0
,
available
,
cancellationTokenSource
.
Token
);
await
connection
.
StreamWriter
.
WriteAsync
(
data
,
0
,
available
,
true
);
await
connection
.
StreamWriter
.
WriteAsync
(
data
,
0
,
available
,
true
,
cancellationTokenSource
.
Token
);
}
}
finally
finally
{
{
...
@@ -204,14 +204,14 @@ namespace Titanium.Web.Proxy
...
@@ -204,14 +204,14 @@ namespace Titanium.Web.Proxy
}
}
}
}
var
serverHelloInfo
=
await
SslTools
.
PeekServerHello
(
connection
.
Stream
);
var
serverHelloInfo
=
await
SslTools
.
PeekServerHello
(
connection
.
Stream
,
cancellationTokenSource
.
Token
);
((
ConnectResponse
)
connectArgs
.
WebSession
.
Response
).
ServerHelloInfo
=
serverHelloInfo
;
((
ConnectResponse
)
connectArgs
.
WebSession
.
Response
).
ServerHelloInfo
=
serverHelloInfo
;
}
}
await
TcpHelper
.
SendRaw
(
clientStream
,
connection
.
Stream
,
BufferSize
,
await
TcpHelper
.
SendRaw
(
clientStream
,
connection
.
Stream
,
BufferSize
,
(
buffer
,
offset
,
count
)
=>
{
connectArgs
.
OnDataSent
(
buffer
,
offset
,
count
);
},
(
buffer
,
offset
,
count
)
=>
{
connectArgs
.
OnDataSent
(
buffer
,
offset
,
count
);
},
(
buffer
,
offset
,
count
)
=>
{
connectArgs
.
OnDataReceived
(
buffer
,
offset
,
count
);
},
(
buffer
,
offset
,
count
)
=>
{
connectArgs
.
OnDataReceived
(
buffer
,
offset
,
count
);
},
ExceptionFunc
,
connectArgs
.
c
ancellationTokenSource
);
ExceptionFunc
,
connectArgs
.
C
ancellationTokenSource
);
}
}
return
;
return
;
...
...
Titanium.Web.Proxy/Helpers/HttpWriter.cs
View file @
b296e183
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
using
System.Globalization
;
using
System.Globalization
;
using
System.IO
;
using
System.IO
;
using
System.Text
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
StreamExtended.Helpers
;
using
StreamExtended.Helpers
;
using
StreamExtended.Network
;
using
StreamExtended.Network
;
...
@@ -114,12 +115,12 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -114,12 +115,12 @@ namespace Titanium.Web.Proxy.Helpers
}
}
}
}
public
async
Task
WriteAsync
(
byte
[]
data
,
int
offset
,
int
count
,
bool
flush
)
public
async
Task
WriteAsync
(
byte
[]
data
,
int
offset
,
int
count
,
bool
flush
,
CancellationToken
cancellationToken
)
{
{
await
WriteAsync
(
data
,
offset
,
count
);
await
WriteAsync
(
data
,
offset
,
count
,
cancellationToken
);
if
(
flush
)
if
(
flush
)
{
{
await
FlushAsync
();
await
FlushAsync
(
cancellationToken
);
}
}
}
}
...
...
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
b296e183
...
@@ -31,10 +31,11 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -31,10 +31,11 @@ namespace Titanium.Web.Proxy.Network.Tcp
/// <param name="proxyServer"></param>
/// <param name="proxyServer"></param>
/// <param name="upStreamEndPoint"></param>
/// <param name="upStreamEndPoint"></param>
/// <param name="externalProxy"></param>
/// <param name="externalProxy"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <returns></returns>
internal
async
Task
<
TcpConnection
>
CreateClient
(
string
remoteHostName
,
int
remotePort
,
internal
async
Task
<
TcpConnection
>
CreateClient
(
string
remoteHostName
,
int
remotePort
,
List
<
SslApplicationProtocol
>
applicationProtocols
,
Version
httpVersion
,
bool
isHttps
,
bool
isConnect
,
List
<
SslApplicationProtocol
>
applicationProtocols
,
Version
httpVersion
,
bool
isHttps
,
bool
isConnect
,
ProxyServer
proxyServer
,
IPEndPoint
upStreamEndPoint
,
ExternalProxy
externalProxy
)
ProxyServer
proxyServer
,
IPEndPoint
upStreamEndPoint
,
ExternalProxy
externalProxy
,
CancellationToken
cancellationToken
)
{
{
bool
useUpstreamProxy
=
false
;
bool
useUpstreamProxy
=
false
;
...
@@ -89,7 +90,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -89,7 +90,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
using
(
var
reader
=
new
CustomBinaryReader
(
stream
,
proxyServer
.
BufferSize
))
using
(
var
reader
=
new
CustomBinaryReader
(
stream
,
proxyServer
.
BufferSize
))
{
{
string
httpStatus
=
await
reader
.
ReadLineAsync
();
string
httpStatus
=
await
reader
.
ReadLineAsync
(
cancellationToken
);
Response
.
ParseResponseLine
(
httpStatus
,
out
_
,
out
int
statusCode
,
out
string
statusDescription
);
Response
.
ParseResponseLine
(
httpStatus
,
out
_
,
out
int
statusCode
,
out
string
statusDescription
);
...
@@ -99,7 +100,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -99,7 +100,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
throw
new
Exception
(
"Upstream proxy failed to create a secure tunnel"
);
throw
new
Exception
(
"Upstream proxy failed to create a secure tunnel"
);
}
}
await
reader
.
ReadAndIgnoreAllLinesAsync
();
await
reader
.
ReadAndIgnoreAllLinesAsync
(
cancellationToken
);
}
}
}
}
...
@@ -123,7 +124,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -123,7 +124,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
options
.
ClientCertificates
=
null
;
options
.
ClientCertificates
=
null
;
options
.
EnabledSslProtocols
=
proxyServer
.
SupportedSslProtocols
;
options
.
EnabledSslProtocols
=
proxyServer
.
SupportedSslProtocols
;
options
.
CertificateRevocationCheckMode
=
proxyServer
.
CheckCertificateRevocation
;
options
.
CertificateRevocationCheckMode
=
proxyServer
.
CheckCertificateRevocation
;
await
sslStream
.
AuthenticateAsClientAsync
(
options
,
new
CancellationToken
(
false
)
);
await
sslStream
.
AuthenticateAsClientAsync
(
options
,
cancellationToken
);
}
}
client
.
ReceiveTimeout
=
proxyServer
.
ConnectionTimeOutSeconds
*
1000
;
client
.
ReceiveTimeout
=
proxyServer
.
ConnectionTimeOutSeconds
*
1000
;
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
b296e183
...
@@ -196,7 +196,7 @@ namespace Titanium.Web.Proxy
...
@@ -196,7 +196,7 @@ namespace Titanium.Web.Proxy
if
(
connection
==
null
)
if
(
connection
==
null
)
{
{
connection
=
await
GetServerConnection
(
args
,
false
);
connection
=
await
GetServerConnection
(
args
,
false
,
cancellationTokenSource
.
Token
);
}
}
//if upgrading to websocket then relay the requet without reading the contents
//if upgrading to websocket then relay the requet without reading the contents
...
@@ -230,7 +230,7 @@ namespace Titanium.Web.Proxy
...
@@ -230,7 +230,7 @@ namespace Titanium.Web.Proxy
await
TcpHelper
.
SendRaw
(
clientStream
,
connection
.
Stream
,
BufferSize
,
await
TcpHelper
.
SendRaw
(
clientStream
,
connection
.
Stream
,
BufferSize
,
(
buffer
,
offset
,
count
)
=>
{
args
.
OnDataSent
(
buffer
,
offset
,
count
);
},
(
buffer
,
offset
,
count
)
=>
{
args
.
OnDataSent
(
buffer
,
offset
,
count
);
},
(
buffer
,
offset
,
count
)
=>
{
args
.
OnDataReceived
(
buffer
,
offset
,
count
);
},
(
buffer
,
offset
,
count
)
=>
{
args
.
OnDataReceived
(
buffer
,
offset
,
count
);
},
ExceptionFunc
,
args
.
cancellationTokenSource
);
ExceptionFunc
,
cancellationTokenSource
);
return
;
return
;
}
}
...
@@ -249,7 +249,7 @@ namespace Titanium.Web.Proxy
...
@@ -249,7 +249,7 @@ namespace Titanium.Web.Proxy
return
;
return
;
}
}
if
(
args
.
cancellationTokenSource
.
IsCancellationRequested
)
if
(
cancellationTokenSource
.
IsCancellationRequested
)
{
{
throw
new
Exception
(
"Session was terminated by user."
);
throw
new
Exception
(
"Session was terminated by user."
);
}
}
...
@@ -364,8 +364,9 @@ namespace Titanium.Web.Proxy
...
@@ -364,8 +364,9 @@ namespace Titanium.Web.Proxy
/// </summary>
/// </summary>
/// <param name="args"></param>
/// <param name="args"></param>
/// <param name="isConnect"></param>
/// <param name="isConnect"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <returns></returns>
private
async
Task
<
TcpConnection
>
GetServerConnection
(
SessionEventArgsBase
args
,
bool
isConnect
)
private
async
Task
<
TcpConnection
>
GetServerConnection
(
SessionEventArgsBase
args
,
bool
isConnect
,
CancellationToken
cancellationToken
)
{
{
ExternalProxy
customUpStreamProxy
=
null
;
ExternalProxy
customUpStreamProxy
=
null
;
...
@@ -383,7 +384,8 @@ namespace Titanium.Web.Proxy
...
@@ -383,7 +384,8 @@ namespace Titanium.Web.Proxy
args
.
WebSession
.
ConnectRequest
?.
ClientHelloInfo
?.
GetAlpn
(),
args
.
WebSession
.
ConnectRequest
?.
ClientHelloInfo
?.
GetAlpn
(),
args
.
WebSession
.
Request
.
HttpVersion
,
isHttps
,
isConnect
,
args
.
WebSession
.
Request
.
HttpVersion
,
isHttps
,
isConnect
,
this
,
args
.
WebSession
.
UpStreamEndPoint
??
UpStreamEndPoint
,
this
,
args
.
WebSession
.
UpStreamEndPoint
??
UpStreamEndPoint
,
customUpStreamProxy
??
(
isHttps
?
UpStreamHttpsProxy
:
UpStreamHttpProxy
));
customUpStreamProxy
??
(
isHttps
?
UpStreamHttpsProxy
:
UpStreamHttpProxy
),
cancellationToken
);
}
}
/// <summary>
/// <summary>
...
...
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
View file @
b296e183
...
@@ -12,8 +12,8 @@
...
@@ -12,8 +12,8 @@
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<PackageReference Include="Portable.BouncyCastle" Version="1.8.
1.4
" />
<PackageReference Include="Portable.BouncyCastle" Version="1.8.
2
" />
<PackageReference Include="StreamExtended" Version="1.0.14
1
-beta" />
<PackageReference Include="StreamExtended" Version="1.0.14
7
-beta" />
</ItemGroup>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
...
...
Titanium.Web.Proxy/Titanium.Web.Proxy.nuspec
View file @
b296e183
...
@@ -14,8 +14,8 @@
...
@@ -14,8 +14,8 @@
<copyright>
Copyright
©
Titanium. All rights reserved.
</copyright>
<copyright>
Copyright
©
Titanium. All rights reserved.
</copyright>
<tags></tags>
<tags></tags>
<dependencies>
<dependencies>
<dependency
id=
"StreamExtended"
version=
"1.0.14
1
-beta"
/>
<dependency
id=
"StreamExtended"
version=
"1.0.14
7
-beta"
/>
<dependency
id=
"Portable.BouncyCastle"
version=
"1.8.
1.4
"
/>
<dependency
id=
"Portable.BouncyCastle"
version=
"1.8.
2
"
/>
</dependencies>
</dependencies>
</metadata>
</metadata>
<files>
<files>
...
...
Titanium.Web.Proxy/TransparentClientHandler.cs
View file @
b296e183
...
@@ -34,7 +34,7 @@ namespace Titanium.Web.Proxy
...
@@ -34,7 +34,7 @@ namespace Titanium.Web.Proxy
try
try
{
{
var
clientHelloInfo
=
await
SslTools
.
PeekClientHello
(
clientStream
);
var
clientHelloInfo
=
await
SslTools
.
PeekClientHello
(
clientStream
,
cancellationTokenSource
.
Token
);
bool
isHttps
=
clientHelloInfo
!=
null
;
bool
isHttps
=
clientHelloInfo
!=
null
;
string
httpsHostName
=
null
;
string
httpsHostName
=
null
;
...
@@ -47,7 +47,7 @@ namespace Titanium.Web.Proxy
...
@@ -47,7 +47,7 @@ namespace Titanium.Web.Proxy
args
.
SniHostName
=
httpsHostName
;
args
.
SniHostName
=
httpsHostName
;
await
endPoint
.
InvokeBeforeSslAuthenticate
(
this
,
args
,
ExceptionFunc
);
await
endPoint
.
InvokeBeforeSslAuthenticate
(
this
,
args
,
ExceptionFunc
);
if
(
args
.
TaskCancellatio
nSource
.
IsCancellationRequested
)
if
(
cancellationToke
nSource
.
IsCancellationRequested
)
{
{
throw
new
Exception
(
"Session was terminated by user."
);
throw
new
Exception
(
"Session was terminated by user."
);
}
}
...
@@ -102,9 +102,9 @@ namespace Titanium.Web.Proxy
...
@@ -102,9 +102,9 @@ namespace Titanium.Web.Proxy
try
try
{
{
// clientStream.Available sbould be at most BufferSize because it is using the same buffer size
// clientStream.Available sbould be at most BufferSize because it is using the same buffer size
await
clientStream
.
ReadAsync
(
data
,
0
,
available
);
await
clientStream
.
ReadAsync
(
data
,
0
,
available
,
cancellationTokenSource
.
Token
);
await
serverStream
.
WriteAsync
(
data
,
0
,
available
);
await
serverStream
.
WriteAsync
(
data
,
0
,
available
,
cancellationTokenSource
.
Token
);
await
serverStream
.
FlushAsync
();
await
serverStream
.
FlushAsync
(
cancellationTokenSource
.
Token
);
}
}
finally
finally
{
{
...
@@ -115,7 +115,7 @@ namespace Titanium.Web.Proxy
...
@@ -115,7 +115,7 @@ namespace Titanium.Web.Proxy
//var serverHelloInfo = await SslTools.PeekServerHello(serverStream);
//var serverHelloInfo = await SslTools.PeekServerHello(serverStream);
await
TcpHelper
.
SendRaw
(
clientStream
,
serverStream
,
BufferSize
,
await
TcpHelper
.
SendRaw
(
clientStream
,
serverStream
,
BufferSize
,
null
,
null
,
ExceptionFunc
,
args
.
TaskCancellatio
nSource
);
null
,
null
,
ExceptionFunc
,
cancellationToke
nSource
);
}
}
}
}
}
}
...
...
Titanium.Web.Proxy/packages.config
View file @
b296e183
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
packages
>
<
package
id
=
"Portable.BouncyCastle"
version
=
"1.8.
1.4
"
targetFramework
=
"net45"
/>
<
package
id
=
"Portable.BouncyCastle"
version
=
"1.8.
2
"
targetFramework
=
"net45"
/>
<
package
id
=
"StreamExtended"
version
=
"1.0.14
1
-beta"
targetFramework
=
"net45"
/>
<
package
id
=
"StreamExtended"
version
=
"1.0.14
7
-beta"
targetFramework
=
"net45"
/>
</
packages
>
</
packages
>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment