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
103754dc
Commit
103754dc
authored
Jun 29, 2017
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#150 Fix Transparent EndPoint; SNI tested Ok
parent
38a3bd84
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
22 deletions
+26
-22
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+11
-11
README.md
README.md
+6
-7
ProxyAuthorizationHandler.cs
Titanium.Web.Proxy/ProxyAuthorizationHandler.cs
+1
-1
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+4
-0
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+4
-3
No files found.
Examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
103754dc
...
...
@@ -81,17 +81,17 @@ namespace Titanium.Web.Proxy.Examples.Basic
proxyServer
.
Start
();
//Transparent endpoint is useful for reverse proxy
ing
(client is not aware of the existence of proxy)
//A transparent endpoint usually requires a network router port forwarding HTTP(S) packets
to this endpoint
//
Currently do not support Server Name Indication (It is not currently supported by SslStream class)
//
That means that the transparent endpoint will always provide the same Generic Certificate to all HTTPS requests
//
In this example only google.com will work for HTTPS requests
//
Other sites will receive a certificate mismatch warning on browser
var
transparentEndPoint
=
new
TransparentProxyEndPoint
(
IPAddress
.
Any
,
8001
,
true
)
{
GenericCertificateName
=
"google.com"
};
proxyServer
.
AddEndPoint
(
transparentEndPoint
);
//Transparent endpoint is useful for reverse proxy (client is not aware of the existence of proxy)
//A transparent endpoint usually requires a network router port forwarding HTTP(S) packets
or DNS
//
to send data to this endPoint
//
var transparentEndPoint = new TransparentProxyEndPoint(IPAddress.Any, 443, true)
//
{
//
//Generic Certificate hostname to use
// //When SNI is disabled by client
// GenericCertificateName = "google.com"
//};
//
proxyServer.AddEndPoint(transparentEndPoint);
//proxyServer.UpStreamHttpProxy = new ExternalProxy() { HostName = "localhost", Port = 8888 };
//proxyServer.UpStreamHttpsProxy = new ExternalProxy() { HostName = "localhost", Port = 8888 };
...
...
README.md
View file @
103754dc
...
...
@@ -73,17 +73,16 @@ var explicitEndPoint = new ExplicitProxyEndPoint(IPAddress.Any, 8000, true)
proxyServer
.
AddEndPoint
(
explicitEndPoint
);
proxyServer
.
Start
();
//Warning! Transparent endpoint is not tested end to end
//Transparent endpoint is useful for reverse proxy (client is not aware of the existence of proxy)
//A transparent endpoint usually requires a network router port forwarding HTTP(S) packets to this endpoint
//Currently do not support Server Name Indication (It is not currently supported by SslStream class)
//That means that the transparent endpoint will always provide the same Generic Certificate to all HTTPS requests
//In this example only google.com will work for HTTPS requests
//Other sites will receive a certificate mismatch warning on browser
//A transparent endpoint usually requires a network router port forwarding HTTP(S) packets or DNS
//to send data to this endPoint
var
transparentEndPoint
=
new
TransparentProxyEndPoint
(
IPAddress
.
Any
,
8001
,
true
)
{
GenericCertificateName
=
"google.com"
//Generic Certificate hostname to use
//when SNI is disabled by client
GenericCertificateName
=
"google.com"
};
proxyServer
.
AddEndPoint
(
transparentEndPoint
);
//proxyServer.UpStreamHttpProxy = new ExternalProxy() { HostName = "localhost", Port = 8888 };
...
...
Titanium.Web.Proxy/ProxyAuthorizationHandler.cs
View file @
103754dc
...
...
@@ -73,7 +73,7 @@ namespace Titanium.Web.Proxy
ResponseStatusDescription
=
description
};
response
.
ResponseHeaders
.
AddHeader
(
"Proxy-Authenticate"
,
"Basic realm=\"TitaniumProxy
\""
);
response
.
ResponseHeaders
.
AddHeader
(
"Proxy-Authenticate"
,
$"Basic realm=\"
{
ProxyRealm
}
\""
);
response
.
ResponseHeaders
.
AddHeader
(
"Proxy-Connection"
,
"close"
);
await
WriteResponse
(
response
,
clientStreamWriter
);
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
103754dc
...
...
@@ -270,6 +270,10 @@ namespace Titanium.Web.Proxy
/// </summary>
public
Func
<
string
,
string
,
Task
<
bool
>>
AuthenticateUserFunc
{
get
;
set
;
}
/// <summary>
/// Realm used during Proxy Basic Authentication
/// </summary>
public
string
ProxyRealm
{
get
;
set
;
}
=
"TitaniumProxy"
;
/// <summary>
/// A callback to provide authentication credentials for up stream proxy this proxy is using for HTTP requests
/// return the ExternalProxy object with valid credentials
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
103754dc
...
...
@@ -247,7 +247,7 @@ namespace Titanium.Web.Proxy
//Now create the request
disposed
=
await
HandleHttpSessionRequest
(
tcpClient
,
httpCmd
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
endPoint
.
EnableSsl
?
endPoint
.
GenericCertificateName
:
null
,
endPoint
,
null
);
endPoint
.
EnableSsl
?
endPoint
.
GenericCertificateName
:
null
,
endPoint
,
null
,
true
);
}
finally
{
...
...
@@ -271,10 +271,11 @@ namespace Titanium.Web.Proxy
/// <param name="httpsConnectHostname"></param>
/// <param name="endPoint"></param>
/// <param name="connectRequest"></param>
/// <param name="isTransparentEndPoint"></param>
/// <returns></returns>
private
async
Task
<
bool
>
HandleHttpSessionRequest
(
TcpClient
client
,
string
httpCmd
,
Stream
clientStream
,
CustomBinaryReader
clientStreamReader
,
StreamWriter
clientStreamWriter
,
string
httpsConnectHostname
,
ProxyEndPoint
endPoint
,
ConnectRequest
connectRequest
)
ProxyEndPoint
endPoint
,
ConnectRequest
connectRequest
,
bool
isTransparentEndPoint
=
false
)
{
bool
disposed
=
false
;
...
...
@@ -306,7 +307,7 @@ namespace Titanium.Web.Proxy
await
HeaderParser
.
ReadHeaders
(
clientStreamReader
,
args
.
WebSession
.
Request
.
RequestHeaders
);
var
httpRemoteUri
=
new
Uri
(
httpsConnectHostname
==
null
?
httpUrl
?
isTransparentEndPoint
?
string
.
Concat
(
"http://"
,
args
.
WebSession
.
Request
.
Host
,
httpUrl
)
:
httpUrl
:
string
.
Concat
(
"https://"
,
args
.
WebSession
.
Request
.
Host
??
httpsConnectHostname
,
httpUrl
));
args
.
WebSession
.
Request
.
RequestUri
=
httpRemoteUri
;
...
...
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