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
ae0239da
Commit
ae0239da
authored
Apr 29, 2017
by
Jehonathan Thomas
Committed by
GitHub
Apr 29, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #195 from justcoding121/develop
Merge Beta with develop
parents
142cabcb
66ac5679
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
8 deletions
+49
-8
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+5
-0
README.md
README.md
+4
-0
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+40
-8
No files found.
Examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
ae0239da
...
@@ -18,6 +18,11 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -18,6 +18,11 @@ namespace Titanium.Web.Proxy.Examples.Basic
{
{
proxyServer
=
new
ProxyServer
();
proxyServer
=
new
ProxyServer
();
proxyServer
.
TrustRootCertificate
=
true
;
proxyServer
.
TrustRootCertificate
=
true
;
//optionally set the Certificate Engine
//Under Mono only BouncyCastle will be supported
//proxyServer.CertificateEngine = Network.CertificateEngine.BouncyCastle;
requestBodyHistory
=
new
Dictionary
<
Guid
,
string
>();
requestBodyHistory
=
new
Dictionary
<
Guid
,
string
>();
}
}
...
...
README.md
View file @
ae0239da
...
@@ -43,6 +43,10 @@ var proxyServer = new ProxyServer();
...
@@ -43,6 +43,10 @@ var proxyServer = new ProxyServer();
//locally trust root certificate used by this proxy
//locally trust root certificate used by this proxy
proxyServer
.
TrustRootCertificate
=
true
;
proxyServer
.
TrustRootCertificate
=
true
;
//optionally set the Certificate Engine
//Under Mono only BouncyCastle will be supported
//proxyServer.CertificateEngine = Network.CertificateEngine.BouncyCastle;
proxyServer
.
BeforeRequest
+=
OnRequest
;
proxyServer
.
BeforeRequest
+=
OnRequest
;
proxyServer
.
BeforeResponse
+=
OnResponse
;
proxyServer
.
BeforeResponse
+=
OnResponse
;
proxyServer
.
ServerCertificateValidationCallback
+=
OnCertificateValidation
;
proxyServer
.
ServerCertificateValidationCallback
+=
OnCertificateValidation
;
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
ae0239da
...
@@ -205,7 +205,8 @@ namespace Titanium.Web.Proxy
...
@@ -205,7 +205,8 @@ namespace Titanium.Web.Proxy
/// <summary>
/// <summary>
/// List of supported Ssl versions
/// List of supported Ssl versions
/// </summary>
/// </summary>
public
SslProtocols
SupportedSslProtocols
{
get
;
set
;
}
=
SslProtocols
.
Tls
|
SslProtocols
.
Tls11
|
SslProtocols
.
Tls12
|
SslProtocols
.
Ssl3
;
public
SslProtocols
SupportedSslProtocols
{
get
;
set
;
}
=
SslProtocols
.
Tls
|
SslProtocols
.
Tls11
|
SslProtocols
.
Tls12
|
SslProtocols
.
Ssl3
;
/// <summary>
/// <summary>
/// Constructor
/// Constructor
...
@@ -242,7 +243,8 @@ namespace Titanium.Web.Proxy
...
@@ -242,7 +243,8 @@ namespace Titanium.Web.Proxy
/// <param name="endPoint"></param>
/// <param name="endPoint"></param>
public
void
AddEndPoint
(
ProxyEndPoint
endPoint
)
public
void
AddEndPoint
(
ProxyEndPoint
endPoint
)
{
{
if
(
ProxyEndPoints
.
Any
(
x
=>
x
.
IpAddress
.
Equals
(
endPoint
.
IpAddress
)
&&
endPoint
.
Port
!=
0
&&
x
.
Port
==
endPoint
.
Port
))
if
(
ProxyEndPoints
.
Any
(
x
=>
x
.
IpAddress
.
Equals
(
endPoint
.
IpAddress
)
&&
endPoint
.
Port
!=
0
&&
x
.
Port
==
endPoint
.
Port
))
{
{
throw
new
Exception
(
"Cannot add another endpoint to same port & ip address"
);
throw
new
Exception
(
"Cannot add another endpoint to same port & ip address"
);
}
}
...
@@ -281,6 +283,11 @@ namespace Titanium.Web.Proxy
...
@@ -281,6 +283,11 @@ namespace Titanium.Web.Proxy
/// <param name="endPoint"></param>
/// <param name="endPoint"></param>
public
void
SetAsSystemHttpProxy
(
ExplicitProxyEndPoint
endPoint
)
public
void
SetAsSystemHttpProxy
(
ExplicitProxyEndPoint
endPoint
)
{
{
if
(
RunTime
.
IsRunningOnMono
())
{
throw
new
Exception
(
"Mono Runtime do not support system proxy settings."
);
}
ValidateEndPointAsSystemProxy
(
endPoint
);
ValidateEndPointAsSystemProxy
(
endPoint
);
//clear any settings previously added
//clear any settings previously added
...
@@ -304,6 +311,11 @@ namespace Titanium.Web.Proxy
...
@@ -304,6 +311,11 @@ namespace Titanium.Web.Proxy
/// <param name="endPoint"></param>
/// <param name="endPoint"></param>
public
void
SetAsSystemHttpsProxy
(
ExplicitProxyEndPoint
endPoint
)
public
void
SetAsSystemHttpsProxy
(
ExplicitProxyEndPoint
endPoint
)
{
{
if
(
RunTime
.
IsRunningOnMono
())
{
throw
new
Exception
(
"Mono Runtime do not support system proxy settings."
);
}
ValidateEndPointAsSystemProxy
(
endPoint
);
ValidateEndPointAsSystemProxy
(
endPoint
);
if
(!
endPoint
.
EnableSsl
)
if
(!
endPoint
.
EnableSsl
)
...
@@ -312,14 +324,17 @@ namespace Titanium.Web.Proxy
...
@@ -312,14 +324,17 @@ namespace Titanium.Web.Proxy
}
}
//clear any settings previously added
//clear any settings previously added
ProxyEndPoints
.
OfType
<
ExplicitProxyEndPoint
>().
ToList
().
ForEach
(
x
=>
x
.
IsSystemHttpsProxy
=
false
);
ProxyEndPoints
.
OfType
<
ExplicitProxyEndPoint
>()
.
ToList
()
.
ForEach
(
x
=>
x
.
IsSystemHttpsProxy
=
false
);
//If certificate was trusted by the machine
//If certificate was trusted by the machine
if
(
certValidated
)
if
(
certValidated
)
{
{
systemProxySettingsManager
.
SetHttpsProxy
(
systemProxySettingsManager
.
SetHttpsProxy
(
Equals
(
endPoint
.
IpAddress
,
IPAddress
.
Any
)
|
Equals
(
endPoint
.
IpAddress
,
IPAddress
.
Loopback
)
?
"127.0.0.1"
:
endPoint
.
IpAddress
.
ToString
(),
Equals
(
endPoint
.
IpAddress
,
IPAddress
.
Any
)
|
Equals
(
endPoint
.
IpAddress
,
IPAddress
.
Loopback
)
?
"127.0.0.1"
:
endPoint
.
IpAddress
.
ToString
(),
endPoint
.
Port
);
endPoint
.
Port
);
}
}
...
@@ -329,7 +344,8 @@ namespace Titanium.Web.Proxy
...
@@ -329,7 +344,8 @@ namespace Titanium.Web.Proxy
#if !DEBUG
#if !DEBUG
firefoxProxySettingsManager
.
AddFirefox
();
firefoxProxySettingsManager
.
AddFirefox
();
#endif
#endif
Console
.
WriteLine
(
"Set endpoint at Ip {0} and port: {1} as System HTTPS Proxy"
,
endPoint
.
IpAddress
,
endPoint
.
Port
);
Console
.
WriteLine
(
"Set endpoint at Ip {0} and port: {1} as System HTTPS Proxy"
,
endPoint
.
IpAddress
,
endPoint
.
Port
);
}
}
/// <summary>
/// <summary>
...
@@ -337,6 +353,11 @@ namespace Titanium.Web.Proxy
...
@@ -337,6 +353,11 @@ namespace Titanium.Web.Proxy
/// </summary>
/// </summary>
public
void
DisableSystemHttpProxy
()
public
void
DisableSystemHttpProxy
()
{
{
if
(
RunTime
.
IsRunningOnMono
())
{
throw
new
Exception
(
"Mono Runtime do not support system proxy settings."
);
}
systemProxySettingsManager
.
RemoveHttpProxy
();
systemProxySettingsManager
.
RemoveHttpProxy
();
}
}
...
@@ -345,6 +366,11 @@ namespace Titanium.Web.Proxy
...
@@ -345,6 +366,11 @@ namespace Titanium.Web.Proxy
/// </summary>
/// </summary>
public
void
DisableSystemHttpsProxy
()
public
void
DisableSystemHttpsProxy
()
{
{
if
(
RunTime
.
IsRunningOnMono
())
{
throw
new
Exception
(
"Mono Runtime do not support system proxy settings."
);
}
systemProxySettingsManager
.
RemoveHttpsProxy
();
systemProxySettingsManager
.
RemoveHttpsProxy
();
}
}
...
@@ -353,6 +379,11 @@ namespace Titanium.Web.Proxy
...
@@ -353,6 +379,11 @@ namespace Titanium.Web.Proxy
/// </summary>
/// </summary>
public
void
DisableAllSystemProxies
()
public
void
DisableAllSystemProxies
()
{
{
if
(
RunTime
.
IsRunningOnMono
())
{
throw
new
Exception
(
"Mono Runtime do not support system proxy settings."
);
}
systemProxySettingsManager
.
DisableAllProxy
();
systemProxySettingsManager
.
DisableAllProxy
();
}
}
...
@@ -383,7 +414,8 @@ namespace Titanium.Web.Proxy
...
@@ -383,7 +414,8 @@ namespace Titanium.Web.Proxy
.
TrustRootCertificate
(
StoreLocation
.
LocalMachine
,
exceptionFunc
);
.
TrustRootCertificate
(
StoreLocation
.
LocalMachine
,
exceptionFunc
);
}
}
if
(
ForwardToUpstreamGateway
&&
GetCustomUpStreamHttpProxyFunc
==
null
&&
GetCustomUpStreamHttpsProxyFunc
==
null
)
if
(
ForwardToUpstreamGateway
&&
GetCustomUpStreamHttpProxyFunc
==
null
&&
GetCustomUpStreamHttpsProxyFunc
==
null
)
{
{
GetCustomUpStreamHttpProxyFunc
=
GetSystemUpStreamProxy
;
GetCustomUpStreamHttpProxyFunc
=
GetSystemUpStreamProxy
;
GetCustomUpStreamHttpsProxyFunc
=
GetSystemUpStreamProxy
;
GetCustomUpStreamHttpsProxyFunc
=
GetSystemUpStreamProxy
;
...
...
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