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
b43e3df2
Commit
b43e3df2
authored
May 16, 2017
by
Jehonathan Thomas
Committed by
GitHub
May 16, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #236 from honfika/develop
Space within single line array initializer
parents
2909c05d
b03f5efb
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
38 additions
and
38 deletions
+38
-38
Program.cs
Examples/Titanium.Web.Proxy.Examples.Basic/Program.cs
+1
-1
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+2
-2
CertificateManagerTests.cs
...s/Titanium.Web.Proxy.UnitTests/CertificateManagerTests.cs
+1
-4
Titanium.Web.Proxy.sln.DotSettings
Titanium.Web.Proxy.sln.DotSettings
+1
-0
HeaderParser.cs
Titanium.Web.Proxy/Http/HeaderParser.cs
+1
-1
WinCertificateMaker.cs
...nium.Web.Proxy/Network/Certificate/WinCertificateMaker.cs
+17
-17
CertificateManager.cs
Titanium.Web.Proxy/Network/CertificateManager.cs
+1
-1
TcpConnection.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnection.cs
+3
-1
TcpConnectionFactory.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+2
-2
ProxyAuthorizationHandler.cs
Titanium.Web.Proxy/ProxyAuthorizationHandler.cs
+2
-2
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+3
-1
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+1
-2
ResponseHandler.cs
Titanium.Web.Proxy/ResponseHandler.cs
+0
-1
ProxyConstants.cs
Titanium.Web.Proxy/Shared/ProxyConstants.cs
+3
-3
No files found.
Examples/Titanium.Web.Proxy.Examples.Basic/Program.cs
View file @
b43e3df2
...
@@ -51,4 +51,4 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -51,4 +51,4 @@ namespace Titanium.Web.Proxy.Examples.Basic
// Pinvoke
// Pinvoke
internal
delegate
bool
ConsoleEventDelegate
(
int
eventType
);
internal
delegate
bool
ConsoleEventDelegate
(
int
eventType
);
}
}
}
}
\ No newline at end of file
Examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
b43e3df2
...
@@ -107,7 +107,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -107,7 +107,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
//intecept & cancel redirect or update requests
//intecept & cancel redirect or update requests
public
async
Task
OnRequest
(
object
sender
,
SessionEventArgs
e
)
public
async
Task
OnRequest
(
object
sender
,
SessionEventArgs
e
)
{
{
Console
.
WriteLine
(
"Active Client Connections:"
+
((
ProxyServer
)
sender
).
ClientConnectionCount
);
Console
.
WriteLine
(
"Active Client Connections:"
+
((
ProxyServer
)
sender
).
ClientConnectionCount
);
Console
.
WriteLine
(
e
.
WebSession
.
Request
.
Url
);
Console
.
WriteLine
(
e
.
WebSession
.
Request
.
Url
);
//read request headers
//read request headers
...
@@ -150,7 +150,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -150,7 +150,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
//Modify response
//Modify response
public
async
Task
OnResponse
(
object
sender
,
SessionEventArgs
e
)
public
async
Task
OnResponse
(
object
sender
,
SessionEventArgs
e
)
{
{
Console
.
WriteLine
(
"Active Server Connections:"
+
((
ProxyServer
)
sender
).
ServerConnectionCount
);
Console
.
WriteLine
(
"Active Server Connections:"
+
((
ProxyServer
)
sender
).
ServerConnectionCount
);
if
(
requestBodyHistory
.
ContainsKey
(
e
.
Id
))
if
(
requestBodyHistory
.
ContainsKey
(
e
.
Id
))
{
{
...
...
Tests/Titanium.Web.Proxy.UnitTests/CertificateManagerTests.cs
View file @
b43e3df2
...
@@ -10,7 +10,7 @@ namespace Titanium.Web.Proxy.UnitTests
...
@@ -10,7 +10,7 @@ namespace Titanium.Web.Proxy.UnitTests
public
class
CertificateManagerTests
public
class
CertificateManagerTests
{
{
private
static
readonly
string
[]
hostNames
private
static
readonly
string
[]
hostNames
=
{
"facebook.com"
,
"youtube.com"
,
"google.com"
,
"bing.com"
,
"yahoo.com"
};
=
{
"facebook.com"
,
"youtube.com"
,
"google.com"
,
"bing.com"
,
"yahoo.com"
};
private
readonly
Random
random
=
new
Random
();
private
readonly
Random
random
=
new
Random
();
...
@@ -35,16 +35,13 @@ namespace Titanium.Web.Proxy.UnitTests
...
@@ -35,16 +35,13 @@ namespace Titanium.Web.Proxy.UnitTests
var
certificate
=
mgr
.
CreateCertificate
(
host
,
false
);
var
certificate
=
mgr
.
CreateCertificate
(
host
,
false
);
Assert
.
IsNotNull
(
certificate
);
Assert
.
IsNotNull
(
certificate
);
}));
}));
}
}
}
}
await
Task
.
WhenAll
(
tasks
.
ToArray
());
await
Task
.
WhenAll
(
tasks
.
ToArray
());
mgr
.
StopClearIdleCertificates
();
mgr
.
StopClearIdleCertificates
();
}
}
}
}
}
}
Titanium.Web.Proxy.sln.DotSettings
View file @
b43e3df2
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/LINE_FEED_AT_FILE_END/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/LINE_FEED_AT_FILE_END/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AFTER_TYPECAST_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AFTER_TYPECAST_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES/@EntryValue">True</s:Boolean>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LIMIT/@EntryValue">240</s:Int64>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LIMIT/@EntryValue">240</s:Int64>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=BC/@EntryIndexedValue">BC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=BC/@EntryIndexedValue">BC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CN/@EntryIndexedValue">CN</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CN/@EntryIndexedValue">CN</s:String>
...
...
Titanium.Web.Proxy/Http/HeaderParser.cs
View file @
b43e3df2
...
@@ -29,7 +29,7 @@ namespace Titanium.Web.Proxy.Http
...
@@ -29,7 +29,7 @@ namespace Titanium.Web.Proxy.Http
{
{
var
existing
=
headers
[
newHeader
.
Name
];
var
existing
=
headers
[
newHeader
.
Name
];
var
nonUniqueHeaders
=
new
List
<
HttpHeader
>
{
existing
,
newHeader
};
var
nonUniqueHeaders
=
new
List
<
HttpHeader
>
{
existing
,
newHeader
};
nonUniqueResponseHeaders
.
Add
(
newHeader
.
Name
,
nonUniqueHeaders
);
nonUniqueResponseHeaders
.
Add
(
newHeader
.
Name
,
nonUniqueHeaders
);
headers
.
Remove
(
newHeader
.
Name
);
headers
.
Remove
(
newHeader
.
Name
);
...
...
Titanium.Web.Proxy/Network/Certificate/WinCertificateMaker.cs
View file @
b43e3df2
...
@@ -89,7 +89,7 @@ namespace Titanium.Web.Proxy.Network.Certificate
...
@@ -89,7 +89,7 @@ namespace Titanium.Web.Proxy.Network.Certificate
}
}
var
x500CertDN
=
Activator
.
CreateInstance
(
typeX500DN
);
var
x500CertDN
=
Activator
.
CreateInstance
(
typeX500DN
);
var
typeValue
=
new
object
[]
{
fullSubject
,
0
};
var
typeValue
=
new
object
[]
{
fullSubject
,
0
};
typeX500DN
.
InvokeMember
(
"Encode"
,
BindingFlags
.
InvokeMethod
,
null
,
x500CertDN
,
typeValue
);
typeX500DN
.
InvokeMember
(
"Encode"
,
BindingFlags
.
InvokeMethod
,
null
,
x500CertDN
,
typeValue
);
var
x500RootCertDN
=
Activator
.
CreateInstance
(
typeX500DN
);
var
x500RootCertDN
=
Activator
.
CreateInstance
(
typeX500DN
);
...
@@ -110,16 +110,16 @@ namespace Titanium.Web.Proxy.Network.Certificate
...
@@ -110,16 +110,16 @@ namespace Titanium.Web.Proxy.Network.Certificate
if
(
sharedPrivateKey
==
null
)
if
(
sharedPrivateKey
==
null
)
{
{
sharedPrivateKey
=
Activator
.
CreateInstance
(
typeX509PrivateKey
);
sharedPrivateKey
=
Activator
.
CreateInstance
(
typeX509PrivateKey
);
typeValue
=
new
object
[]
{
sProviderName
};
typeValue
=
new
object
[]
{
sProviderName
};
typeX509PrivateKey
.
InvokeMember
(
"ProviderName"
,
BindingFlags
.
PutDispProperty
,
null
,
sharedPrivateKey
,
typeValue
);
typeX509PrivateKey
.
InvokeMember
(
"ProviderName"
,
BindingFlags
.
PutDispProperty
,
null
,
sharedPrivateKey
,
typeValue
);
typeValue
[
0
]
=
2
;
typeValue
[
0
]
=
2
;
typeX509PrivateKey
.
InvokeMember
(
"ExportPolicy"
,
BindingFlags
.
PutDispProperty
,
null
,
sharedPrivateKey
,
typeValue
);
typeX509PrivateKey
.
InvokeMember
(
"ExportPolicy"
,
BindingFlags
.
PutDispProperty
,
null
,
sharedPrivateKey
,
typeValue
);
typeValue
=
new
object
[]
{
isRoot
?
2
:
1
};
typeValue
=
new
object
[]
{
isRoot
?
2
:
1
};
typeX509PrivateKey
.
InvokeMember
(
"KeySpec"
,
BindingFlags
.
PutDispProperty
,
null
,
sharedPrivateKey
,
typeValue
);
typeX509PrivateKey
.
InvokeMember
(
"KeySpec"
,
BindingFlags
.
PutDispProperty
,
null
,
sharedPrivateKey
,
typeValue
);
if
(!
isRoot
)
if
(!
isRoot
)
{
{
typeValue
=
new
object
[]
{
176
};
typeValue
=
new
object
[]
{
176
};
typeX509PrivateKey
.
InvokeMember
(
"KeyUsage"
,
BindingFlags
.
PutDispProperty
,
null
,
sharedPrivateKey
,
typeValue
);
typeX509PrivateKey
.
InvokeMember
(
"KeyUsage"
,
BindingFlags
.
PutDispProperty
,
null
,
sharedPrivateKey
,
typeValue
);
}
}
...
@@ -149,9 +149,9 @@ namespace Titanium.Web.Proxy.Network.Certificate
...
@@ -149,9 +149,9 @@ namespace Titanium.Web.Proxy.Network.Certificate
var
requestCert
=
Activator
.
CreateInstance
(
typeRequestCert
);
var
requestCert
=
Activator
.
CreateInstance
(
typeRequestCert
);
typeValue
=
new
[]
{
1
,
sharedPrivateKey
,
string
.
Empty
};
typeValue
=
new
[]
{
1
,
sharedPrivateKey
,
string
.
Empty
};
typeRequestCert
.
InvokeMember
(
"InitializeFromPrivateKey"
,
BindingFlags
.
InvokeMethod
,
null
,
requestCert
,
typeValue
);
typeRequestCert
.
InvokeMember
(
"InitializeFromPrivateKey"
,
BindingFlags
.
InvokeMethod
,
null
,
requestCert
,
typeValue
);
typeValue
=
new
[]
{
x500CertDN
};
typeValue
=
new
[]
{
x500CertDN
};
typeRequestCert
.
InvokeMember
(
"Subject"
,
BindingFlags
.
PutDispProperty
,
null
,
requestCert
,
typeValue
);
typeRequestCert
.
InvokeMember
(
"Subject"
,
BindingFlags
.
PutDispProperty
,
null
,
requestCert
,
typeValue
);
typeValue
[
0
]
=
x500RootCertDN
;
typeValue
[
0
]
=
x500RootCertDN
;
typeRequestCert
.
InvokeMember
(
"Issuer"
,
BindingFlags
.
PutDispProperty
,
null
,
requestCert
,
typeValue
);
typeRequestCert
.
InvokeMember
(
"Issuer"
,
BindingFlags
.
PutDispProperty
,
null
,
requestCert
,
typeValue
);
...
@@ -186,14 +186,14 @@ namespace Titanium.Web.Proxy.Network.Certificate
...
@@ -186,14 +186,14 @@ namespace Titanium.Web.Proxy.Network.Certificate
var
extNames
=
Activator
.
CreateInstance
(
typeExtNames
);
var
extNames
=
Activator
.
CreateInstance
(
typeExtNames
);
var
altDnsNames
=
Activator
.
CreateInstance
(
typeCAlternativeName
);
var
altDnsNames
=
Activator
.
CreateInstance
(
typeCAlternativeName
);
typeValue
=
new
object
[]
{
3
,
subject
};
typeValue
=
new
object
[]
{
3
,
subject
};
typeCAlternativeName
.
InvokeMember
(
"InitializeFromString"
,
BindingFlags
.
InvokeMethod
,
null
,
altDnsNames
,
typeValue
);
typeCAlternativeName
.
InvokeMember
(
"InitializeFromString"
,
BindingFlags
.
InvokeMethod
,
null
,
altDnsNames
,
typeValue
);
typeValue
=
new
[]
{
altDnsNames
};
typeValue
=
new
[]
{
altDnsNames
};
typeAltNamesCollection
.
InvokeMember
(
"Add"
,
BindingFlags
.
InvokeMethod
,
null
,
altNameCollection
,
typeValue
);
typeAltNamesCollection
.
InvokeMember
(
"Add"
,
BindingFlags
.
InvokeMethod
,
null
,
altNameCollection
,
typeValue
);
typeValue
=
new
[]
{
altNameCollection
};
typeValue
=
new
[]
{
altNameCollection
};
typeExtNames
.
InvokeMember
(
"InitializeEncode"
,
BindingFlags
.
InvokeMethod
,
null
,
extNames
,
typeValue
);
typeExtNames
.
InvokeMember
(
"InitializeEncode"
,
BindingFlags
.
InvokeMethod
,
null
,
extNames
,
typeValue
);
typeValue
[
0
]
=
extNames
;
typeValue
[
0
]
=
extNames
;
...
@@ -204,27 +204,27 @@ namespace Titanium.Web.Proxy.Network.Certificate
...
@@ -204,27 +204,27 @@ namespace Titanium.Web.Proxy.Network.Certificate
{
{
var
signerCertificate
=
Activator
.
CreateInstance
(
typeSignerCertificate
);
var
signerCertificate
=
Activator
.
CreateInstance
(
typeSignerCertificate
);
typeValue
=
new
object
[]
{
0
,
0
,
12
,
signingCertificate
.
Thumbprint
};
typeValue
=
new
object
[]
{
0
,
0
,
12
,
signingCertificate
.
Thumbprint
};
typeSignerCertificate
.
InvokeMember
(
"Initialize"
,
BindingFlags
.
InvokeMethod
,
null
,
signerCertificate
,
typeValue
);
typeSignerCertificate
.
InvokeMember
(
"Initialize"
,
BindingFlags
.
InvokeMethod
,
null
,
signerCertificate
,
typeValue
);
typeValue
=
new
[]
{
signerCertificate
};
typeValue
=
new
[]
{
signerCertificate
};
typeRequestCert
.
InvokeMember
(
"SignerCertificate"
,
BindingFlags
.
PutDispProperty
,
null
,
requestCert
,
typeValue
);
typeRequestCert
.
InvokeMember
(
"SignerCertificate"
,
BindingFlags
.
PutDispProperty
,
null
,
requestCert
,
typeValue
);
}
}
else
else
{
{
var
basicConstraints
=
Activator
.
CreateInstance
(
typeBasicConstraints
);
var
basicConstraints
=
Activator
.
CreateInstance
(
typeBasicConstraints
);
typeValue
=
new
object
[]
{
"true"
,
"0"
};
typeValue
=
new
object
[]
{
"true"
,
"0"
};
typeBasicConstraints
.
InvokeMember
(
"InitializeEncode"
,
BindingFlags
.
InvokeMethod
,
null
,
basicConstraints
,
typeValue
);
typeBasicConstraints
.
InvokeMember
(
"InitializeEncode"
,
BindingFlags
.
InvokeMethod
,
null
,
basicConstraints
,
typeValue
);
typeValue
=
new
[]
{
basicConstraints
};
typeValue
=
new
[]
{
basicConstraints
};
typeX509Extensions
.
InvokeMember
(
"Add"
,
BindingFlags
.
InvokeMethod
,
null
,
certificate
,
typeValue
);
typeX509Extensions
.
InvokeMember
(
"Add"
,
BindingFlags
.
InvokeMethod
,
null
,
certificate
,
typeValue
);
}
}
oid
=
Activator
.
CreateInstance
(
typeOID
);
oid
=
Activator
.
CreateInstance
(
typeOID
);
typeValue
=
new
object
[]
{
1
,
0
,
0
,
hashAlg
};
typeValue
=
new
object
[]
{
1
,
0
,
0
,
hashAlg
};
typeOID
.
InvokeMember
(
"InitializeFromAlgorithmName"
,
BindingFlags
.
InvokeMethod
,
null
,
oid
,
typeValue
);
typeOID
.
InvokeMember
(
"InitializeFromAlgorithmName"
,
BindingFlags
.
InvokeMethod
,
null
,
oid
,
typeValue
);
typeValue
=
new
[]
{
oid
};
typeValue
=
new
[]
{
oid
};
typeRequestCert
.
InvokeMember
(
"HashAlgorithm"
,
BindingFlags
.
PutDispProperty
,
null
,
requestCert
,
typeValue
);
typeRequestCert
.
InvokeMember
(
"HashAlgorithm"
,
BindingFlags
.
PutDispProperty
,
null
,
requestCert
,
typeValue
);
typeRequestCert
.
InvokeMember
(
"Encode"
,
BindingFlags
.
InvokeMethod
,
null
,
requestCert
,
null
);
typeRequestCert
.
InvokeMember
(
"Encode"
,
BindingFlags
.
InvokeMethod
,
null
,
requestCert
,
null
);
...
@@ -244,10 +244,10 @@ namespace Titanium.Web.Proxy.Network.Certificate
...
@@ -244,10 +244,10 @@ namespace Titanium.Web.Proxy.Network.Certificate
typeValue
[
0
]
=
0
;
typeValue
[
0
]
=
0
;
var
createCertRequest
=
typeX509Enrollment
.
InvokeMember
(
"CreateRequest"
,
BindingFlags
.
InvokeMethod
,
null
,
x509Enrollment
,
typeValue
);
var
createCertRequest
=
typeX509Enrollment
.
InvokeMember
(
"CreateRequest"
,
BindingFlags
.
InvokeMethod
,
null
,
x509Enrollment
,
typeValue
);
typeValue
=
new
[]
{
2
,
createCertRequest
,
0
,
string
.
Empty
};
typeValue
=
new
[]
{
2
,
createCertRequest
,
0
,
string
.
Empty
};
typeX509Enrollment
.
InvokeMember
(
"InstallResponse"
,
BindingFlags
.
InvokeMethod
,
null
,
x509Enrollment
,
typeValue
);
typeX509Enrollment
.
InvokeMember
(
"InstallResponse"
,
BindingFlags
.
InvokeMethod
,
null
,
x509Enrollment
,
typeValue
);
typeValue
=
new
object
[]
{
null
,
0
,
1
};
typeValue
=
new
object
[]
{
null
,
0
,
1
};
try
try
{
{
...
...
Titanium.Web.Proxy/Network/CertificateManager.cs
View file @
b43e3df2
...
@@ -265,7 +265,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -265,7 +265,7 @@ namespace Titanium.Web.Proxy.Network
}
}
if
(
certificate
!=
null
&&
!
certificateCache
.
ContainsKey
(
certificateName
))
if
(
certificate
!=
null
&&
!
certificateCache
.
ContainsKey
(
certificateName
))
{
{
certificateCache
.
Add
(
certificateName
,
new
CachedCertificate
{
Certificate
=
certificate
});
certificateCache
.
Add
(
certificateName
,
new
CachedCertificate
{
Certificate
=
certificate
});
}
}
}
}
else
else
...
...
Titanium.Web.Proxy/Network/Tcp/TcpConnection.cs
View file @
b43e3df2
...
@@ -70,7 +70,9 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -70,7 +70,9 @@ namespace Titanium.Web.Proxy.Network.Tcp
TcpClient
.
Close
();
TcpClient
.
Close
();
}
}
}
}
catch
{
}
catch
{
}
}
}
}
}
}
}
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
b43e3df2
...
@@ -55,7 +55,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -55,7 +55,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
await
client
.
ConnectAsync
(
externalHttpsProxy
.
HostName
,
externalHttpsProxy
.
Port
);
await
client
.
ConnectAsync
(
externalHttpsProxy
.
HostName
,
externalHttpsProxy
.
Port
);
stream
=
new
CustomBufferedStream
(
client
.
GetStream
(),
server
.
BufferSize
);
stream
=
new
CustomBufferedStream
(
client
.
GetStream
(),
server
.
BufferSize
);
using
(
var
writer
=
new
StreamWriter
(
stream
,
Encoding
.
ASCII
,
server
.
BufferSize
,
true
)
{
NewLine
=
ProxyConstants
.
NewLine
})
using
(
var
writer
=
new
StreamWriter
(
stream
,
Encoding
.
ASCII
,
server
.
BufferSize
,
true
)
{
NewLine
=
ProxyConstants
.
NewLine
})
{
{
await
writer
.
WriteLineAsync
(
$"CONNECT
{
remoteHostName
}
:
{
remotePort
}
HTTP/
{
httpVersion
}
"
);
await
writer
.
WriteLineAsync
(
$"CONNECT
{
remoteHostName
}
:
{
remotePort
}
HTTP/
{
httpVersion
}
"
);
await
writer
.
WriteLineAsync
(
$"Host:
{
remoteHostName
}
:
{
remotePort
}
"
);
await
writer
.
WriteLineAsync
(
$"Host:
{
remoteHostName
}
:
{
remotePort
}
"
);
...
@@ -75,7 +75,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -75,7 +75,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
{
{
var
result
=
await
reader
.
ReadLineAsync
();
var
result
=
await
reader
.
ReadLineAsync
();
if
(!
new
[]
{
"200 OK"
,
"connection established"
}.
Any
(
s
=>
result
.
ContainsIgnoreCase
(
s
)))
if
(!
new
[]
{
"200 OK"
,
"connection established"
}.
Any
(
s
=>
result
.
ContainsIgnoreCase
(
s
)))
{
{
throw
new
Exception
(
"Upstream proxy failed to create a secure tunnel"
);
throw
new
Exception
(
"Upstream proxy failed to create a secure tunnel"
);
}
}
...
...
Titanium.Web.Proxy/ProxyAuthorizationHandler.cs
View file @
b43e3df2
...
@@ -70,8 +70,8 @@ namespace Titanium.Web.Proxy
...
@@ -70,8 +70,8 @@ namespace Titanium.Web.Proxy
{
{
ResponseHeaders
=
new
Dictionary
<
string
,
HttpHeader
>
ResponseHeaders
=
new
Dictionary
<
string
,
HttpHeader
>
{
{
{
"Proxy-Authenticate"
,
new
HttpHeader
(
"Proxy-Authenticate"
,
"Basic realm=\"TitaniumProxy\""
)
},
{
"Proxy-Authenticate"
,
new
HttpHeader
(
"Proxy-Authenticate"
,
"Basic realm=\"TitaniumProxy\""
)
},
{
"Proxy-Connection"
,
new
HttpHeader
(
"Proxy-Connection"
,
"close"
)
}
{
"Proxy-Connection"
,
new
HttpHeader
(
"Proxy-Connection"
,
"close"
)
}
}
}
};
};
await
WriteResponseHeaders
(
clientStreamWriter
,
response
);
await
WriteResponseHeaders
(
clientStreamWriter
,
response
);
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
b43e3df2
...
@@ -627,7 +627,9 @@ namespace Titanium.Web.Proxy
...
@@ -627,7 +627,9 @@ namespace Titanium.Web.Proxy
tcpClient
.
Close
();
tcpClient
.
Close
();
}
}
}
}
catch
{
}
catch
{
}
}
}
});
});
}
}
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
b43e3df2
...
@@ -165,7 +165,6 @@ namespace Titanium.Web.Proxy
...
@@ -165,7 +165,6 @@ namespace Titanium.Web.Proxy
{
{
Dispose
(
clientStream
,
clientStreamReader
,
clientStreamWriter
,
null
);
Dispose
(
clientStream
,
clientStreamReader
,
clientStreamWriter
,
null
);
}
}
}
}
}
}
...
@@ -224,7 +223,7 @@ namespace Titanium.Web.Proxy
...
@@ -224,7 +223,7 @@ namespace Titanium.Web.Proxy
//Now create the request
//Now create the request
disposed
=
await
HandleHttpSessionRequest
(
tcpClient
,
httpCmd
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
disposed
=
await
HandleHttpSessionRequest
(
tcpClient
,
httpCmd
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
endPoint
.
EnableSsl
?
endPoint
.
GenericCertificateName
:
null
,
endPoint
,
null
);
endPoint
.
EnableSsl
?
endPoint
.
GenericCertificateName
:
null
,
endPoint
,
null
);
if
(!
disposed
)
if
(!
disposed
)
{
{
...
...
Titanium.Web.Proxy/ResponseHandler.cs
View file @
b43e3df2
...
@@ -244,7 +244,6 @@ namespace Titanium.Web.Proxy
...
@@ -244,7 +244,6 @@ namespace Titanium.Web.Proxy
serverConnection
.
Dispose
();
serverConnection
.
Dispose
();
Interlocked
.
Decrement
(
ref
ServerConnectionCountField
);
Interlocked
.
Decrement
(
ref
ServerConnectionCountField
);
}
}
}
}
}
}
}
}
Titanium.Web.Proxy/Shared/ProxyConstants.cs
View file @
b43e3df2
...
@@ -7,9 +7,9 @@ namespace Titanium.Web.Proxy.Shared
...
@@ -7,9 +7,9 @@ namespace Titanium.Web.Proxy.Shared
/// </summary>
/// </summary>
internal
class
ProxyConstants
internal
class
ProxyConstants
{
{
internal
static
readonly
char
[]
SpaceSplit
=
{
' '
};
internal
static
readonly
char
[]
SpaceSplit
=
{
' '
};
internal
static
readonly
char
[]
ColonSplit
=
{
':'
};
internal
static
readonly
char
[]
ColonSplit
=
{
':'
};
internal
static
readonly
char
[]
SemiColonSplit
=
{
';'
};
internal
static
readonly
char
[]
SemiColonSplit
=
{
';'
};
internal
static
readonly
byte
[]
NewLineBytes
=
Encoding
.
ASCII
.
GetBytes
(
NewLine
);
internal
static
readonly
byte
[]
NewLineBytes
=
Encoding
.
ASCII
.
GetBytes
(
NewLine
);
...
...
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