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
af8558f3
Commit
af8558f3
authored
Nov 17, 2019
by
ByronP
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
external proxy use interface
parent
ea42073c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
18 additions
and
18 deletions
+18
-18
SessionEventArgsBase.cs
...Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs
+1
-1
WinHttpWebProxyFinder.cs
...tanium.Web.Proxy/Helpers/WinHttp/WinHttpWebProxyFinder.cs
+1
-1
ExternalProxy.cs
src/Titanium.Web.Proxy/Models/ExternalProxy.cs
+1
-1
TcpConnectionFactory.cs
src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+6
-6
TcpServerConnection.cs
src/Titanium.Web.Proxy/Network/Tcp/TcpServerConnection.cs
+2
-2
ProxyServer.cs
src/Titanium.Web.Proxy/ProxyServer.cs
+6
-6
NestedProxyTests.cs
...s/Titanium.Web.Proxy.IntegrationTests/NestedProxyTests.cs
+1
-1
No files found.
src/Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs
View file @
af8558f3
...
...
@@ -106,7 +106,7 @@ namespace Titanium.Web.Proxy.EventArguments
/// <summary>
/// Are we using a custom upstream HTTP(S) proxy?
/// </summary>
public
I
ExternalProxy
?
CustomUpStreamProxyUsed
{
get
;
internal
set
;
}
public
ExternalProxy
?
CustomUpStreamProxyUsed
{
get
;
internal
set
;
}
/// <summary>
/// Local endpoint via which we make the request.
...
...
src/Titanium.Web.Proxy/Helpers/WinHttp/WinHttpWebProxyFinder.cs
View file @
af8558f3
...
...
@@ -95,7 +95,7 @@ namespace Titanium.Web.Proxy.Helpers.WinHttp
return
true
;
}
public
I
ExternalProxy
?
GetProxy
(
Uri
destination
)
public
ExternalProxy
?
GetProxy
(
Uri
destination
)
{
if
(
GetAutoProxies
(
destination
,
out
var
proxies
))
{
...
...
src/Titanium.Web.Proxy/Models/ExternalProxy.cs
View file @
af8558f3
...
...
@@ -6,7 +6,7 @@ namespace Titanium.Web.Proxy.Models
/// <summary>
/// An upstream proxy this proxy uses if any.
/// </summary>
public
class
ExternalProxy
:
IExternalProxy
public
class
ExternalProxy
{
private
static
readonly
Lazy
<
NetworkCredential
>
defaultCredentials
=
new
Lazy
<
NetworkCredential
>(()
=>
CredentialCache
.
DefaultNetworkCredentials
);
...
...
src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
af8558f3
...
...
@@ -49,7 +49,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
internal
string
GetConnectionCacheKey
(
string
remoteHostName
,
int
remotePort
,
bool
isHttps
,
List
<
SslApplicationProtocol
>?
applicationProtocols
,
IPEndPoint
?
upStreamEndPoint
,
I
ExternalProxy
?
externalProxy
)
IPEndPoint
?
upStreamEndPoint
,
ExternalProxy
?
externalProxy
)
{
// http version is ignored since its an application level decision b/w HTTP 1.0/1.1
// also when doing connect request MS Edge browser sends http 1.0 but uses 1.1 after server sends 1.1 its response.
...
...
@@ -115,7 +115,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
applicationProtocols
=
new
List
<
SslApplicationProtocol
>
{
applicationProtocol
};
}
I
ExternalProxy
?
customUpStreamProxy
=
null
;
ExternalProxy
?
customUpStreamProxy
=
null
;
bool
isHttps
=
session
.
IsHttps
;
if
(
server
.
GetCustomUpStreamProxyFunc
!=
null
)
...
...
@@ -170,7 +170,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
internal
async
Task
<
TcpServerConnection
>
GetServerConnection
(
ProxyServer
server
,
SessionEventArgsBase
session
,
bool
isConnect
,
List
<
SslApplicationProtocol
>?
applicationProtocols
,
bool
noCache
,
CancellationToken
cancellationToken
)
{
I
ExternalProxy
?
customUpStreamProxy
=
null
;
ExternalProxy
?
customUpStreamProxy
=
null
;
bool
isHttps
=
session
.
IsHttps
;
if
(
server
.
GetCustomUpStreamProxyFunc
!=
null
)
...
...
@@ -208,7 +208,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
/// <returns></returns>
internal
async
Task
<
TcpServerConnection
>
GetServerConnection
(
string
remoteHostName
,
int
remotePort
,
Version
httpVersion
,
bool
isHttps
,
List
<
SslApplicationProtocol
>?
applicationProtocols
,
bool
isConnect
,
ProxyServer
proxyServer
,
SessionEventArgsBase
?
session
,
IPEndPoint
?
upStreamEndPoint
,
I
ExternalProxy
?
externalProxy
,
ProxyServer
proxyServer
,
SessionEventArgsBase
?
session
,
IPEndPoint
?
upStreamEndPoint
,
ExternalProxy
?
externalProxy
,
bool
noCache
,
CancellationToken
cancellationToken
)
{
var
sslProtocol
=
session
?.
ProxyClient
.
Connection
.
SslProtocol
??
SslProtocols
.
None
;
...
...
@@ -262,7 +262,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
/// <returns></returns>
private
async
Task
<
TcpServerConnection
>
createServerConnection
(
string
remoteHostName
,
int
remotePort
,
Version
httpVersion
,
bool
isHttps
,
SslProtocols
sslProtocol
,
List
<
SslApplicationProtocol
>?
applicationProtocols
,
bool
isConnect
,
ProxyServer
proxyServer
,
SessionEventArgsBase
?
session
,
IPEndPoint
?
upStreamEndPoint
,
I
ExternalProxy
?
externalProxy
,
string
cacheKey
,
ProxyServer
proxyServer
,
SessionEventArgsBase
?
session
,
IPEndPoint
?
upStreamEndPoint
,
ExternalProxy
?
externalProxy
,
string
cacheKey
,
CancellationToken
cancellationToken
)
{
// deny connection to proxy end points to avoid infinite connection loop.
...
...
@@ -304,7 +304,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
bool
retry
=
true
;
var
enabledSslProtocols
=
sslProtocol
;
retry
:
retry
:
try
{
string
hostname
=
useUpstreamProxy
?
externalProxy
!.
HostName
:
remoteHostName
;
...
...
src/Titanium.Web.Proxy/Network/Tcp/TcpServerConnection.cs
View file @
af8558f3
...
...
@@ -17,7 +17,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
{
internal
TcpServerConnection
(
ProxyServer
proxyServer
,
TcpClient
tcpClient
,
CustomBufferedStream
stream
,
string
hostName
,
int
port
,
bool
isHttps
,
SslApplicationProtocol
negotiatedApplicationProtocol
,
Version
version
,
bool
useUpstreamProxy
,
I
ExternalProxy
?
upStreamProxy
,
IPEndPoint
?
upStreamEndPoint
,
string
cacheKey
)
Version
version
,
bool
useUpstreamProxy
,
ExternalProxy
?
upStreamProxy
,
IPEndPoint
?
upStreamEndPoint
,
string
cacheKey
)
{
this
.
tcpClient
=
tcpClient
;
LastAccess
=
DateTime
.
Now
;
...
...
@@ -41,7 +41,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
internal
bool
IsClosed
=>
Stream
.
IsClosed
;
internal
I
ExternalProxy
?
UpStreamProxy
{
get
;
set
;
}
internal
ExternalProxy
?
UpStreamProxy
{
get
;
set
;
}
internal
string
HostName
{
get
;
set
;
}
...
...
src/Titanium.Web.Proxy/ProxyServer.cs
View file @
af8558f3
...
...
@@ -61,7 +61,7 @@ namespace Titanium.Web.Proxy
/// </summary>
private
WinHttpWebProxyFinder
?
systemProxyResolver
;
/// <inheritdoc />
/// <summary>
/// Initializes a new instance of ProxyServer class with provided parameters.
...
...
@@ -145,7 +145,7 @@ namespace Titanium.Web.Proxy
/// Defaults to false.
/// </summary>
public
bool
EnableWinAuth
{
get
;
set
;
}
/// <summary>
/// Enable disable HTTP/2 support.
/// Warning: HTTP/2 support is very limited
...
...
@@ -253,12 +253,12 @@ namespace Titanium.Web.Proxy
/// <summary>
/// External proxy used for Http requests.
/// </summary>
public
I
ExternalProxy
?
UpStreamHttpProxy
{
get
;
set
;
}
public
ExternalProxy
?
UpStreamHttpProxy
{
get
;
set
;
}
/// <summary>
/// External proxy used for Https requests.
/// </summary>
public
I
ExternalProxy
?
UpStreamHttpsProxy
{
get
;
set
;
}
public
ExternalProxy
?
UpStreamHttpsProxy
{
get
;
set
;
}
/// <summary>
/// Local adapter/NIC endpoint where proxy makes request via.
...
...
@@ -275,7 +275,7 @@ namespace Titanium.Web.Proxy
/// A callback to provide authentication credentials for up stream proxy this proxy is using for HTTP(S) requests.
/// User should return the ExternalProxy object with valid credentials.
/// </summary>
public
Func
<
SessionEventArgsBase
,
Task
<
I
ExternalProxy
?>>?
GetCustomUpStreamProxyFunc
{
get
;
set
;
}
public
Func
<
SessionEventArgsBase
,
Task
<
ExternalProxy
?>>?
GetCustomUpStreamProxyFunc
{
get
;
set
;
}
/// <summary>
/// Callback for error events in this proxy instance.
...
...
@@ -709,7 +709,7 @@ namespace Titanium.Web.Proxy
/// </summary>
/// <param name="sessionEventArgs">The session.</param>
/// <returns>The external proxy as task result.</returns>
private
Task
<
I
ExternalProxy
?>
getSystemUpStreamProxy
(
SessionEventArgsBase
sessionEventArgs
)
private
Task
<
ExternalProxy
?>
getSystemUpStreamProxy
(
SessionEventArgsBase
sessionEventArgs
)
{
var
proxy
=
systemProxyResolver
!.
GetProxy
(
sessionEventArgs
.
HttpClient
.
Request
.
RequestUri
);
return
Task
.
FromResult
(
proxy
);
...
...
tests/Titanium.Web.Proxy.IntegrationTests/NestedProxyTests.cs
View file @
af8558f3
...
...
@@ -69,7 +69,7 @@ namespace Titanium.Web.Proxy.IntegrationTests
};
var
client
=
testSuite
.
GetClient
(
proxy1
,
true
);
var
response
=
await
client
.
PostAsync
(
new
Uri
(
server
.
ListeningHttpsUrl
),
new
StringContent
(
"hello server. I am a client."
));
...
...
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