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
b2c7c691
Commit
b2c7c691
authored
Jun 25, 2017
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prepare for .NET standard version
parent
a6a60cd0
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
1 deletion
+34
-1
SessionEventArgs.cs
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
+4
-0
Network.cs
Titanium.Web.Proxy/Helpers/Network.cs
+2
-0
CertificateManager.cs
Titanium.Web.Proxy/Network/CertificateManager.cs
+6
-0
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+18
-1
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+2
-0
ResponseHandler.cs
Titanium.Web.Proxy/ResponseHandler.cs
+2
-0
No files found.
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
View file @
b2c7c691
...
...
@@ -109,6 +109,7 @@ namespace Titanium.Web.Proxy.EventArguments
WebSession
.
ProcessId
=
new
Lazy
<
int
>(()
=>
{
#if NET45
var
remoteEndPoint
=
(
IPEndPoint
)
ProxyClient
.
TcpClient
.
Client
.
RemoteEndPoint
;
//If client is localhost get the process id
...
...
@@ -119,6 +120,9 @@ namespace Titanium.Web.Proxy.EventArguments
//can't access process Id of remote request from remote machine
return
-
1
;
#else
throw
new
PlatformNotSupportedException
();
#endif
});
}
...
...
Titanium.Web.Proxy/Helpers/Network.cs
View file @
b2c7c691
...
...
@@ -6,6 +6,7 @@ namespace Titanium.Web.Proxy.Helpers
{
internal
class
NetworkHelper
{
#if NET45
private
static
int
FindProcessIdFromLocalPort
(
int
port
,
IpVersion
ipVersion
)
{
var
tcpRow
=
TcpHelper
.
GetTcpRowByLocalPort
(
ipVersion
,
port
);
...
...
@@ -24,6 +25,7 @@ namespace Titanium.Web.Proxy.Helpers
return
FindProcessIdFromLocalPort
(
port
,
IpVersion
.
Ipv6
);
}
#endif
/// <summary>
/// Adapated from below link
...
...
Titanium.Web.Proxy/Network/CertificateManager.cs
View file @
b2c7c691
...
...
@@ -39,11 +39,13 @@ namespace Titanium.Web.Proxy.Network
get
{
return
engine
;
}
set
{
#if NET45
//For Mono only Bouncy Castle is supported
if
(
RunTime
.
IsRunningOnMono
)
{
value
=
CertificateEngine
.
BouncyCastle
;
}
#endif
if
(
value
!=
engine
)
{
...
...
@@ -220,6 +222,7 @@ namespace Titanium.Web.Proxy.Network
TrustRootCertificate
(
StoreLocation
.
LocalMachine
);
}
#if NET45
/// <summary>
/// Puts the certificate to the local machine's certificate store.
/// Needs elevated permission. Works only on Windows.
...
...
@@ -264,6 +267,7 @@ namespace Titanium.Web.Proxy.Network
return
true
;
}
#endif
/// <summary>
/// Removes the trusted certificates.
...
...
@@ -277,6 +281,7 @@ namespace Titanium.Web.Proxy.Network
RemoveTrustedRootCertificates
(
StoreLocation
.
LocalMachine
);
}
#if NET45
/// <summary>
/// Removes the trusted certificates from the local machine's certificate store.
/// Needs elevated permission. Works only on Windows.
...
...
@@ -316,6 +321,7 @@ namespace Titanium.Web.Proxy.Network
return
true
;
}
#endif
/// <summary>
/// Determines whether the root certificate is trusted.
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
b2c7c691
...
...
@@ -10,7 +10,9 @@ using System.Threading.Tasks;
using
Titanium.Web.Proxy.EventArguments
;
using
Titanium.Web.Proxy.Extensions
;
using
Titanium.Web.Proxy.Helpers
;
#if NET45
using
Titanium.Web.Proxy.Helpers.WinHttp
;
#endif
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Network
;
using
Titanium.Web.Proxy.Network.Tcp
;
...
...
@@ -38,7 +40,9 @@ namespace Titanium.Web.Proxy
/// </summary>
private
Action
<
Exception
>
exceptionFunc
;
#if NET45
private
WinHttpWebProxyFinder
systemProxyResolver
;
#endif
/// <summary>
/// Backing field for corresponding public property
...
...
@@ -60,10 +64,12 @@ namespace Titanium.Web.Proxy
/// </summary>
private
TcpConnectionFactory
tcpConnectionFactory
{
get
;
}
#if NET45
/// <summary>
/// Manage system proxy settings
/// </summary>
private
SystemProxyManager
systemProxySettingsManager
{
get
;
}
#endif
/// <summary>
/// Set firefox to use default system proxy
...
...
@@ -296,10 +302,12 @@ namespace Titanium.Web.Proxy
ProxyEndPoints
=
new
List
<
ProxyEndPoint
>();
tcpConnectionFactory
=
new
TcpConnectionFactory
();
#if NET45
if
(!
RunTime
.
IsRunningOnMono
)
{
systemProxySettingsManager
=
new
SystemProxyManager
();
}
#endif
CertificateManager
=
new
CertificateManager
(
ExceptionFunc
);
if
(
rootCertificateName
!=
null
)
...
...
@@ -352,6 +360,7 @@ namespace Titanium.Web.Proxy
}
}
#if NET45
/// <summary>
/// Set the given explicit end point as the default proxy server for current machine
/// </summary>
...
...
@@ -497,6 +506,7 @@ namespace Titanium.Web.Proxy
systemProxySettingsManager
.
DisableAllProxy
();
}
#endif
/// <summary>
/// Start this proxy server
...
...
@@ -508,6 +518,7 @@ namespace Titanium.Web.Proxy
throw
new
Exception
(
"Proxy is already running."
);
}
#if NET45
//clear any system proxy settings which is pointing to our own endpoint
//due to non gracious proxy shutdown before
if
(
systemProxySettingsManager
!=
null
)
...
...
@@ -543,6 +554,7 @@ namespace Titanium.Web.Proxy
GetCustomUpStreamHttpProxyFunc
=
GetSystemUpStreamProxy
;
GetCustomUpStreamHttpsProxyFunc
=
GetSystemUpStreamProxy
;
}
#endif
foreach
(
var
endPoint
in
ProxyEndPoints
)
{
...
...
@@ -551,11 +563,13 @@ namespace Titanium.Web.Proxy
CertificateManager
.
ClearIdleCertificates
(
CertificateCacheTimeOutMinutes
);
#if NET45
if
(!
RunTime
.
IsRunningOnMono
)
{
//clear orphaned windows auth states every 2 minutes
WinAuthEndPoint
.
ClearIdleStates
(
2
);
}
#endif
proxyRunning
=
true
;
}
...
...
@@ -571,6 +585,7 @@ namespace Titanium.Web.Proxy
throw
new
Exception
(
"Proxy is not running."
);
}
#if NET45
if
(!
RunTime
.
IsRunningOnMono
)
{
bool
setAsSystemProxy
=
ProxyEndPoints
.
OfType
<
ExplicitProxyEndPoint
>().
Any
(
x
=>
x
.
IsSystemHttpProxy
||
x
.
IsSystemHttpsProxy
);
...
...
@@ -580,6 +595,7 @@ namespace Titanium.Web.Proxy
systemProxySettingsManager
.
RestoreOriginalSettings
();
}
}
#endif
foreach
(
var
endPoint
in
ProxyEndPoints
)
{
...
...
@@ -639,6 +655,7 @@ namespace Titanium.Web.Proxy
}
}
#if NET45
/// <summary>
/// Gets the system up stream proxy.
/// </summary>
...
...
@@ -649,7 +666,7 @@ namespace Titanium.Web.Proxy
var
proxy
=
systemProxyResolver
.
GetProxy
(
sessionEventArgs
.
WebSession
.
Request
.
RequestUri
);
return
Task
.
FromResult
(
proxy
);
}
#endif
private
void
EnsureRootCertificate
()
{
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
b2c7c691
...
...
@@ -338,6 +338,7 @@ namespace Titanium.Web.Proxy
PrepareRequestHeaders
(
args
.
WebSession
.
Request
.
RequestHeaders
);
args
.
WebSession
.
Request
.
Host
=
args
.
WebSession
.
Request
.
RequestUri
.
Authority
;
#if NET45
//if win auth is enabled
//we need a cache of request body
//so that we can send it after authentication in WinAuthHandler.cs
...
...
@@ -345,6 +346,7 @@ namespace Titanium.Web.Proxy
{
await
args
.
GetRequestBody
();
}
#endif
//If user requested interception do it
if
(
BeforeRequest
!=
null
)
...
...
Titanium.Web.Proxy/ResponseHandler.cs
View file @
b2c7c691
...
...
@@ -33,6 +33,7 @@ namespace Titanium.Web.Proxy
var
response
=
args
.
WebSession
.
Response
;
#if NET45
//check for windows authentication
if
(
EnableWinAuth
&&
!
RunTime
.
IsRunningOnMono
...
...
@@ -45,6 +46,7 @@ namespace Titanium.Web.Proxy
return
true
;
}
}
#endif
args
.
ReRequest
=
false
;
...
...
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