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
b03f5efb
Commit
b03f5efb
authored
May 16, 2017
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Space within single line array initializer
parent
6c15f3c7
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 @
b03f5efb
...
...
@@ -51,4 +51,4 @@ namespace Titanium.Web.Proxy.Examples.Basic
// Pinvoke
internal
delegate
bool
ConsoleEventDelegate
(
int
eventType
);
}
}
\ No newline at end of file
}
Examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
b03f5efb
...
...
@@ -107,7 +107,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
//intecept & cancel redirect or update requests
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
);
//read request headers
...
...
@@ -150,7 +150,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
//Modify response
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
))
{
...
...
Tests/Titanium.Web.Proxy.UnitTests/CertificateManagerTests.cs
View file @
b03f5efb
...
...
@@ -10,7 +10,7 @@ namespace Titanium.Web.Proxy.UnitTests
public
class
CertificateManagerTests
{
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
();
...
...
@@ -35,16 +35,13 @@ namespace Titanium.Web.Proxy.UnitTests
var
certificate
=
mgr
.
CreateCertificate
(
host
,
false
);
Assert
.
IsNotNull
(
certificate
);
}));
}
}
await
Task
.
WhenAll
(
tasks
.
ToArray
());
mgr
.
StopClearIdleCertificates
();
}
}
}
Titanium.Web.Proxy.sln.DotSettings
View file @
b03f5efb
<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/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: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>
...
...
Titanium.Web.Proxy/Http/HeaderParser.cs
View file @
b03f5efb
...
...
@@ -29,7 +29,7 @@ namespace Titanium.Web.Proxy.Http
{
var
existing
=
headers
[
newHeader
.
Name
];
var
nonUniqueHeaders
=
new
List
<
HttpHeader
>
{
existing
,
newHeader
};
var
nonUniqueHeaders
=
new
List
<
HttpHeader
>
{
existing
,
newHeader
};
nonUniqueResponseHeaders
.
Add
(
newHeader
.
Name
,
nonUniqueHeaders
);
headers
.
Remove
(
newHeader
.
Name
);
...
...
Titanium.Web.Proxy/Network/Certificate/WinCertificateMaker.cs
View file @
b03f5efb
...
...
@@ -89,7 +89,7 @@ namespace Titanium.Web.Proxy.Network.Certificate
}
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
);
var
x500RootCertDN
=
Activator
.
CreateInstance
(
typeX500DN
);
...
...
@@ -110,16 +110,16 @@ namespace Titanium.Web.Proxy.Network.Certificate
if
(
sharedPrivateKey
==
null
)
{
sharedPrivateKey
=
Activator
.
CreateInstance
(
typeX509PrivateKey
);
typeValue
=
new
object
[]
{
sProviderName
};
typeValue
=
new
object
[]
{
sProviderName
};
typeX509PrivateKey
.
InvokeMember
(
"ProviderName"
,
BindingFlags
.
PutDispProperty
,
null
,
sharedPrivateKey
,
typeValue
);
typeValue
[
0
]
=
2
;
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
);
if
(!
isRoot
)
{
typeValue
=
new
object
[]
{
176
};
typeValue
=
new
object
[]
{
176
};
typeX509PrivateKey
.
InvokeMember
(
"KeyUsage"
,
BindingFlags
.
PutDispProperty
,
null
,
sharedPrivateKey
,
typeValue
);
}
...
...
@@ -149,9 +149,9 @@ namespace Titanium.Web.Proxy.Network.Certificate
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
);
typeValue
=
new
[]
{
x500CertDN
};
typeValue
=
new
[]
{
x500CertDN
};
typeRequestCert
.
InvokeMember
(
"Subject"
,
BindingFlags
.
PutDispProperty
,
null
,
requestCert
,
typeValue
);
typeValue
[
0
]
=
x500RootCertDN
;
typeRequestCert
.
InvokeMember
(
"Issuer"
,
BindingFlags
.
PutDispProperty
,
null
,
requestCert
,
typeValue
);
...
...
@@ -186,14 +186,14 @@ namespace Titanium.Web.Proxy.Network.Certificate
var
extNames
=
Activator
.
CreateInstance
(
typeExtNames
);
var
altDnsNames
=
Activator
.
CreateInstance
(
typeCAlternativeName
);
typeValue
=
new
object
[]
{
3
,
subject
};
typeValue
=
new
object
[]
{
3
,
subject
};
typeCAlternativeName
.
InvokeMember
(
"InitializeFromString"
,
BindingFlags
.
InvokeMethod
,
null
,
altDnsNames
,
typeValue
);
typeValue
=
new
[]
{
altDnsNames
};
typeValue
=
new
[]
{
altDnsNames
};
typeAltNamesCollection
.
InvokeMember
(
"Add"
,
BindingFlags
.
InvokeMethod
,
null
,
altNameCollection
,
typeValue
);
typeValue
=
new
[]
{
altNameCollection
};
typeValue
=
new
[]
{
altNameCollection
};
typeExtNames
.
InvokeMember
(
"InitializeEncode"
,
BindingFlags
.
InvokeMethod
,
null
,
extNames
,
typeValue
);
typeValue
[
0
]
=
extNames
;
...
...
@@ -204,27 +204,27 @@ namespace Titanium.Web.Proxy.Network.Certificate
{
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
);
typeValue
=
new
[]
{
signerCertificate
};
typeValue
=
new
[]
{
signerCertificate
};
typeRequestCert
.
InvokeMember
(
"SignerCertificate"
,
BindingFlags
.
PutDispProperty
,
null
,
requestCert
,
typeValue
);
}
else
{
var
basicConstraints
=
Activator
.
CreateInstance
(
typeBasicConstraints
);
typeValue
=
new
object
[]
{
"true"
,
"0"
};
typeValue
=
new
object
[]
{
"true"
,
"0"
};
typeBasicConstraints
.
InvokeMember
(
"InitializeEncode"
,
BindingFlags
.
InvokeMethod
,
null
,
basicConstraints
,
typeValue
);
typeValue
=
new
[]
{
basicConstraints
};
typeValue
=
new
[]
{
basicConstraints
};
typeX509Extensions
.
InvokeMember
(
"Add"
,
BindingFlags
.
InvokeMethod
,
null
,
certificate
,
typeValue
);
}
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
);
typeValue
=
new
[]
{
oid
};
typeValue
=
new
[]
{
oid
};
typeRequestCert
.
InvokeMember
(
"HashAlgorithm"
,
BindingFlags
.
PutDispProperty
,
null
,
requestCert
,
typeValue
);
typeRequestCert
.
InvokeMember
(
"Encode"
,
BindingFlags
.
InvokeMethod
,
null
,
requestCert
,
null
);
...
...
@@ -244,10 +244,10 @@ namespace Titanium.Web.Proxy.Network.Certificate
typeValue
[
0
]
=
0
;
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
);
typeValue
=
new
object
[]
{
null
,
0
,
1
};
typeValue
=
new
object
[]
{
null
,
0
,
1
};
try
{
...
...
Titanium.Web.Proxy/Network/CertificateManager.cs
View file @
b03f5efb
...
...
@@ -265,7 +265,7 @@ namespace Titanium.Web.Proxy.Network
}
if
(
certificate
!=
null
&&
!
certificateCache
.
ContainsKey
(
certificateName
))
{
certificateCache
.
Add
(
certificateName
,
new
CachedCertificate
{
Certificate
=
certificate
});
certificateCache
.
Add
(
certificateName
,
new
CachedCertificate
{
Certificate
=
certificate
});
}
}
else
...
...
Titanium.Web.Proxy/Network/Tcp/TcpConnection.cs
View file @
b03f5efb
...
...
@@ -70,7 +70,9 @@ namespace Titanium.Web.Proxy.Network.Tcp
TcpClient
.
Close
();
}
}
catch
{
}
catch
{
}
}
}
}
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
b03f5efb
...
...
@@ -55,7 +55,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
await
client
.
ConnectAsync
(
externalHttpsProxy
.
HostName
,
externalHttpsProxy
.
Port
);
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
(
$"Host:
{
remoteHostName
}
:
{
remotePort
}
"
);
...
...
@@ -75,7 +75,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
{
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"
);
}
...
...
Titanium.Web.Proxy/ProxyAuthorizationHandler.cs
View file @
b03f5efb
...
...
@@ -70,8 +70,8 @@ namespace Titanium.Web.Proxy
{
ResponseHeaders
=
new
Dictionary
<
string
,
HttpHeader
>
{
{
"Proxy-Authenticate"
,
new
HttpHeader
(
"Proxy-Authenticate"
,
"Basic realm=\"TitaniumProxy\""
)
},
{
"Proxy-Connection"
,
new
HttpHeader
(
"Proxy-Connection"
,
"close"
)
}
{
"Proxy-Authenticate"
,
new
HttpHeader
(
"Proxy-Authenticate"
,
"Basic realm=\"TitaniumProxy\""
)
},
{
"Proxy-Connection"
,
new
HttpHeader
(
"Proxy-Connection"
,
"close"
)
}
}
};
await
WriteResponseHeaders
(
clientStreamWriter
,
response
);
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
b03f5efb
...
...
@@ -627,7 +627,9 @@ namespace Titanium.Web.Proxy
tcpClient
.
Close
();
}
}
catch
{
}
catch
{
}
}
});
}
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
b03f5efb
...
...
@@ -165,7 +165,6 @@ namespace Titanium.Web.Proxy
{
Dispose
(
clientStream
,
clientStreamReader
,
clientStreamWriter
,
null
);
}
}
}
...
...
@@ -224,7 +223,7 @@ namespace Titanium.Web.Proxy
//Now create the request
disposed
=
await
HandleHttpSessionRequest
(
tcpClient
,
httpCmd
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
endPoint
.
EnableSsl
?
endPoint
.
GenericCertificateName
:
null
,
endPoint
,
null
);
endPoint
.
EnableSsl
?
endPoint
.
GenericCertificateName
:
null
,
endPoint
,
null
);
if
(!
disposed
)
{
...
...
Titanium.Web.Proxy/ResponseHandler.cs
View file @
b03f5efb
...
...
@@ -244,7 +244,6 @@ namespace Titanium.Web.Proxy
serverConnection
.
Dispose
();
Interlocked
.
Decrement
(
ref
ServerConnectionCountField
);
}
}
}
}
Titanium.Web.Proxy/Shared/ProxyConstants.cs
View file @
b03f5efb
...
...
@@ -7,9 +7,9 @@ namespace Titanium.Web.Proxy.Shared
/// </summary>
internal
class
ProxyConstants
{
internal
static
readonly
char
[]
SpaceSplit
=
{
' '
};
internal
static
readonly
char
[]
ColonSplit
=
{
':'
};
internal
static
readonly
char
[]
SemiColonSplit
=
{
';'
};
internal
static
readonly
char
[]
SpaceSplit
=
{
' '
};
internal
static
readonly
char
[]
ColonSplit
=
{
':'
};
internal
static
readonly
char
[]
SemiColonSplit
=
{
';'
};
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