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
8cbf0f43
Unverified
Commit
8cbf0f43
authored
Dec 23, 2019
by
honfika
Committed by
GitHub
Dec 23, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #710 from justcoding121/master
beta
parents
312dca6c
d21ea354
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
71 additions
and
36 deletions
+71
-36
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+11
-0
SessionEventArgsBase.cs
...Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs
+17
-3
WinHttpWebProxyFinder.cs
...tanium.Web.Proxy/Helpers/WinHttp/WinHttpWebProxyFinder.cs
+2
-11
ExternalProxy.cs
src/Titanium.Web.Proxy/Models/ExternalProxy.cs
+33
-1
TcpConnectionFactory.cs
src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+4
-4
WinAuthHandler.cs
src/Titanium.Web.Proxy/WinAuthHandler.cs
+1
-1
NestedProxyTests.cs
...s/Titanium.Web.Proxy.IntegrationTests/NestedProxyTests.cs
+1
-5
TestProxyServer.cs
...anium.Web.Proxy.IntegrationTests/Setup/TestProxyServer.cs
+2
-11
No files found.
examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
8cbf0f43
...
@@ -207,6 +207,17 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -207,6 +207,17 @@ namespace Titanium.Web.Proxy.Examples.Basic
{
{
e
.
GetState
().
PipelineInfo
.
AppendLine
(
nameof
(
onRequest
)
+
":"
+
e
.
HttpClient
.
Request
.
RequestUri
);
e
.
GetState
().
PipelineInfo
.
AppendLine
(
nameof
(
onRequest
)
+
":"
+
e
.
HttpClient
.
Request
.
RequestUri
);
var
clientLocalIp
=
e
.
ClientLocalEndPoint
.
Address
;
if
(!
clientLocalIp
.
Equals
(
IPAddress
.
Loopback
)
&&
!
clientLocalIp
.
Equals
(
IPAddress
.
IPv6Loopback
))
{
e
.
HttpClient
.
UpStreamEndPoint
=
new
IPEndPoint
(
clientLocalIp
,
0
);
}
if
(
e
.
HttpClient
.
Request
.
Url
.
Contains
(
"yahoo.com"
))
{
e
.
CustomUpStreamProxy
=
new
ExternalProxy
(
"localhost"
,
8888
);
}
await
writeToConsole
(
"Active Client Connections:"
+
((
ProxyServer
)
sender
).
ClientConnectionCount
);
await
writeToConsole
(
"Active Client Connections:"
+
((
ProxyServer
)
sender
).
ClientConnectionCount
);
await
writeToConsole
(
e
.
HttpClient
.
Request
.
Url
);
await
writeToConsole
(
e
.
HttpClient
.
Request
.
Url
);
...
...
src/Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs
View file @
8cbf0f43
...
@@ -59,7 +59,7 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -59,7 +59,7 @@ namespace Titanium.Web.Proxy.EventArguments
ClientStream
=
clientStream
;
ClientStream
=
clientStream
;
HttpClient
=
new
HttpWebClient
(
connectRequest
,
request
,
new
Lazy
<
int
>(()
=>
clientStream
.
Connection
.
GetProcessId
(
endPoint
)));
HttpClient
=
new
HttpWebClient
(
connectRequest
,
request
,
new
Lazy
<
int
>(()
=>
clientStream
.
Connection
.
GetProcessId
(
endPoint
)));
Local
EndPoint
=
endPoint
;
Proxy
EndPoint
=
endPoint
;
EnableWinAuth
=
server
.
EnableWinAuth
&&
isWindowsAuthenticationSupported
;
EnableWinAuth
=
server
.
EnableWinAuth
&&
isWindowsAuthenticationSupported
;
}
}
...
@@ -103,6 +103,9 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -103,6 +103,9 @@ namespace Titanium.Web.Proxy.EventArguments
/// </summary>
/// </summary>
public
IPEndPoint
ClientRemoteEndPoint
=>
(
IPEndPoint
)
ClientConnection
.
RemoteEndPoint
;
public
IPEndPoint
ClientRemoteEndPoint
=>
(
IPEndPoint
)
ClientConnection
.
RemoteEndPoint
;
[
Obsolete
(
"Use ClientRemoteEndPoint instead."
)]
public
IPEndPoint
ClientEndPoint
=>
ClientRemoteEndPoint
;
/// <summary>
/// <summary>
/// The web client used to communicate with server for this session.
/// The web client used to communicate with server for this session.
/// </summary>
/// </summary>
...
@@ -111,6 +114,14 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -111,6 +114,14 @@ namespace Titanium.Web.Proxy.EventArguments
[
Obsolete
(
"Use HttpClient instead."
)]
[
Obsolete
(
"Use HttpClient instead."
)]
public
HttpWebClient
WebSession
=>
HttpClient
;
public
HttpWebClient
WebSession
=>
HttpClient
;
/// <summary>
/// Gets or sets the custom up stream proxy.
/// </summary>
/// <value>
/// The custom up stream proxy.
/// </value>
public
IExternalProxy
?
CustomUpStreamProxy
{
get
;
set
;
}
/// <summary>
/// <summary>
/// Are we using a custom upstream HTTP(S) proxy?
/// Are we using a custom upstream HTTP(S) proxy?
/// </summary>
/// </summary>
...
@@ -119,12 +130,15 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -119,12 +130,15 @@ namespace Titanium.Web.Proxy.EventArguments
/// <summary>
/// <summary>
/// Local endpoint via which we make the request.
/// Local endpoint via which we make the request.
/// </summary>
/// </summary>
public
ProxyEndPoint
LocalEndPoint
{
get
;
}
public
ProxyEndPoint
ProxyEndPoint
{
get
;
}
[
Obsolete
(
"Use ProxyEndPoint instead."
)]
public
ProxyEndPoint
LocalEndPoint
=>
ProxyEndPoint
;
/// <summary>
/// <summary>
/// Is this a transparent endpoint?
/// Is this a transparent endpoint?
/// </summary>
/// </summary>
public
bool
IsTransparent
=>
Local
EndPoint
is
TransparentProxyEndPoint
;
public
bool
IsTransparent
=>
Proxy
EndPoint
is
TransparentProxyEndPoint
;
/// <summary>
/// <summary>
/// The last exception that happened.
/// The last exception that happened.
...
...
src/Titanium.Web.Proxy/Helpers/WinHttp/WinHttpWebProxyFinder.cs
View file @
8cbf0f43
...
@@ -114,11 +114,7 @@ namespace Titanium.Web.Proxy.Helpers.WinHttp
...
@@ -114,11 +114,7 @@ namespace Titanium.Web.Proxy.Helpers.WinHttp
}
}
// TODO: Apply authorization
// TODO: Apply authorization
var
systemProxy
=
new
ExternalProxy
var
systemProxy
=
new
ExternalProxy
(
proxyStr
,
port
);
{
HostName
=
proxyStr
,
Port
=
port
};
return
systemProxy
;
return
systemProxy
;
}
}
...
@@ -134,12 +130,7 @@ namespace Titanium.Web.Proxy.Helpers.WinHttp
...
@@ -134,12 +130,7 @@ namespace Titanium.Web.Proxy.Helpers.WinHttp
HttpSystemProxyValue
?
value
=
null
;
HttpSystemProxyValue
?
value
=
null
;
if
(
ProxyInfo
?.
Proxies
?.
TryGetValue
(
protocolType
.
Value
,
out
value
)
==
true
)
if
(
ProxyInfo
?.
Proxies
?.
TryGetValue
(
protocolType
.
Value
,
out
value
)
==
true
)
{
{
var
systemProxy
=
new
ExternalProxy
var
systemProxy
=
new
ExternalProxy
(
value
!.
HostName
,
value
.
Port
);
{
HostName
=
value
!.
HostName
,
Port
=
value
.
Port
};
return
systemProxy
;
return
systemProxy
;
}
}
}
}
...
...
src/Titanium.Web.Proxy/Models/ExternalProxy.cs
View file @
8cbf0f43
...
@@ -69,6 +69,39 @@ namespace Titanium.Web.Proxy.Models
...
@@ -69,6 +69,39 @@ namespace Titanium.Web.Proxy.Models
/// </summary>
/// </summary>
public
int
Port
{
get
;
set
;
}
public
int
Port
{
get
;
set
;
}
/// <summary>
/// Initializes a new instance of the <see cref="ExternalProxy"/> class.
/// </summary>
public
ExternalProxy
()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ExternalProxy"/> class.
/// </summary>
/// <param name="hostName">Name of the host.</param>
/// <param name="port">The port.</param>
public
ExternalProxy
(
string
hostName
,
int
port
)
{
HostName
=
hostName
;
Port
=
port
;
}
/// <summary>
/// Initializes a new instance of the <see cref="ExternalProxy"/> class.
/// </summary>
/// <param name="hostName">Name of the host.</param>
/// <param name="port">The port.</param>
/// <param name="userName">Name of the user.</param>
/// <param name="password">The password.</param>
public
ExternalProxy
(
string
hostName
,
int
port
,
string
userName
,
string
password
)
{
HostName
=
hostName
;
Port
=
port
;
UserName
=
userName
;
Password
=
password
;
}
/// <summary>
/// <summary>
/// returns data in Hostname:port format.
/// returns data in Hostname:port format.
/// </summary>
/// </summary>
...
@@ -77,6 +110,5 @@ namespace Titanium.Web.Proxy.Models
...
@@ -77,6 +110,5 @@ namespace Titanium.Web.Proxy.Models
{
{
return
$"
{
HostName
}
:
{
Port
}
"
;
return
$"
{
HostName
}
:
{
Port
}
"
;
}
}
}
}
}
}
src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
8cbf0f43
...
@@ -114,10 +114,10 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -114,10 +114,10 @@ namespace Titanium.Web.Proxy.Network.Tcp
applicationProtocols
=
new
List
<
SslApplicationProtocol
>
{
applicationProtocol
};
applicationProtocols
=
new
List
<
SslApplicationProtocol
>
{
applicationProtocol
};
}
}
IExternalProxy
?
customUpStreamProxy
=
null
;
IExternalProxy
?
customUpStreamProxy
=
session
.
CustomUpStreamProxy
;
bool
isHttps
=
session
.
IsHttps
;
bool
isHttps
=
session
.
IsHttps
;
if
(
server
.
GetCustomUpStreamProxyFunc
!=
null
)
if
(
customUpStreamProxy
==
null
&&
server
.
GetCustomUpStreamProxyFunc
!=
null
)
{
{
customUpStreamProxy
=
await
server
.
GetCustomUpStreamProxyFunc
(
session
);
customUpStreamProxy
=
await
server
.
GetCustomUpStreamProxyFunc
(
session
);
}
}
...
@@ -169,10 +169,10 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -169,10 +169,10 @@ namespace Titanium.Web.Proxy.Network.Tcp
internal
async
Task
<
TcpServerConnection
>
GetServerConnection
(
ProxyServer
proxyServer
,
SessionEventArgsBase
session
,
bool
isConnect
,
internal
async
Task
<
TcpServerConnection
>
GetServerConnection
(
ProxyServer
proxyServer
,
SessionEventArgsBase
session
,
bool
isConnect
,
List
<
SslApplicationProtocol
>?
applicationProtocols
,
bool
noCache
,
CancellationToken
cancellationToken
)
List
<
SslApplicationProtocol
>?
applicationProtocols
,
bool
noCache
,
CancellationToken
cancellationToken
)
{
{
IExternalProxy
?
customUpStreamProxy
=
null
;
IExternalProxy
?
customUpStreamProxy
=
session
.
CustomUpStreamProxy
;
bool
isHttps
=
session
.
IsHttps
;
bool
isHttps
=
session
.
IsHttps
;
if
(
proxyServer
.
GetCustomUpStreamProxyFunc
!=
null
)
if
(
customUpStreamProxy
==
null
&&
proxyServer
.
GetCustomUpStreamProxyFunc
!=
null
)
{
{
customUpStreamProxy
=
await
proxyServer
.
GetCustomUpStreamProxyFunc
(
session
);
customUpStreamProxy
=
await
proxyServer
.
GetCustomUpStreamProxyFunc
(
session
);
}
}
...
...
src/Titanium.Web.Proxy/WinAuthHandler.cs
View file @
8cbf0f43
...
@@ -175,7 +175,7 @@ namespace Titanium.Web.Proxy
...
@@ -175,7 +175,7 @@ namespace Titanium.Web.Proxy
// Add custom div to body to clarify that the proxy (not the client browser) failed authentication
// Add custom div to body to clarify that the proxy (not the client browser) failed authentication
string
authErrorMessage
=
string
authErrorMessage
=
"<div class=\"inserted-by-proxy\"><h2>NTLM authentication through Titanium.Web.Proxy ("
+
"<div class=\"inserted-by-proxy\"><h2>NTLM authentication through Titanium.Web.Proxy ("
+
args
.
Client
Connection
.
LocalEndPoint
+
args
.
ClientLocalEndPoint
+
") failed. Please check credentials.</h2></div>"
;
") failed. Please check credentials.</h2></div>"
;
string
originalErrorMessage
=
string
originalErrorMessage
=
"<div class=\"inserted-by-proxy\"><h3>Response from remote web server below.</h3></div><br/>"
;
"<div class=\"inserted-by-proxy\"><h3>Response from remote web server below.</h3></div><br/>"
;
...
...
tests/Titanium.Web.Proxy.IntegrationTests/NestedProxyTests.cs
View file @
8cbf0f43
...
@@ -59,11 +59,7 @@ namespace Titanium.Web.Proxy.IntegrationTests
...
@@ -59,11 +59,7 @@ namespace Titanium.Web.Proxy.IntegrationTests
{
{
Assert
.
AreEqual
(
"Test"
,
session
.
UserData
);
Assert
.
AreEqual
(
"Test"
,
session
.
UserData
);
return
await
Task
.
FromResult
(
new
Models
.
ExternalProxy
return
await
Task
.
FromResult
(
new
Models
.
ExternalProxy
(
"localhost"
,
proxy2
.
ProxyEndPoints
[
0
].
Port
));
{
HostName
=
"localhost"
,
Port
=
proxy2
.
ProxyEndPoints
[
0
].
Port
});
};
};
var
client
=
testSuite
.
GetClient
(
proxy1
,
true
);
var
client
=
testSuite
.
GetClient
(
proxy1
,
true
);
...
...
tests/Titanium.Web.Proxy.IntegrationTests/Setup/TestProxyServer.cs
View file @
8cbf0f43
...
@@ -22,17 +22,8 @@ namespace Titanium.Web.Proxy.IntegrationTests.Setup
...
@@ -22,17 +22,8 @@ namespace Titanium.Web.Proxy.IntegrationTests.Setup
if
(
upStreamProxy
!=
null
)
if
(
upStreamProxy
!=
null
)
{
{
ProxyServer
.
UpStreamHttpProxy
=
new
ExternalProxy
ProxyServer
.
UpStreamHttpProxy
=
new
ExternalProxy
(
"localhost"
,
upStreamProxy
.
ProxyEndPoints
[
0
].
Port
);
{
ProxyServer
.
UpStreamHttpsProxy
=
new
ExternalProxy
(
"localhost"
,
upStreamProxy
.
ProxyEndPoints
[
0
].
Port
);
HostName
=
"localhost"
,
Port
=
upStreamProxy
.
ProxyEndPoints
[
0
].
Port
};
ProxyServer
.
UpStreamHttpsProxy
=
new
ExternalProxy
{
HostName
=
"localhost"
,
Port
=
upStreamProxy
.
ProxyEndPoints
[
0
].
Port
};
}
}
ProxyServer
.
Start
();
ProxyServer
.
Start
();
...
...
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