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
78aa6639
Commit
78aa6639
authored
Oct 22, 2016
by
Hakan Arıcı
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* Files are untabified
* Removed redundant usings
parent
55312330
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
48 deletions
+45
-48
Tcp.cs
Titanium.Web.Proxy/Helpers/Tcp.cs
+10
-10
HttpWebClient.cs
Titanium.Web.Proxy/Http/HttpWebClient.cs
+0
-3
TcpConnectionFactory.cs
Titanium.Web.Proxy/Network/TcpConnectionFactory.cs
+2
-2
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+33
-33
No files found.
Titanium.Web.Proxy/Helpers/Tcp.cs
View file @
78aa6639
...
@@ -15,16 +15,16 @@ using Titanium.Web.Proxy.Tcp;
...
@@ -15,16 +15,16 @@ using Titanium.Web.Proxy.Tcp;
namespace
Titanium.Web.Proxy.Helpers
namespace
Titanium.Web.Proxy.Helpers
{
{
internal
enum
IpVersion
internal
enum
IpVersion
{
{
Ipv4
=
1
,
Ipv4
=
1
,
Ipv6
=
2
,
Ipv6
=
2
,
}
}
internal
partial
class
NativeMethods
internal
partial
class
NativeMethods
{
{
internal
const
int
AfInet
=
2
;
internal
const
int
AfInet
=
2
;
internal
const
int
AfInet6
=
23
;
internal
const
int
AfInet6
=
23
;
internal
enum
TcpTableType
internal
enum
TcpTableType
{
{
...
@@ -89,7 +89,7 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -89,7 +89,7 @@ namespace Titanium.Web.Proxy.Helpers
IntPtr
tcpTable
=
IntPtr
.
Zero
;
IntPtr
tcpTable
=
IntPtr
.
Zero
;
int
tcpTableLength
=
0
;
int
tcpTableLength
=
0
;
var
ipVersionValue
=
ipVersion
==
IpVersion
.
Ipv4
?
NativeMethods
.
AfInet
:
NativeMethods
.
AfInet6
;
var
ipVersionValue
=
ipVersion
==
IpVersion
.
Ipv4
?
NativeMethods
.
AfInet
:
NativeMethods
.
AfInet6
;
if
(
NativeMethods
.
GetExtendedTcpTable
(
tcpTable
,
ref
tcpTableLength
,
false
,
ipVersionValue
,
(
int
)
NativeMethods
.
TcpTableType
.
OwnerPidAll
,
0
)
!=
0
)
if
(
NativeMethods
.
GetExtendedTcpTable
(
tcpTable
,
ref
tcpTableLength
,
false
,
ipVersionValue
,
(
int
)
NativeMethods
.
TcpTableType
.
OwnerPidAll
,
0
)
!=
0
)
{
{
...
@@ -179,10 +179,10 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -179,10 +179,10 @@ namespace Titanium.Web.Proxy.Helpers
{
{
Stream
tunnelStream
=
tcpConnection
.
Stream
;
Stream
tunnelStream
=
tcpConnection
.
Stream
;
//Now async relay all server=>client & client=>server data
//Now async relay all server=>client & client=>server data
var
sendRelay
=
clientStream
.
CopyToAsync
(
sb
?.
ToString
()
??
string
.
Empty
,
tunnelStream
);
var
sendRelay
=
clientStream
.
CopyToAsync
(
sb
?.
ToString
()
??
string
.
Empty
,
tunnelStream
);
var
receiveRelay
=
tunnelStream
.
CopyToAsync
(
string
.
Empty
,
clientStream
);
var
receiveRelay
=
tunnelStream
.
CopyToAsync
(
string
.
Empty
,
clientStream
);
await
Task
.
WhenAll
(
sendRelay
,
receiveRelay
);
await
Task
.
WhenAll
(
sendRelay
,
receiveRelay
);
}
}
...
...
Titanium.Web.Proxy/Http/HttpWebClient.cs
View file @
78aa6639
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Titanium.Web.Proxy.Helpers
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Network
;
using
Titanium.Web.Proxy.Network
;
using
Titanium.Web.Proxy.Shared
;
using
Titanium.Web.Proxy.Shared
;
using
Titanium.Web.Proxy.Tcp
;
namespace
Titanium.Web.Proxy.Http
namespace
Titanium.Web.Proxy.Http
{
{
...
...
Titanium.Web.Proxy/Network/TcpConnectionFactory.cs
View file @
78aa6639
...
@@ -100,9 +100,9 @@ namespace Titanium.Web.Proxy.Network
...
@@ -100,9 +100,9 @@ namespace Titanium.Web.Proxy.Network
}
}
catch
catch
{
{
sslStream
?.
Dispose
();
sslStream
?.
Dispose
();
throw
;
throw
;
}
}
}
}
else
else
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
78aa6639
...
@@ -17,7 +17,7 @@ namespace Titanium.Web.Proxy
...
@@ -17,7 +17,7 @@ namespace Titanium.Web.Proxy
/// </summary>
/// </summary>
public
partial
class
ProxyServer
:
IDisposable
public
partial
class
ProxyServer
:
IDisposable
{
{
/// <summary>
/// <summary>
/// Is the root certificate used by this proxy is valid?
/// Is the root certificate used by this proxy is valid?
/// </summary>
/// </summary>
...
@@ -186,10 +186,10 @@ namespace Titanium.Web.Proxy
...
@@ -186,10 +186,10 @@ namespace Titanium.Web.Proxy
/// </summary>
/// </summary>
public
bool
ProxyRunning
=>
proxyRunning
;
public
bool
ProxyRunning
=>
proxyRunning
;
/// <summary>
/// <summary>
/// Gets or sets a value indicating whether requests will be chained to upstream gateway.
/// Gets or sets a value indicating whether requests will be chained to upstream gateway.
/// </summary>
/// </summary>
public
bool
ForwardToUpstreamGateway
{
get
;
set
;
}
public
bool
ForwardToUpstreamGateway
{
get
;
set
;
}
/// <summary>
/// <summary>
/// Constructor
/// Constructor
...
@@ -353,11 +353,11 @@ namespace Titanium.Web.Proxy
...
@@ -353,11 +353,11 @@ namespace Titanium.Web.Proxy
certificateCacheManager
.
TrustRootCertificate
();
certificateCacheManager
.
TrustRootCertificate
();
}
}
if
(
ForwardToUpstreamGateway
&&
GetCustomUpStreamHttpProxyFunc
==
null
&&
GetCustomUpStreamHttpsProxyFunc
==
null
)
if
(
ForwardToUpstreamGateway
&&
GetCustomUpStreamHttpProxyFunc
==
null
&&
GetCustomUpStreamHttpsProxyFunc
==
null
)
{
{
GetCustomUpStreamHttpProxyFunc
=
GetSystemUpStreamProxy
;
GetCustomUpStreamHttpProxyFunc
=
GetSystemUpStreamProxy
;
GetCustomUpStreamHttpsProxyFunc
=
GetSystemUpStreamProxy
;
GetCustomUpStreamHttpsProxyFunc
=
GetSystemUpStreamProxy
;
}
}
foreach
(
var
endPoint
in
ProxyEndPoints
)
foreach
(
var
endPoint
in
ProxyEndPoints
)
{
{
...
@@ -369,29 +369,29 @@ namespace Titanium.Web.Proxy
...
@@ -369,29 +369,29 @@ namespace Titanium.Web.Proxy
proxyRunning
=
true
;
proxyRunning
=
true
;
}
}
/// <summary>
/// <summary>
/// Gets the system up stream proxy.
/// Gets the system up stream proxy.
/// </summary>
/// </summary>
/// <param name="sessionEventArgs">The <see cref="SessionEventArgs"/> instance containing the event data.</param>
/// <param name="sessionEventArgs">The <see cref="SessionEventArgs"/> instance containing the event data.</param>
/// <returns><see cref="ExternalProxy"/> instance containing valid proxy configuration from PAC/WAPD scripts if any exists.</returns>
/// <returns><see cref="ExternalProxy"/> instance containing valid proxy configuration from PAC/WAPD scripts if any exists.</returns>
private
Task
<
ExternalProxy
>
GetSystemUpStreamProxy
(
SessionEventArgs
sessionEventArgs
)
private
Task
<
ExternalProxy
>
GetSystemUpStreamProxy
(
SessionEventArgs
sessionEventArgs
)
{
{
// Use built-in WebProxy class to handle PAC/WAPD scripts.
// Use built-in WebProxy class to handle PAC/WAPD scripts.
var
systemProxyResolver
=
new
WebProxy
();
var
systemProxyResolver
=
new
WebProxy
();
var
systemProxyUri
=
systemProxyResolver
.
GetProxy
(
sessionEventArgs
.
WebSession
.
Request
.
RequestUri
);
var
systemProxyUri
=
systemProxyResolver
.
GetProxy
(
sessionEventArgs
.
WebSession
.
Request
.
RequestUri
);
// TODO: Apply authorization
// TODO: Apply authorization
var
systemProxy
=
new
ExternalProxy
var
systemProxy
=
new
ExternalProxy
{
{
HostName
=
systemProxyUri
.
Host
,
HostName
=
systemProxyUri
.
Host
,
Port
=
systemProxyUri
.
Port
Port
=
systemProxyUri
.
Port
};
};
return
Task
.
FromResult
(
systemProxy
);
return
Task
.
FromResult
(
systemProxy
);
}
}
/// <summary>
/// <summary>
/// Stop this proxy server
/// Stop this proxy server
/// </summary>
/// </summary>
public
void
Stop
()
public
void
Stop
()
...
...
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