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
aa2208c9
Commit
aa2208c9
authored
Dec 04, 2016
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor UpStreamEndPoint
parent
6843bbbf
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
12 deletions
+14
-12
Tcp.cs
Titanium.Web.Proxy/Helpers/Tcp.cs
+2
-2
TcpConnectionFactory.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+6
-5
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+3
-2
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+3
-3
No files found.
Titanium.Web.Proxy/Helpers/Tcp.cs
View file @
aa2208c9
...
@@ -145,7 +145,7 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -145,7 +145,7 @@ namespace Titanium.Web.Proxy.Helpers
string
remoteHostName
,
int
remotePort
,
string
httpCmd
,
Version
httpVersion
,
Dictionary
<
string
,
HttpHeader
>
requestHeaders
,
string
remoteHostName
,
int
remotePort
,
string
httpCmd
,
Version
httpVersion
,
Dictionary
<
string
,
HttpHeader
>
requestHeaders
,
bool
isHttps
,
SslProtocols
supportedProtocols
,
bool
isHttps
,
SslProtocols
supportedProtocols
,
RemoteCertificateValidationCallback
remoteCertificateValidationCallback
,
LocalCertificateSelectionCallback
localCertificateSelectionCallback
,
RemoteCertificateValidationCallback
remoteCertificateValidationCallback
,
LocalCertificateSelectionCallback
localCertificateSelectionCallback
,
Stream
clientStream
,
TcpConnectionFactory
tcpConnectionFactory
)
Stream
clientStream
,
TcpConnectionFactory
tcpConnectionFactory
,
IPEndPoint
upStreamEndPoint
)
{
{
//prepare the prefix content
//prepare the prefix content
StringBuilder
sb
=
null
;
StringBuilder
sb
=
null
;
...
@@ -175,7 +175,7 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -175,7 +175,7 @@ namespace Titanium.Web.Proxy.Helpers
remoteHostName
,
remotePort
,
remoteHostName
,
remotePort
,
httpVersion
,
isHttps
,
httpVersion
,
isHttps
,
supportedProtocols
,
remoteCertificateValidationCallback
,
localCertificateSelectionCallback
,
supportedProtocols
,
remoteCertificateValidationCallback
,
localCertificateSelectionCallback
,
null
,
null
,
clientStream
,
new
IPEndPoint
(
IPAddress
.
Any
,
0
)
);
null
,
null
,
clientStream
,
upStreamEndPoint
);
try
try
{
{
...
...
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
aa2208c9
...
@@ -36,13 +36,14 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -36,13 +36,14 @@ namespace Titanium.Web.Proxy.Network.Tcp
/// <param name="externalHttpProxy"></param>
/// <param name="externalHttpProxy"></param>
/// <param name="externalHttpsProxy"></param>
/// <param name="externalHttpsProxy"></param>
/// <param name="clientStream"></param>
/// <param name="clientStream"></param>
/// <param name="upStreamEndPoint"></param>
/// <returns></returns>
/// <returns></returns>
internal
async
Task
<
TcpConnection
>
CreateClient
(
int
bufferSize
,
int
connectionTimeOutSeconds
,
internal
async
Task
<
TcpConnection
>
CreateClient
(
int
bufferSize
,
int
connectionTimeOutSeconds
,
string
remoteHostName
,
int
remotePort
,
Version
httpVersion
,
string
remoteHostName
,
int
remotePort
,
Version
httpVersion
,
bool
isHttps
,
SslProtocols
supportedSslProtocols
,
bool
isHttps
,
SslProtocols
supportedSslProtocols
,
RemoteCertificateValidationCallback
remoteCertificateValidationCallback
,
LocalCertificateSelectionCallback
localCertificateSelectionCallback
,
RemoteCertificateValidationCallback
remoteCertificateValidationCallback
,
LocalCertificateSelectionCallback
localCertificateSelectionCallback
,
ExternalProxy
externalHttpProxy
,
ExternalProxy
externalHttpsProxy
,
ExternalProxy
externalHttpProxy
,
ExternalProxy
externalHttpsProxy
,
Stream
clientStream
,
EndPoint
local
EndPoint
)
Stream
clientStream
,
EndPoint
upStream
EndPoint
)
{
{
TcpClient
client
;
TcpClient
client
;
Stream
stream
;
Stream
stream
;
...
@@ -55,7 +56,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -55,7 +56,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
if
(
externalHttpsProxy
!=
null
&&
externalHttpsProxy
.
HostName
!=
remoteHostName
)
if
(
externalHttpsProxy
!=
null
&&
externalHttpsProxy
.
HostName
!=
remoteHostName
)
{
{
client
=
new
TcpClient
();
client
=
new
TcpClient
();
client
.
Client
.
Bind
(
local
EndPoint
);
client
.
Client
.
Bind
(
upStream
EndPoint
);
client
.
Client
.
Connect
(
externalHttpsProxy
.
HostName
,
externalHttpsProxy
.
Port
);
client
.
Client
.
Connect
(
externalHttpsProxy
.
HostName
,
externalHttpsProxy
.
Port
);
stream
=
client
.
GetStream
();
stream
=
client
.
GetStream
();
...
@@ -91,7 +92,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -91,7 +92,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
else
else
{
{
client
=
new
TcpClient
();
client
=
new
TcpClient
();
client
.
Client
.
Bind
(
local
EndPoint
);
client
.
Client
.
Bind
(
upStream
EndPoint
);
client
.
Client
.
Connect
(
remoteHostName
,
remotePort
);
client
.
Client
.
Connect
(
remoteHostName
,
remotePort
);
stream
=
client
.
GetStream
();
stream
=
client
.
GetStream
();
}
}
...
@@ -117,14 +118,14 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -117,14 +118,14 @@ namespace Titanium.Web.Proxy.Network.Tcp
if
(
externalHttpProxy
!=
null
&&
externalHttpProxy
.
HostName
!=
remoteHostName
)
if
(
externalHttpProxy
!=
null
&&
externalHttpProxy
.
HostName
!=
remoteHostName
)
{
{
client
=
new
TcpClient
();
client
=
new
TcpClient
();
client
.
Client
.
Bind
(
local
EndPoint
);
client
.
Client
.
Bind
(
upStream
EndPoint
);
client
.
Client
.
Connect
(
externalHttpProxy
.
HostName
,
externalHttpProxy
.
Port
);
client
.
Client
.
Connect
(
externalHttpProxy
.
HostName
,
externalHttpProxy
.
Port
);
stream
=
client
.
GetStream
();
stream
=
client
.
GetStream
();
}
}
else
else
{
{
client
=
new
TcpClient
();
client
=
new
TcpClient
();
client
.
Client
.
Bind
(
local
EndPoint
);
client
.
Client
.
Bind
(
upStream
EndPoint
);
client
.
Client
.
Connect
(
remoteHostName
,
remotePort
);
client
.
Client
.
Connect
(
remoteHostName
,
remotePort
);
stream
=
client
.
GetStream
();
stream
=
client
.
GetStream
();
}
}
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
aa2208c9
...
@@ -118,9 +118,10 @@ namespace Titanium.Web.Proxy
...
@@ -118,9 +118,10 @@ namespace Titanium.Web.Proxy
public
ExternalProxy
UpStreamHttpsProxy
{
get
;
set
;
}
public
ExternalProxy
UpStreamHttpsProxy
{
get
;
set
;
}
/// <summary>
/// <summary>
/// Local adapter endpoint
/// Local adapter/NIC endpoint (where proxy makes request via)
/// default via any IP addresses of this machine
/// </summary>
/// </summary>
public
EndPoint
Local
EndPoint
{
get
;
set
;
}
=
new
IPEndPoint
(
IPAddress
.
Any
,
0
);
public
IPEndPoint
UpStream
EndPoint
{
get
;
set
;
}
=
new
IPEndPoint
(
IPAddress
.
Any
,
0
);
/// <summary>
/// <summary>
/// Verifies the remote Secure Sockets Layer (SSL) certificate used for authentication
/// Verifies the remote Secure Sockets Layer (SSL) certificate used for authentication
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
aa2208c9
...
@@ -152,7 +152,7 @@ namespace Titanium.Web.Proxy
...
@@ -152,7 +152,7 @@ namespace Titanium.Web.Proxy
false
,
SupportedSslProtocols
,
false
,
SupportedSslProtocols
,
new
RemoteCertificateValidationCallback
(
ValidateServerCertificate
),
new
RemoteCertificateValidationCallback
(
ValidateServerCertificate
),
new
LocalCertificateSelectionCallback
(
SelectClientCertificate
),
new
LocalCertificateSelectionCallback
(
SelectClientCertificate
),
clientStream
,
tcpConnectionFactory
);
clientStream
,
tcpConnectionFactory
,
UpStreamEndPoint
);
Dispose
(
clientStream
,
clientStreamReader
,
clientStreamWriter
,
null
);
Dispose
(
clientStream
,
clientStreamReader
,
clientStreamWriter
,
null
);
return
;
return
;
...
@@ -251,7 +251,7 @@ namespace Titanium.Web.Proxy
...
@@ -251,7 +251,7 @@ namespace Titanium.Web.Proxy
args
.
IsHttps
,
SupportedSslProtocols
,
args
.
IsHttps
,
SupportedSslProtocols
,
new
RemoteCertificateValidationCallback
(
ValidateServerCertificate
),
new
RemoteCertificateValidationCallback
(
ValidateServerCertificate
),
new
LocalCertificateSelectionCallback
(
SelectClientCertificate
),
new
LocalCertificateSelectionCallback
(
SelectClientCertificate
),
customUpStreamHttpProxy
??
UpStreamHttpProxy
,
customUpStreamHttpsProxy
??
UpStreamHttpsProxy
,
args
.
ProxyClient
.
ClientStream
,
Local
EndPoint
);
customUpStreamHttpProxy
??
UpStreamHttpProxy
,
customUpStreamHttpsProxy
??
UpStreamHttpsProxy
,
args
.
ProxyClient
.
ClientStream
,
UpStream
EndPoint
);
}
}
args
.
WebSession
.
Request
.
RequestLocked
=
true
;
args
.
WebSession
.
Request
.
RequestLocked
=
true
;
...
@@ -487,7 +487,7 @@ namespace Titanium.Web.Proxy
...
@@ -487,7 +487,7 @@ namespace Titanium.Web.Proxy
httpCmd
,
httpVersion
,
args
.
WebSession
.
Request
.
RequestHeaders
,
args
.
IsHttps
,
httpCmd
,
httpVersion
,
args
.
WebSession
.
Request
.
RequestHeaders
,
args
.
IsHttps
,
SupportedSslProtocols
,
new
RemoteCertificateValidationCallback
(
ValidateServerCertificate
),
SupportedSslProtocols
,
new
RemoteCertificateValidationCallback
(
ValidateServerCertificate
),
new
LocalCertificateSelectionCallback
(
SelectClientCertificate
),
new
LocalCertificateSelectionCallback
(
SelectClientCertificate
),
clientStream
,
tcpConnectionFactory
);
clientStream
,
tcpConnectionFactory
,
UpStreamEndPoint
);
Dispose
(
clientStream
,
clientStreamReader
,
clientStreamWriter
,
args
);
Dispose
(
clientStream
,
clientStreamReader
,
clientStreamWriter
,
args
);
break
;
break
;
...
...
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