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
d5182b73
Commit
d5182b73
authored
Jul 18, 2017
by
justcoding121
Committed by
justcoding121
Jul 18, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix server connection count; fix UpstreamEndPoint
parent
464e7c95
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
892 additions
and
911 deletions
+892
-911
TcpExtensions.cs
Titanium.Web.Proxy/Extensions/TcpExtensions.cs
+0
-28
TcpConnectionFactory.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+1
-1
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+871
-868
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+20
-14
No files found.
Titanium.Web.Proxy/Extensions/TcpExtensions.cs
View file @
d5182b73
...
@@ -5,34 +5,6 @@ namespace Titanium.Web.Proxy.Extensions
...
@@ -5,34 +5,6 @@ namespace Titanium.Web.Proxy.Extensions
{
{
internal
static
class
TcpExtensions
internal
static
class
TcpExtensions
{
{
/// <summary>
/// verifies if the underlying socket is connected before using a TcpClient connection
/// </summary>
/// <param name="client"></param>
/// <returns></returns>
internal
static
bool
IsConnected
(
this
Socket
client
)
{
// This is how you can determine whether a socket is still connected.
bool
blockingState
=
client
.
Blocking
;
try
{
var
tmp
=
new
byte
[
1
];
client
.
Blocking
=
false
;
client
.
Send
(
tmp
,
0
,
0
);
return
true
;
}
catch
(
SocketException
e
)
{
// 10035 == WSAEWOULDBLOCK
return
e
.
SocketErrorCode
==
SocketError
.
WouldBlock
;
}
finally
{
client
.
Blocking
=
blockingState
;
}
}
#if NET45
#if NET45
/// <summary>
/// <summary>
...
...
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
d5182b73
...
@@ -58,7 +58,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -58,7 +58,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
client
=
new
TcpClient
(
upStreamEndPoint
);
client
=
new
TcpClient
(
upStreamEndPoint
);
#else
#else
client
=
new
TcpClient
();
client
=
new
TcpClient
();
client
.
Client
.
Bind
(
server
.
U
pStreamEndPoint
);
client
.
Client
.
Bind
(
u
pStreamEndPoint
);
#endif
#endif
//If this proxy uses another external proxy then create a tunnel request for HTTP/HTTPS connections
//If this proxy uses another external proxy then create a tunnel request for HTTP/HTTPS connections
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
d5182b73
...
@@ -547,8 +547,8 @@ namespace Titanium.Web.Proxy
...
@@ -547,8 +547,8 @@ namespace Titanium.Web.Proxy
}
}
#if NET45
#if NET45
//clear any system proxy settings which is pointing to our own endpoint
//clear any system proxy settings which is pointing to our own endpoint
(causing a cycle)
//due to non gracious proxy shutdown before
//due to non gracious proxy shutdown before
or something else
if
(
systemProxySettingsManager
!=
null
)
if
(
systemProxySettingsManager
!=
null
)
{
{
var
proxyInfo
=
systemProxySettingsManager
.
GetProxyInfoFromRegistry
();
var
proxyInfo
=
systemProxySettingsManager
.
GetProxyInfoFromRegistry
();
...
@@ -557,7 +557,9 @@ namespace Titanium.Web.Proxy
...
@@ -557,7 +557,9 @@ namespace Titanium.Web.Proxy
var
protocolToRemove
=
ProxyProtocolType
.
None
;
var
protocolToRemove
=
ProxyProtocolType
.
None
;
foreach
(
var
proxy
in
proxyInfo
.
Proxies
.
Values
)
foreach
(
var
proxy
in
proxyInfo
.
Proxies
.
Values
)
{
{
if
(
proxy
.
HostName
==
"127.0.0.1"
&&
ProxyEndPoints
.
Any
(
x
=>
x
.
Port
==
proxy
.
Port
))
if
((
proxy
.
HostName
==
"127.0.0.1"
||
proxy
.
HostName
.
Equals
(
"localhost"
,
StringComparison
.
OrdinalIgnoreCase
))
&&
ProxyEndPoints
.
Any
(
x
=>
x
.
Port
==
proxy
.
Port
))
{
{
protocolToRemove
|=
proxy
.
ProtocolType
;
protocolToRemove
|=
proxy
.
ProtocolType
;
}
}
...
@@ -654,6 +656,7 @@ namespace Titanium.Web.Proxy
...
@@ -654,6 +656,7 @@ namespace Titanium.Web.Proxy
if
(
serverConnection
!=
null
)
if
(
serverConnection
!=
null
)
{
{
serverConnection
.
Dispose
();
serverConnection
.
Dispose
();
serverConnection
=
null
;
UpdateServerConnectionCount
(
false
);
UpdateServerConnectionCount
(
false
);
}
}
}
}
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
d5182b73
...
@@ -163,6 +163,8 @@ namespace Titanium.Web.Proxy
...
@@ -163,6 +163,8 @@ namespace Titanium.Web.Proxy
{
{
//create new connection
//create new connection
using
(
var
connection
=
await
GetServerConnection
(
connectArgs
,
true
))
using
(
var
connection
=
await
GetServerConnection
(
connectArgs
,
true
))
{
try
{
{
if
(
isClientHello
)
if
(
isClientHello
)
{
{
...
@@ -181,8 +183,12 @@ namespace Titanium.Web.Proxy
...
@@ -181,8 +183,12 @@ namespace Titanium.Web.Proxy
await
TcpHelper
.
SendRaw
(
clientStream
,
connection
.
Stream
,
BufferSize
,
await
TcpHelper
.
SendRaw
(
clientStream
,
connection
.
Stream
,
BufferSize
,
(
buffer
,
offset
,
count
)
=>
{
connectArgs
.
OnDataSent
(
buffer
,
offset
,
count
);
},
(
buffer
,
offset
,
count
)
=>
{
connectArgs
.
OnDataReceived
(
buffer
,
offset
,
count
);
});
(
buffer
,
offset
,
count
)
=>
{
connectArgs
.
OnDataSent
(
buffer
,
offset
,
count
);
},
(
buffer
,
offset
,
count
)
=>
{
connectArgs
.
OnDataReceived
(
buffer
,
offset
,
count
);
});
}
finally
{
UpdateServerConnectionCount
(
false
);
UpdateServerConnectionCount
(
false
);
}
}
}
return
;
return
;
}
}
...
@@ -361,8 +367,8 @@ namespace Titanium.Web.Proxy
...
@@ -361,8 +367,8 @@ namespace Titanium.Web.Proxy
&&
!
args
.
WebSession
.
UpStreamEndPoint
.
Equals
(
connection
.
UpStreamEndPoint
))))
&&
!
args
.
WebSession
.
UpStreamEndPoint
.
Equals
(
connection
.
UpStreamEndPoint
))))
{
{
connection
.
Dispose
();
connection
.
Dispose
();
UpdateServerConnectionCount
(
false
);
connection
=
null
;
connection
=
null
;
UpdateServerConnectionCount
(
false
);
}
}
if
(
connection
==
null
)
if
(
connection
==
null
)
...
...
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