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
c63e280b
Commit
c63e280b
authored
Apr 15, 2018
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect server http/2 support (fallback proxy to 1.x when server does not supprot http/2)
parent
0fe5a400
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
9 deletions
+27
-9
ExplicitClientHandler.cs
Titanium.Web.Proxy/ExplicitClientHandler.cs
+19
-6
TcpConnection.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnection.cs
+2
-0
TcpConnectionFactory.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+6
-3
No files found.
Titanium.Web.Proxy/ExplicitClientHandler.cs
View file @
c63e280b
...
@@ -127,6 +127,19 @@ namespace Titanium.Web.Proxy
...
@@ -127,6 +127,19 @@ namespace Titanium.Web.Proxy
{
{
connectRequest
.
RequestUri
=
new
Uri
(
"https://"
+
httpUrl
);
connectRequest
.
RequestUri
=
new
Uri
(
"https://"
+
httpUrl
);
bool
http2Supproted
=
false
;
var
alpn
=
clientHelloInfo
.
GetAlpn
();
if
(
alpn
!=
null
&&
alpn
.
Contains
(
SslApplicationProtocol
.
Http2
))
{
// test server HTTP/2 support
// todo: this is a hack, because Titanium does not support HTTP protocol changing currently
using
(
var
connection
=
await
GetServerConnection
(
connectArgs
,
true
,
cancellationToken
))
{
http2Supproted
=
connection
.
IsHttp2Supported
;
}
}
SslStream
sslStream
=
null
;
SslStream
sslStream
=
null
;
try
try
...
@@ -140,15 +153,15 @@ namespace Titanium.Web.Proxy
...
@@ -140,15 +153,15 @@ namespace Titanium.Web.Proxy
//Successfully managed to authenticate the client using the fake certificate
//Successfully managed to authenticate the client using the fake certificate
var
options
=
new
SslServerAuthenticationOptions
();
var
options
=
new
SslServerAuthenticationOptions
();
options
.
ApplicationProtocols
=
clientHelloInfo
.
GetAlpn
();
if
(
http2Supproted
)
if
(
options
.
ApplicationProtocols
==
null
||
options
.
ApplicationProtocols
.
Count
==
0
)
{
{
options
.
ApplicationProtocols
=
SslExtensions
.
Http11ProtocolAsList
;
options
.
ApplicationProtocols
=
clientHelloInfo
.
GetAlpn
();
if
(
options
.
ApplicationProtocols
==
null
||
options
.
ApplicationProtocols
.
Count
==
0
)
{
options
.
ApplicationProtocols
=
SslExtensions
.
Http11ProtocolAsList
;
}
}
}
// client connection is always HTTP 1.x, todo
//options.ApplicationProtocols = SslExtensions.Http11ProtocolAsList;
options
.
ServerCertificate
=
certificate
;
options
.
ServerCertificate
=
certificate
;
options
.
ClientCertificateRequired
=
false
;
options
.
ClientCertificateRequired
=
false
;
options
.
EnabledSslProtocols
=
SupportedSslProtocols
;
options
.
EnabledSslProtocols
=
SupportedSslProtocols
;
...
...
Titanium.Web.Proxy/Network/Tcp/TcpConnection.cs
View file @
c63e280b
...
@@ -30,6 +30,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -30,6 +30,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
internal
bool
IsHttps
{
get
;
set
;
}
internal
bool
IsHttps
{
get
;
set
;
}
internal
bool
IsHttp2Supported
{
get
;
set
;
}
internal
bool
UseUpstreamProxy
{
get
;
set
;
}
internal
bool
UseUpstreamProxy
{
get
;
set
;
}
/// <summary>
/// <summary>
...
...
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
c63e280b
...
@@ -55,6 +55,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -55,6 +55,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
TcpClient
client
=
null
;
TcpClient
client
=
null
;
CustomBufferedStream
stream
=
null
;
CustomBufferedStream
stream
=
null
;
bool
http2Supported
=
false
;
try
try
{
{
client
=
new
TcpClient
(
upStreamEndPoint
);
client
=
new
TcpClient
(
upStreamEndPoint
);
...
@@ -119,14 +121,14 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -119,14 +121,14 @@ namespace Titanium.Web.Proxy.Network.Tcp
options
.
ApplicationProtocols
=
SslExtensions
.
Http11ProtocolAsList
;
options
.
ApplicationProtocols
=
SslExtensions
.
Http11ProtocolAsList
;
}
}
// server connection is always HTTP 1.x, todo
//options.ApplicationProtocols = SslExtensions.Http11ProtocolAsList;
options
.
TargetHost
=
remoteHostName
;
options
.
TargetHost
=
remoteHostName
;
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
,
cancellationToken
);
await
sslStream
.
AuthenticateAsClientAsync
(
options
,
cancellationToken
);
#if NETCOREAPP2_1
http2Supported
=
sslStream
.
NegotiatedApplicationProtocol
==
SslApplicationProtocol
.
Http2
;
#endif
}
}
client
.
ReceiveTimeout
=
proxyServer
.
ConnectionTimeOutSeconds
*
1000
;
client
.
ReceiveTimeout
=
proxyServer
.
ConnectionTimeOutSeconds
*
1000
;
...
@@ -146,6 +148,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -146,6 +148,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
HostName
=
remoteHostName
,
HostName
=
remoteHostName
,
Port
=
remotePort
,
Port
=
remotePort
,
IsHttps
=
decryptSsl
,
IsHttps
=
decryptSsl
,
IsHttp2Supported
=
http2Supported
,
UseUpstreamProxy
=
useUpstreamProxy
,
UseUpstreamProxy
=
useUpstreamProxy
,
TcpClient
=
client
,
TcpClient
=
client
,
StreamReader
=
new
CustomBinaryReader
(
stream
,
proxyServer
.
BufferSize
),
StreamReader
=
new
CustomBinaryReader
(
stream
,
proxyServer
.
BufferSize
),
...
...
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