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
5476c5e9
Commit
5476c5e9
authored
Feb 28, 2018
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small refactor in HandleClient
parent
61a41535
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
21 deletions
+21
-21
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+21
-21
No files found.
Titanium.Web.Proxy/RequestHandler.cs
View file @
5476c5e9
...
...
@@ -45,8 +45,6 @@ namespace Titanium.Web.Proxy
var
clientStreamReader
=
new
CustomBinaryReader
(
clientStream
,
BufferSize
);
var
clientStreamWriter
=
new
HttpResponseWriter
(
clientStream
,
BufferSize
);
Uri
httpRemoteUri
;
try
{
//read the first line HTTP command
...
...
@@ -58,26 +56,29 @@ namespace Titanium.Web.Proxy
Request
.
ParseRequestLine
(
httpCmd
,
out
string
httpMethod
,
out
string
httpUrl
,
out
var
version
);
httpRemoteUri
=
httpMethod
==
"CONNECT"
?
new
Uri
(
"http://"
+
httpUrl
)
:
new
Uri
(
httpUrl
);
string
connectHostname
=
null
;
ConnectRequest
connectRequest
=
null
;
//Client wants to create a secure tcp tunnel (probably its a HTTPS or Websocket request)
if
(
httpMethod
==
"CONNECT"
)
{
var
httpRemoteUri
=
new
Uri
(
"http://"
+
httpUrl
);
connectHostname
=
httpRemoteUri
.
Host
;
//filter out excluded host names
bool
excluded
=
false
;
if
(
endPoint
.
ExcludedHttpsHostNameRegex
!=
null
)
{
excluded
=
endPoint
.
ExcludedHttpsHostNameRegexList
.
Any
(
x
=>
x
.
IsMatch
(
httpRemoteUri
.
Host
));
excluded
=
endPoint
.
ExcludedHttpsHostNameRegexList
.
Any
(
x
=>
x
.
IsMatch
(
connectHostname
));
}
if
(
endPoint
.
IncludedHttpsHostNameRegex
!=
null
)
{
excluded
=
!
endPoint
.
IncludedHttpsHostNameRegexList
.
Any
(
x
=>
x
.
IsMatch
(
httpRemoteUri
.
Host
));
excluded
=
!
endPoint
.
IncludedHttpsHostNameRegexList
.
Any
(
x
=>
x
.
IsMatch
(
connectHostname
));
}
ConnectRequest
connectRequest
=
null
;
//Client wants to create a secure tcp tunnel (probably its a HTTPS or Websocket request)
if
(
httpMethod
==
"CONNECT"
)
{
connectRequest
=
new
ConnectRequest
{
RequestUri
=
httpRemoteUri
,
...
...
@@ -125,8 +126,7 @@ namespace Titanium.Web.Proxy
if
(!
excluded
&&
isClientHello
)
{
httpRemoteUri
=
new
Uri
(
"https://"
+
httpUrl
);
connectRequest
.
RequestUri
=
httpRemoteUri
;
connectRequest
.
RequestUri
=
new
Uri
(
"https://"
+
httpUrl
);
SslStream
sslStream
=
null
;
...
...
@@ -134,7 +134,7 @@ namespace Titanium.Web.Proxy
{
sslStream
=
new
SslStream
(
clientStream
);
string
certName
=
HttpHelper
.
GetWildCardDomainName
(
httpRemoteUri
.
Host
);
string
certName
=
HttpHelper
.
GetWildCardDomainName
(
connectHostname
);
var
certificate
=
endPoint
.
GenericCertificate
??
CertificateManager
.
CreateCertificate
(
certName
,
false
);
...
...
@@ -208,7 +208,7 @@ namespace Titanium.Web.Proxy
//Now create the request
disposed
=
await
HandleHttpSessionRequest
(
tcpClient
,
httpCmd
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
httpRemoteUri
.
Scheme
==
UriSchemeHttps
?
httpRemoteUri
.
Host
:
null
,
endPoint
,
connectRequest
);
connectHostname
,
endPoint
,
connectRequest
);
}
catch
(
IOException
e
)
{
...
...
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