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
77d9258f
Commit
77d9258f
authored
Apr 24, 2019
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inconsistent naming fixes
parent
6996456c
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
79 additions
and
77 deletions
+79
-77
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+19
-19
MainWindow.xaml.cs
examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs
+7
-7
Titanium.Web.Proxy.sln.DotSettings
src/Titanium.Web.Proxy.sln.DotSettings
+2
-0
SessionEventArgs.cs
src/Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
+8
-8
SessionEventArgsBase.cs
...Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs
+8
-8
RunTime.cs
src/Titanium.Web.Proxy/Helpers/RunTime.cs
+2
-2
SystemProxy.cs
src/Titanium.Web.Proxy/Helpers/SystemProxy.cs
+7
-7
TcpConnectionFactory.cs
src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+9
-9
LittleEndian.cs
...tanium.Web.Proxy/Network/WinAuth/Security/LittleEndian.cs
+1
-1
HttpMessageParsing.cs
....Web.Proxy.IntegrationTests/Helpers/HttpMessageParsing.cs
+3
-3
SystemProxyTest.cs
tests/Titanium.Web.Proxy.UnitTests/SystemProxyTest.cs
+13
-13
No files found.
examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
77d9258f
...
...
@@ -32,11 +32,11 @@ namespace Titanium.Web.Proxy.Examples.Basic
{
if
(
exception
is
ProxyHttpException
phex
)
{
await
W
riteToConsole
(
exception
.
Message
+
": "
+
phex
.
InnerException
?.
Message
,
true
);
await
w
riteToConsole
(
exception
.
Message
+
": "
+
phex
.
InnerException
?.
Message
,
true
);
}
else
{
await
W
riteToConsole
(
exception
.
Message
,
true
);
await
w
riteToConsole
(
exception
.
Message
,
true
);
}
};
proxyServer
.
ForwardToUpstreamGateway
=
true
;
...
...
@@ -52,8 +52,8 @@ namespace Titanium.Web.Proxy.Examples.Basic
public
void
StartProxy
()
{
proxyServer
.
BeforeRequest
+=
O
nRequest
;
proxyServer
.
BeforeResponse
+=
O
nResponse
;
proxyServer
.
BeforeRequest
+=
o
nRequest
;
proxyServer
.
BeforeResponse
+=
o
nResponse
;
proxyServer
.
ServerCertificateValidationCallback
+=
OnCertificateValidation
;
proxyServer
.
ClientCertificateSelectionCallback
+=
OnCertificateSelection
;
...
...
@@ -63,7 +63,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
explicitEndPoint
=
new
ExplicitProxyEndPoint
(
IPAddress
.
Any
,
8000
);
// Fired when a CONNECT request is received
explicitEndPoint
.
BeforeTunnelConnectRequest
+=
O
nBeforeTunnelConnectRequest
;
explicitEndPoint
.
BeforeTunnelConnectRequest
+=
o
nBeforeTunnelConnectRequest
;
explicitEndPoint
.
BeforeTunnelConnectResponse
+=
OnBeforeTunnelConnectResponse
;
// An explicit endpoint is where the client knows about the existence of a proxy
...
...
@@ -102,11 +102,11 @@ namespace Titanium.Web.Proxy.Examples.Basic
public
void
Stop
()
{
explicitEndPoint
.
BeforeTunnelConnectRequest
-=
O
nBeforeTunnelConnectRequest
;
explicitEndPoint
.
BeforeTunnelConnectRequest
-=
o
nBeforeTunnelConnectRequest
;
explicitEndPoint
.
BeforeTunnelConnectResponse
-=
OnBeforeTunnelConnectResponse
;
proxyServer
.
BeforeRequest
-=
O
nRequest
;
proxyServer
.
BeforeResponse
-=
O
nResponse
;
proxyServer
.
BeforeRequest
-=
o
nRequest
;
proxyServer
.
BeforeResponse
-=
o
nResponse
;
proxyServer
.
ServerCertificateValidationCallback
-=
OnCertificateValidation
;
proxyServer
.
ClientCertificateSelectionCallback
-=
OnCertificateSelection
;
...
...
@@ -116,10 +116,10 @@ namespace Titanium.Web.Proxy.Examples.Basic
//proxyServer.CertificateManager.RemoveTrustedRootCertificates();
}
private
async
Task
O
nBeforeTunnelConnectRequest
(
object
sender
,
TunnelConnectSessionEventArgs
e
)
private
async
Task
o
nBeforeTunnelConnectRequest
(
object
sender
,
TunnelConnectSessionEventArgs
e
)
{
string
hostname
=
e
.
HttpClient
.
Request
.
RequestUri
.
Host
;
await
W
riteToConsole
(
"Tunnel to: "
+
hostname
);
await
w
riteToConsole
(
"Tunnel to: "
+
hostname
);
if
(
hostname
.
Contains
(
"dropbox.com"
))
{
...
...
@@ -136,10 +136,10 @@ namespace Titanium.Web.Proxy.Examples.Basic
}
// intecept & cancel redirect or update requests
private
async
Task
O
nRequest
(
object
sender
,
SessionEventArgs
e
)
private
async
Task
o
nRequest
(
object
sender
,
SessionEventArgs
e
)
{
await
W
riteToConsole
(
"Active Client Connections:"
+
((
ProxyServer
)
sender
).
ClientConnectionCount
);
await
W
riteToConsole
(
e
.
HttpClient
.
Request
.
Url
);
await
w
riteToConsole
(
"Active Client Connections:"
+
((
ProxyServer
)
sender
).
ClientConnectionCount
);
await
w
riteToConsole
(
e
.
HttpClient
.
Request
.
Url
);
// store it in the UserData property
// It can be a simple integer, Guid, or any type
...
...
@@ -177,19 +177,19 @@ namespace Titanium.Web.Proxy.Examples.Basic
}
// Modify response
private
async
Task
M
ultipartRequestPartSent
(
object
sender
,
MultipartRequestPartSentEventArgs
e
)
private
async
Task
m
ultipartRequestPartSent
(
object
sender
,
MultipartRequestPartSentEventArgs
e
)
{
var
session
=
(
SessionEventArgs
)
sender
;
await
W
riteToConsole
(
"Multipart form data headers:"
);
await
w
riteToConsole
(
"Multipart form data headers:"
);
foreach
(
var
header
in
e
.
Headers
)
{
await
W
riteToConsole
(
header
.
ToString
());
await
w
riteToConsole
(
header
.
ToString
());
}
}
private
async
Task
O
nResponse
(
object
sender
,
SessionEventArgs
e
)
private
async
Task
o
nResponse
(
object
sender
,
SessionEventArgs
e
)
{
await
W
riteToConsole
(
"Active Server Connections:"
+
((
ProxyServer
)
sender
).
ServerConnectionCount
);
await
w
riteToConsole
(
"Active Server Connections:"
+
((
ProxyServer
)
sender
).
ServerConnectionCount
);
string
ext
=
System
.
IO
.
Path
.
GetExtension
(
e
.
HttpClient
.
Request
.
RequestUri
.
AbsolutePath
);
...
...
@@ -261,7 +261,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
return
Task
.
FromResult
(
0
);
}
private
async
Task
W
riteToConsole
(
string
message
,
bool
useRedColor
=
false
)
private
async
Task
w
riteToConsole
(
string
message
,
bool
useRedColor
=
false
)
{
await
@lock
.
WaitAsync
();
...
...
examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs
View file @
77d9258f
...
...
@@ -106,7 +106,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
if
(
value
!=
selectedSession
)
{
selectedSession
=
value
;
S
electedSessionChanged
();
s
electedSessionChanged
();
}
}
}
...
...
@@ -131,7 +131,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
e
.
DecryptSsl
=
false
;
}
await
Dispatcher
.
InvokeAsync
(()
=>
{
A
ddSession
(
e
);
});
await
Dispatcher
.
InvokeAsync
(()
=>
{
a
ddSession
(
e
);
});
}
private
async
Task
ProxyServer_BeforeTunnelConnectResponse
(
object
sender
,
TunnelConnectSessionEventArgs
e
)
...
...
@@ -148,7 +148,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
private
async
Task
ProxyServer_BeforeRequest
(
object
sender
,
SessionEventArgs
e
)
{
SessionListItem
item
=
null
;
await
Dispatcher
.
InvokeAsync
(()
=>
{
item
=
A
ddSession
(
e
);
});
await
Dispatcher
.
InvokeAsync
(()
=>
{
item
=
a
ddSession
(
e
);
});
if
(
e
.
HttpClient
.
Request
.
HasBody
)
{
...
...
@@ -191,15 +191,15 @@ namespace Titanium.Web.Proxy.Examples.Wpf
});
}
private
SessionListItem
A
ddSession
(
SessionEventArgsBase
e
)
private
SessionListItem
a
ddSession
(
SessionEventArgsBase
e
)
{
var
item
=
C
reateSessionListItem
(
e
);
var
item
=
c
reateSessionListItem
(
e
);
Sessions
.
Add
(
item
);
sessionDictionary
.
Add
(
e
.
HttpClient
,
item
);
return
item
;
}
private
SessionListItem
C
reateSessionListItem
(
SessionEventArgsBase
e
)
private
SessionListItem
c
reateSessionListItem
(
SessionEventArgsBase
e
)
{
lastSessionNumber
++;
bool
isTunnelConnect
=
e
is
TunnelConnectSessionEventArgs
;
...
...
@@ -248,7 +248,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
}
}
private
void
S
electedSessionChanged
()
private
void
s
electedSessionChanged
()
{
if
(
SelectedSession
==
null
)
{
...
...
src/Titanium.Web.Proxy.sln.DotSettings
View file @
77d9258f
...
...
@@ -19,10 +19,12 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MTA/@EntryIndexedValue">MTA</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OID/@EntryIndexedValue">OID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OIDS/@EntryIndexedValue">OIDS</s:String>
<s:Boolean x:Key="/Default/CodeStyle/Naming/CSharpNaming/ApplyAutoDetectedRules/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PublicFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=a4ab2e69_002D4d9c_002D4345_002Dbcd1_002D5541dacf5d38/@EntryIndexedValue"><Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Private" Description="Method (private)"><ElementKinds><Kind Name="METHOD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy></s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=dda2ffa1_002D435c_002D4111_002D88eb_002D1a7c93c382f0/@EntryIndexedValue"><Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Private" Description="Property (private)"><ElementKinds><Kind Name="PROPERTY" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy></s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
...
...
src/Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
View file @
77d9258f
...
...
@@ -117,7 +117,7 @@ namespace Titanium.Web.Proxy.EventArguments
}
catch
(
Exception
ex
)
{
e
xceptionFunc
(
new
Exception
(
"Exception thrown in user event"
,
ex
));
E
xceptionFunc
(
new
Exception
(
"Exception thrown in user event"
,
ex
));
}
}
...
...
@@ -154,7 +154,7 @@ namespace Titanium.Web.Proxy.EventArguments
{
using
(
var
bodyStream
=
new
MemoryStream
())
{
var
writer
=
new
HttpWriter
(
bodyStream
,
bufferPool
,
b
ufferSize
);
var
writer
=
new
HttpWriter
(
bodyStream
,
BufferPool
,
B
ufferSize
);
if
(
isRequest
)
{
...
...
@@ -186,7 +186,7 @@ namespace Titanium.Web.Proxy.EventArguments
using
(
var
bodyStream
=
new
MemoryStream
())
{
var
writer
=
new
HttpWriter
(
bodyStream
,
bufferPool
,
b
ufferSize
);
var
writer
=
new
HttpWriter
(
bodyStream
,
BufferPool
,
B
ufferSize
);
await
copyBodyAsync
(
isRequest
,
true
,
writer
,
TransformationMode
.
None
,
null
,
cancellationToken
);
}
}
...
...
@@ -207,7 +207,7 @@ namespace Titanium.Web.Proxy.EventArguments
var
reader
=
getStreamReader
(
true
);
string
boundary
=
HttpHelper
.
GetBoundaryFromContentType
(
request
.
ContentType
);
using
(
var
copyStream
=
new
CopyStream
(
reader
,
writer
,
bufferPool
,
b
ufferSize
))
using
(
var
copyStream
=
new
CopyStream
(
reader
,
writer
,
BufferPool
,
B
ufferSize
))
{
while
(
contentLength
>
copyStream
.
ReadBytes
)
{
...
...
@@ -259,7 +259,7 @@ namespace Titanium.Web.Proxy.EventArguments
string
contentEncoding
=
useOriginalHeaderValues
?
requestResponse
.
OriginalContentEncoding
:
requestResponse
.
ContentEncoding
;
Stream
s
=
limitedStream
=
new
LimitedStream
(
stream
,
b
ufferPool
,
isChunked
,
contentLength
);
Stream
s
=
limitedStream
=
new
LimitedStream
(
stream
,
B
ufferPool
,
isChunked
,
contentLength
);
if
(
transformation
==
TransformationMode
.
Uncompress
&&
contentEncoding
!=
null
)
{
...
...
@@ -268,7 +268,7 @@ namespace Titanium.Web.Proxy.EventArguments
try
{
using
(
var
bufStream
=
new
CustomBufferedStream
(
s
,
bufferPool
,
b
ufferSize
,
true
))
using
(
var
bufStream
=
new
CustomBufferedStream
(
s
,
BufferPool
,
B
ufferSize
,
true
))
{
await
writer
.
CopyBodyAsync
(
bufStream
,
false
,
-
1
,
onCopy
,
cancellationToken
);
}
...
...
@@ -290,7 +290,7 @@ namespace Titanium.Web.Proxy.EventArguments
{
int
bufferDataLength
=
0
;
var
buffer
=
bufferPool
.
GetBuffer
(
b
ufferSize
);
var
buffer
=
BufferPool
.
GetBuffer
(
B
ufferSize
);
try
{
int
boundaryLength
=
boundary
.
Length
+
4
;
...
...
@@ -340,7 +340,7 @@ namespace Titanium.Web.Proxy.EventArguments
}
finally
{
b
ufferPool
.
ReturnBuffer
(
buffer
);
B
ufferPool
.
ReturnBuffer
(
buffer
);
}
}
...
...
src/Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs
View file @
77d9258f
...
...
@@ -24,9 +24,9 @@ namespace Titanium.Web.Proxy.EventArguments
internal
TcpServerConnection
ServerConnection
=>
HttpClient
.
Connection
;
internal
TcpClientConnection
ClientConnection
=>
ProxyClient
.
Connection
;
protected
readonly
int
b
ufferSize
;
protected
readonly
IBufferPool
b
ufferPool
;
protected
readonly
ExceptionHandler
e
xceptionFunc
;
protected
readonly
int
B
ufferSize
;
protected
readonly
IBufferPool
B
ufferPool
;
protected
readonly
ExceptionHandler
E
xceptionFunc
;
/// <summary>
/// Relative milliseconds for various events.
...
...
@@ -39,9 +39,9 @@ namespace Titanium.Web.Proxy.EventArguments
private
SessionEventArgsBase
(
ProxyServer
server
,
ProxyEndPoint
endPoint
,
CancellationTokenSource
cancellationTokenSource
)
{
b
ufferSize
=
server
.
BufferSize
;
b
ufferPool
=
server
.
BufferPool
;
e
xceptionFunc
=
server
.
ExceptionFunc
;
B
ufferSize
=
server
.
BufferSize
;
B
ufferPool
=
server
.
BufferPool
;
E
xceptionFunc
=
server
.
ExceptionFunc
;
TimeLine
[
"Session Created"
]
=
DateTime
.
Now
;
}
...
...
@@ -161,7 +161,7 @@ namespace Titanium.Web.Proxy.EventArguments
}
catch
(
Exception
ex
)
{
e
xceptionFunc
(
new
Exception
(
"Exception thrown in user event"
,
ex
));
E
xceptionFunc
(
new
Exception
(
"Exception thrown in user event"
,
ex
));
}
}
...
...
@@ -173,7 +173,7 @@ namespace Titanium.Web.Proxy.EventArguments
}
catch
(
Exception
ex
)
{
e
xceptionFunc
(
new
Exception
(
"Exception thrown in user event"
,
ex
));
E
xceptionFunc
(
new
Exception
(
"Exception thrown in user event"
,
ex
));
}
}
...
...
src/Titanium.Web.Proxy/Helpers/RunTime.cs
View file @
77d9258f
...
...
@@ -70,7 +70,7 @@ namespace Titanium.Web.Proxy.Helpers
internal
static
bool
IsRunningAsUwp
()
{
if
(
I
sWindows7OrLower
)
if
(
i
sWindows7OrLower
)
{
return
false
;
}
...
...
@@ -87,7 +87,7 @@ namespace Titanium.Web.Proxy.Helpers
}
}
private
static
bool
I
sWindows7OrLower
private
static
bool
i
sWindows7OrLower
{
get
{
...
...
src/Titanium.Web.Proxy/Helpers/SystemProxy.cs
View file @
77d9258f
...
...
@@ -80,7 +80,7 @@ namespace Titanium.Web.Proxy.Helpers
/// <param name="protocolType"></param>
internal
void
SetProxy
(
string
hostname
,
int
port
,
ProxyProtocolType
protocolType
)
{
using
(
var
reg
=
O
penInternetSettingsKey
())
using
(
var
reg
=
o
penInternetSettingsKey
())
{
if
(
reg
==
null
)
{
...
...
@@ -127,7 +127,7 @@ namespace Titanium.Web.Proxy.Helpers
/// </summary>
internal
void
RemoveProxy
(
ProxyProtocolType
protocolType
,
bool
saveOriginalConfig
=
true
)
{
using
(
var
reg
=
O
penInternetSettingsKey
())
using
(
var
reg
=
o
penInternetSettingsKey
())
{
if
(
reg
==
null
)
{
...
...
@@ -168,7 +168,7 @@ namespace Titanium.Web.Proxy.Helpers
/// </summary>
internal
void
DisableAllProxy
()
{
using
(
var
reg
=
O
penInternetSettingsKey
())
using
(
var
reg
=
o
penInternetSettingsKey
())
{
if
(
reg
==
null
)
{
...
...
@@ -186,7 +186,7 @@ namespace Titanium.Web.Proxy.Helpers
internal
void
SetAutoProxyUrl
(
string
url
)
{
using
(
var
reg
=
O
penInternetSettingsKey
())
using
(
var
reg
=
o
penInternetSettingsKey
())
{
if
(
reg
==
null
)
{
...
...
@@ -201,7 +201,7 @@ namespace Titanium.Web.Proxy.Helpers
internal
void
SetProxyOverride
(
string
proxyOverride
)
{
using
(
var
reg
=
O
penInternetSettingsKey
())
using
(
var
reg
=
o
penInternetSettingsKey
())
{
if
(
reg
==
null
)
{
...
...
@@ -286,7 +286,7 @@ namespace Titanium.Web.Proxy.Helpers
internal
ProxyInfo
GetProxyInfoFromRegistry
()
{
using
(
var
reg
=
O
penInternetSettingsKey
())
using
(
var
reg
=
o
penInternetSettingsKey
())
{
if
(
reg
==
null
)
{
...
...
@@ -347,7 +347,7 @@ namespace Titanium.Web.Proxy.Helpers
/// <summary>
/// Opens the registry key with the internet settings
/// </summary>
private
static
RegistryKey
O
penInternetSettingsKey
()
private
static
RegistryKey
o
penInternetSettingsKey
()
{
return
Registry
.
CurrentUser
.
OpenSubKey
(
regKeyInternetSettings
,
true
);
}
...
...
src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
77d9258f
...
...
@@ -38,11 +38,11 @@ namespace Titanium.Web.Proxy.Network.Tcp
internal
TcpConnectionFactory
(
ProxyServer
server
)
{
this
.
s
erver
=
server
;
this
.
S
erver
=
server
;
Task
.
Run
(
async
()
=>
await
clearOutdatedConnections
());
}
internal
ProxyServer
s
erver
{
get
;
set
;
}
internal
ProxyServer
S
erver
{
get
;
set
;
}
internal
string
GetConnectionCacheKey
(
string
remoteHostName
,
int
remotePort
,
bool
isHttps
,
List
<
SslApplicationProtocol
>
applicationProtocols
,
...
...
@@ -232,7 +232,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
CancellationToken
cancellationToken
)
{
//deny connection to proxy end points to avoid infinite connection loop.
if
(
s
erver
.
ProxyEndPoints
.
Any
(
x
=>
x
.
Port
==
remotePort
)
if
(
S
erver
.
ProxyEndPoints
.
Any
(
x
=>
x
.
Port
==
remotePort
)
&&
NetworkHelper
.
IsLocalIpAddress
(
remoteHostName
))
{
throw
new
Exception
(
$"A client is making HTTP request to one of the listening ports of this proxy
{
remoteHostName
}
:
{
remotePort
}
"
);
...
...
@@ -240,7 +240,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
if
(
externalProxy
!=
null
)
{
if
(
s
erver
.
ProxyEndPoints
.
Any
(
x
=>
x
.
Port
==
externalProxy
.
Port
)
if
(
S
erver
.
ProxyEndPoints
.
Any
(
x
=>
x
.
Port
==
externalProxy
.
Port
)
&&
NetworkHelper
.
IsLocalIpAddress
(
externalProxy
.
HostName
))
{
throw
new
Exception
(
$"A client is making HTTP request via external proxy to one of the listening ports of this proxy
{
remoteHostName
}
:
{
remotePort
}
"
);
...
...
@@ -416,7 +416,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
return
;
}
if
(
close
||
connection
.
IsWinAuthenticated
||
!
s
erver
.
EnableConnectionPool
||
connection
.
Stream
.
IsClosed
)
if
(
close
||
connection
.
IsWinAuthenticated
||
!
S
erver
.
EnableConnectionPool
||
connection
.
Stream
.
IsClosed
)
{
disposalBag
.
Add
(
connection
);
return
;
...
...
@@ -432,7 +432,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
{
if
(
cache
.
TryGetValue
(
connection
.
CacheKey
,
out
var
existingConnections
))
{
while
(
existingConnections
.
Count
>=
s
erver
.
MaxCachedConnections
)
while
(
existingConnections
.
Count
>=
S
erver
.
MaxCachedConnections
)
{
if
(
existingConnections
.
TryDequeue
(
out
var
staleConnection
))
{
...
...
@@ -489,8 +489,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
{
if
(
queue
.
TryDequeue
(
out
var
connection
))
{
var
cutOff
=
DateTime
.
Now
.
AddSeconds
(-
1
*
s
erver
.
ConnectionTimeOutSeconds
);
if
(!
s
erver
.
EnableConnectionPool
var
cutOff
=
DateTime
.
Now
.
AddSeconds
(-
1
*
S
erver
.
ConnectionTimeOutSeconds
);
if
(!
S
erver
.
EnableConnectionPool
||
connection
.
LastAccess
<
cutOff
)
{
disposalBag
.
Add
(
connection
);
...
...
@@ -530,7 +530,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
}
catch
(
Exception
e
)
{
s
erver
.
ExceptionFunc
(
new
Exception
(
"An error occurred when disposing server connections."
,
e
));
S
erver
.
ExceptionFunc
(
new
Exception
(
"An error occurred when disposing server connections."
,
e
));
}
finally
{
...
...
src/Titanium.Web.Proxy/Network/WinAuth/Security/LittleEndian.cs
View file @
77d9258f
//
//
// Mono.Security.BitConverterLE.cs
// Like System.BitConverter but always little endian
//
...
...
tests/Titanium.Web.Proxy.IntegrationTests/Helpers/HttpMessageParsing.cs
View file @
77d9258f
...
...
@@ -43,7 +43,7 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
if
(!
requireBody
)
return
request
as
Request
;
if
(
P
arseBody
(
reader
,
ref
request
))
if
(
p
arseBody
(
reader
,
ref
request
))
return
request
as
Request
;
}
catch
{
}
...
...
@@ -84,7 +84,7 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
if
(
line
?.
Length
!=
0
)
return
null
;
if
(
P
arseBody
(
reader
,
ref
response
))
if
(
p
arseBody
(
reader
,
ref
response
))
return
response
as
Response
;
}
catch
{
}
...
...
@@ -92,7 +92,7 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
return
null
;
}
private
static
bool
P
arseBody
(
StringReader
reader
,
ref
RequestResponseBase
obj
)
private
static
bool
p
arseBody
(
StringReader
reader
,
ref
RequestResponseBase
obj
)
{
obj
.
OriginalContentLength
=
obj
.
ContentLength
;
if
(
obj
.
ContentLength
<=
0
)
...
...
tests/Titanium.Web.Proxy.UnitTests/SystemProxyTest.cs
View file @
77d9258f
...
...
@@ -11,22 +11,22 @@ namespace Titanium.Web.Proxy.UnitTests
public
class
SystemProxyTest
{
[
TestMethod
]
public
void
CompareProxyAdd
dressReturen
dByWebProxyAndWinHttpProxyResolver
()
public
void
CompareProxyAdd
ressReturne
dByWebProxyAndWinHttpProxyResolver
()
{
var
proxyManager
=
new
SystemProxyManager
();
try
{
C
ompareUrls
();
c
ompareUrls
();
proxyManager
.
SetProxy
(
"127.0.0.1"
,
8000
,
ProxyProtocolType
.
Http
);
C
ompareUrls
();
c
ompareUrls
();
proxyManager
.
SetProxy
(
"127.0.0.1"
,
8000
,
ProxyProtocolType
.
Https
);
C
ompareUrls
();
c
ompareUrls
();
proxyManager
.
SetProxy
(
"127.0.0.1"
,
8000
,
ProxyProtocolType
.
AllHttp
);
C
ompareUrls
();
c
ompareUrls
();
// for this test you need to add a proxy.pac file to a local webserver
//function FindProxyForURL(url, host)
...
...
@@ -43,25 +43,25 @@ namespace Titanium.Web.Proxy.UnitTests
//CompareUrls();
proxyManager
.
SetProxyOverride
(
"<-loopback>"
);
C
ompareUrls
();
c
ompareUrls
();
proxyManager
.
SetProxyOverride
(
"<local>"
);
C
ompareUrls
();
c
ompareUrls
();
proxyManager
.
SetProxyOverride
(
"yahoo.com"
);
C
ompareUrls
();
c
ompareUrls
();
proxyManager
.
SetProxyOverride
(
"*.local"
);
C
ompareUrls
();
c
ompareUrls
();
proxyManager
.
SetProxyOverride
(
"http://*.local"
);
C
ompareUrls
();
c
ompareUrls
();
proxyManager
.
SetProxyOverride
(
"<-loopback>;*.local"
);
C
ompareUrls
();
c
ompareUrls
();
proxyManager
.
SetProxyOverride
(
"<-loopback>;*.local;<local>"
);
C
ompareUrls
();
c
ompareUrls
();
}
finally
{
...
...
@@ -69,7 +69,7 @@ namespace Titanium.Web.Proxy.UnitTests
}
}
private
void
C
ompareUrls
()
private
void
c
ompareUrls
()
{
var
webProxy
=
WebRequest
.
GetSystemWebProxy
();
...
...
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