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
f870fad5
Commit
f870fad5
authored
Apr 14, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
order method signatures for readabilty
parent
59792b59
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
43 additions
and
39 deletions
+43
-39
AsyncEventHandler.cs
Titanium.Web.Proxy/EventArguments/AsyncEventHandler.cs
+1
-2
BeforeSslAuthenticateEventArgs.cs
...eb.Proxy/EventArguments/BeforeSslAuthenticateEventArgs.cs
+1
-1
DataEventArgs.cs
Titanium.Web.Proxy/EventArguments/DataEventArgs.cs
+1
-1
LimitedStream.cs
Titanium.Web.Proxy/EventArguments/LimitedStream.cs
+1
-1
SessionEventArgs.cs
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
+6
-4
SessionEventArgsBase.cs
Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs
+6
-4
TunnelConnectEventArgs.cs
Titanium.Web.Proxy/EventArguments/TunnelConnectEventArgs.cs
+1
-1
ExplicitClientHandler.cs
Titanium.Web.Proxy/ExplicitClientHandler.cs
+1
-1
TcpConnectionFactory.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+15
-15
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+8
-7
TransparentClientHandler.cs
Titanium.Web.Proxy/TransparentClientHandler.cs
+2
-2
No files found.
Titanium.Web.Proxy/EventArguments/AsyncEventHandler.cs
View file @
f870fad5
using
System
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
namespace
Titanium.Web.Proxy.EventArguments
{
...
...
Titanium.Web.Proxy/EventArguments/BeforeSslAuthenticateEventArgs.cs
View file @
f870fad5
...
...
@@ -9,7 +9,7 @@ namespace Titanium.Web.Proxy.EventArguments
internal
BeforeSslAuthenticateEventArgs
(
CancellationTokenSource
taskCancellationSource
)
{
this
.
TaskCancellationSource
=
taskCancellationSource
;
TaskCancellationSource
=
taskCancellationSource
;
}
public
string
SniHostName
{
get
;
internal
set
;
}
...
...
Titanium.Web.Proxy/EventArguments/DataEventArgs.cs
View file @
f870fad5
...
...
@@ -10,7 +10,7 @@ namespace Titanium.Web.Proxy.EventArguments
public
int
Count
{
get
;
}
public
DataEventArgs
(
byte
[]
buffer
,
int
offset
,
int
count
)
internal
DataEventArgs
(
byte
[]
buffer
,
int
offset
,
int
count
)
{
Buffer
=
buffer
;
Offset
=
offset
;
...
...
Titanium.Web.Proxy/EventArguments/LimitedStream.cs
View file @
f870fad5
...
...
@@ -16,7 +16,7 @@ namespace Titanium.Web.Proxy.EventArguments
private
bool
readChunkTrail
;
private
long
bytesRemaining
;
public
LimitedStream
(
CustomBufferedStream
baseStream
,
CustomBinaryReader
baseReader
,
bool
isChunked
,
long
contentLength
)
internal
LimitedStream
(
CustomBufferedStream
baseStream
,
CustomBinaryReader
baseReader
,
bool
isChunked
,
long
contentLength
)
{
this
.
baseStream
=
baseStream
;
this
.
baseReader
=
baseReader
;
...
...
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
View file @
f870fad5
...
...
@@ -57,13 +57,15 @@ namespace Titanium.Web.Proxy.EventArguments
/// <summary>
/// Constructor to initialize the proxy
/// </summary>
internal
SessionEventArgs
(
int
bufferSize
,
ProxyEndPoint
endPoint
,
ExceptionHandler
exceptionFunc
,
CancellationTokenSource
cancellationTokenSource
)
:
this
(
bufferSize
,
endPoint
,
exceptionFunc
,
null
,
cancellationTokenSource
)
internal
SessionEventArgs
(
int
bufferSize
,
ProxyEndPoint
endPoint
,
CancellationTokenSource
cancellationTokenSource
,
ExceptionHandler
exceptionFunc
)
:
this
(
bufferSize
,
endPoint
,
cancellationTokenSource
,
null
,
exceptionFunc
)
{
}
protected
SessionEventArgs
(
int
bufferSize
,
ProxyEndPoint
endPoint
,
ExceptionHandler
exceptionFunc
,
Request
request
,
CancellationTokenSource
cancellationTokenSource
)
:
base
(
bufferSize
,
endPoint
,
exceptionFunc
,
request
,
cancellationTokenSource
)
protected
SessionEventArgs
(
int
bufferSize
,
ProxyEndPoint
endPoint
,
CancellationTokenSource
cancellationTokenSource
,
Request
request
,
ExceptionHandler
exceptionFunc
)
:
base
(
bufferSize
,
endPoint
,
cancellationTokenSource
,
request
,
exceptionFunc
)
{
}
...
...
Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs
View file @
f870fad5
...
...
@@ -70,13 +70,15 @@ namespace Titanium.Web.Proxy.EventArguments
/// <summary>
/// Constructor to initialize the proxy
/// </summary>
internal
SessionEventArgsBase
(
int
bufferSize
,
ProxyEndPoint
endPoint
,
ExceptionHandler
exceptionFunc
,
CancellationTokenSource
cancellationTokenSource
)
:
this
(
bufferSize
,
endPoint
,
exceptionFunc
,
null
,
cancellationTokenSource
)
internal
SessionEventArgsBase
(
int
bufferSize
,
ProxyEndPoint
endPoint
,
CancellationTokenSource
cancellationTokenSource
,
ExceptionHandler
exceptionFunc
)
:
this
(
bufferSize
,
endPoint
,
cancellationTokenSource
,
null
,
exceptionFunc
)
{
}
protected
SessionEventArgsBase
(
int
bufferSize
,
ProxyEndPoint
endPoint
,
ExceptionHandler
exceptionFunc
,
Request
request
,
CancellationTokenSource
cancellationTokenSource
)
protected
SessionEventArgsBase
(
int
bufferSize
,
ProxyEndPoint
endPoint
,
CancellationTokenSource
cancellationTokenSource
,
Request
request
,
ExceptionHandler
exceptionFunc
)
{
this
.
BufferSize
=
bufferSize
;
this
.
ExceptionFunc
=
exceptionFunc
;
...
...
Titanium.Web.Proxy/EventArguments/TunnelConnectEventArgs.cs
View file @
f870fad5
...
...
@@ -17,7 +17,7 @@ namespace Titanium.Web.Proxy.EventArguments
public
bool
IsHttpsConnect
{
get
;
internal
set
;
}
internal
TunnelConnectSessionEventArgs
(
int
bufferSize
,
ProxyEndPoint
endPoint
,
ConnectRequest
connectRequest
,
ExceptionHandler
exceptionFunc
,
CancellationTokenSource
cancellationTokenSource
)
:
base
(
bufferSize
,
endPoint
,
exceptionFunc
,
connectRequest
,
cancellationTokenSource
)
:
base
(
bufferSize
,
endPoint
,
cancellationTokenSource
,
connectRequest
,
exceptionFunc
)
{
}
}
...
...
Titanium.Web.Proxy/ExplicitClientHandler.cs
View file @
f870fad5
...
...
@@ -200,7 +200,7 @@ namespace Titanium.Web.Proxy
}
//Now create the request
await
HandleHttpSessionRequest
(
tcpClient
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
connectHostname
,
endPoint
,
connectRequest
,
cancellationTokenSource
);
await
HandleHttpSessionRequest
(
endPoint
,
tcpClient
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
cancellationTokenSource
,
connectHostname
,
connectRequest
);
}
catch
(
ProxyHttpException
e
)
{
...
...
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
f870fad5
...
...
@@ -21,18 +21,18 @@ namespace Titanium.Web.Proxy.Network.Tcp
/// <summary>
/// Creates a TCP connection to server
/// </summary>
/// <param name="server"></param>
/// <param name="remoteHostName"></param>
/// <param name="remotePort"></param>
/// <param name="httpVersion"></param>
/// <param name="isHttps"></param>
/// <param name="isConnect"></param>
/// <param name="proxyServer"></param>
/// <param name="upStreamEndPoint"></param>
/// <param name="externalProxy"></param>
/// <returns></returns>
internal
async
Task
<
TcpConnection
>
CreateClient
(
ProxyServer
server
,
string
remoteHostName
,
int
remotePort
,
Version
httpVersion
,
bool
isHttps
,
bool
isConnect
,
IPEndPoint
upStreamEndPoint
,
ExternalProxy
externalProxy
)
internal
async
Task
<
TcpConnection
>
CreateClient
(
string
remoteHostName
,
int
remotePort
,
Version
httpVersion
,
bool
isHttps
,
bool
isConnect
,
ProxyServer
proxyServer
,
IPEndPoint
upStreamEndPoint
,
ExternalProxy
externalProxy
)
{
bool
useUpstreamProxy
=
false
;
...
...
@@ -65,11 +65,11 @@ namespace Titanium.Web.Proxy.Network.Tcp
await
client
.
ConnectAsync
(
remoteHostName
,
remotePort
);
}
stream
=
new
CustomBufferedStream
(
client
.
GetStream
(),
s
erver
.
BufferSize
);
stream
=
new
CustomBufferedStream
(
client
.
GetStream
(),
proxyS
erver
.
BufferSize
);
if
(
useUpstreamProxy
&&
(
isConnect
||
isHttps
))
{
var
writer
=
new
HttpRequestWriter
(
stream
,
s
erver
.
BufferSize
);
var
writer
=
new
HttpRequestWriter
(
stream
,
proxyS
erver
.
BufferSize
);
await
writer
.
WriteLineAsync
(
$"CONNECT
{
remoteHostName
}
:
{
remotePort
}
HTTP/
{
httpVersion
}
"
);
await
writer
.
WriteLineAsync
(
$"Host:
{
remoteHostName
}
:
{
remotePort
}
"
);
await
writer
.
WriteLineAsync
(
$"
{
KnownHeaders
.
Connection
}
:
{
KnownHeaders
.
ConnectionKeepAlive
}
"
);
...
...
@@ -84,7 +84,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
await
writer
.
WriteLineAsync
();
using
(
var
reader
=
new
CustomBinaryReader
(
stream
,
s
erver
.
BufferSize
))
using
(
var
reader
=
new
CustomBinaryReader
(
stream
,
proxyS
erver
.
BufferSize
))
{
string
httpStatus
=
await
reader
.
ReadLineAsync
();
...
...
@@ -102,14 +102,14 @@ namespace Titanium.Web.Proxy.Network.Tcp
if
(
isHttps
)
{
var
sslStream
=
new
SslStream
(
stream
,
false
,
server
.
ValidateServerCertificate
,
s
erver
.
SelectClientCertificate
);
stream
=
new
CustomBufferedStream
(
sslStream
,
s
erver
.
BufferSize
);
var
sslStream
=
new
SslStream
(
stream
,
false
,
proxyServer
.
ValidateServerCertificate
,
proxyS
erver
.
SelectClientCertificate
);
stream
=
new
CustomBufferedStream
(
sslStream
,
proxyS
erver
.
BufferSize
);
await
sslStream
.
AuthenticateAsClientAsync
(
remoteHostName
,
null
,
server
.
SupportedSslProtocols
,
s
erver
.
CheckCertificateRevocation
);
await
sslStream
.
AuthenticateAsClientAsync
(
remoteHostName
,
null
,
proxyServer
.
SupportedSslProtocols
,
proxyS
erver
.
CheckCertificateRevocation
);
}
client
.
ReceiveTimeout
=
s
erver
.
ConnectionTimeOutSeconds
*
1000
;
client
.
SendTimeout
=
s
erver
.
ConnectionTimeOutSeconds
*
1000
;
client
.
ReceiveTimeout
=
proxyS
erver
.
ConnectionTimeOutSeconds
*
1000
;
client
.
SendTimeout
=
proxyS
erver
.
ConnectionTimeOutSeconds
*
1000
;
}
catch
(
Exception
)
{
...
...
@@ -118,7 +118,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
throw
;
}
return
new
TcpConnection
(
s
erver
)
return
new
TcpConnection
(
proxyS
erver
)
{
UpStreamProxy
=
externalProxy
,
UpStreamEndPoint
=
upStreamEndPoint
,
...
...
@@ -127,8 +127,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
IsHttps
=
isHttps
,
UseUpstreamProxy
=
useUpstreamProxy
,
TcpClient
=
client
,
StreamReader
=
new
CustomBinaryReader
(
stream
,
s
erver
.
BufferSize
),
StreamWriter
=
new
HttpRequestWriter
(
stream
,
s
erver
.
BufferSize
),
StreamReader
=
new
CustomBinaryReader
(
stream
,
proxyS
erver
.
BufferSize
),
StreamWriter
=
new
HttpRequestWriter
(
stream
,
proxyS
erver
.
BufferSize
),
Stream
=
stream
,
Version
=
httpVersion
};
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
f870fad5
...
...
@@ -33,14 +33,15 @@ namespace Titanium.Web.Proxy
/// <param name="clientStream"></param>
/// <param name="clientStreamReader"></param>
/// <param name="clientStreamWriter"></param>
/// <param name="cancellationTokenSource"></param>
/// <param name="httpsConnectHostname"></param>
/// <param name="endPoint"></param>
/// <param name="connectRequest"></param>
/// <param name="isTransparentEndPoint"></param>
/// <returns></returns>
private
async
Task
HandleHttpSessionRequest
(
TcpClient
client
,
CustomBufferedStream
clientStream
,
CustomB
inaryReader
clientStreamReader
,
HttpResponseWriter
clientStreamWriter
,
string
httpsConnectHostname
,
ProxyEndPoint
endPoint
,
ConnectRequest
connectRequest
,
CancellationTokenSource
cancellationTokenSource
,
bool
isTransparentEndPoint
=
false
)
private
async
Task
HandleHttpSessionRequest
(
ProxyEndPoint
endPoint
,
TcpClient
client
,
CustomB
ufferedStream
clientStream
,
CustomBinaryReader
clientStreamReader
,
HttpResponseWriter
clientStreamWriter
,
CancellationTokenSource
cancellationTokenSource
,
string
httpsConnectHostname
,
ConnectRequest
connectRequest
,
bool
isTransparentEndPoint
=
false
)
{
TcpConnection
connection
=
null
;
...
...
@@ -57,7 +58,7 @@ namespace Titanium.Web.Proxy
return
;
}
var
args
=
new
SessionEventArgs
(
BufferSize
,
endPoint
,
ExceptionFunc
,
cancellationTokenSource
)
var
args
=
new
SessionEventArgs
(
BufferSize
,
endPoint
,
cancellationTokenSource
,
ExceptionFunc
)
{
ProxyClient
=
{
TcpClient
=
client
},
WebSession
=
{
ConnectRequest
=
connectRequest
}
...
...
@@ -354,11 +355,11 @@ namespace Titanium.Web.Proxy
args
.
CustomUpStreamProxyUsed
=
customUpStreamProxy
;
return
await
tcpConnectionFactory
.
CreateClient
(
this
,
args
.
WebSession
.
Request
.
RequestUri
.
Host
,
return
await
tcpConnectionFactory
.
CreateClient
(
args
.
WebSession
.
Request
.
RequestUri
.
Host
,
args
.
WebSession
.
Request
.
RequestUri
.
Port
,
args
.
WebSession
.
Request
.
HttpVersion
,
isHttps
,
isConnect
,
isHttps
,
isConnect
,
this
,
args
.
WebSession
.
UpStreamEndPoint
??
UpStreamEndPoint
,
customUpStreamProxy
??
(
isHttps
?
UpStreamHttpsProxy
:
UpStreamHttpProxy
));
}
...
...
Titanium.Web.Proxy/TransparentClientHandler.cs
View file @
f870fad5
...
...
@@ -122,8 +122,8 @@ namespace Titanium.Web.Proxy
//HTTPS server created - we can now decrypt the client's traffic
//Now create the request
await
HandleHttpSessionRequest
(
tcpClient
,
clientStream
,
clientStreamReader
,
clientStreamWrit
er
,
isHttps
?
httpsHostName
:
null
,
endPoint
,
null
,
cancellationTokenSource
,
true
);
await
HandleHttpSessionRequest
(
endPoint
,
tcpClient
,
clientStream
,
clientStreamRead
er
,
clientStreamWriter
,
cancellationTokenSource
,
isHttps
?
httpsHostName
:
null
,
null
,
true
);
}
finally
{
...
...
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