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
958511de
Commit
958511de
authored
May 07, 2017
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#207 inconsistent naming fixes
parent
196bf663
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
42 deletions
+43
-42
EndPoint.cs
Titanium.Web.Proxy/Models/EndPoint.cs
+18
-18
CertificateManager.cs
Titanium.Web.Proxy/Network/CertificateManager.cs
+12
-11
ProxyAuthorizationHandler.cs
Titanium.Web.Proxy/ProxyAuthorizationHandler.cs
+2
-2
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+9
-9
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+2
-2
No files found.
Titanium.Web.Proxy/Models/EndPoint.cs
View file @
958511de
...
@@ -13,14 +13,14 @@ namespace Titanium.Web.Proxy.Models
...
@@ -13,14 +13,14 @@ namespace Titanium.Web.Proxy.Models
/// <summary>
/// <summary>
/// Constructor.
/// Constructor.
/// </summary>
/// </summary>
/// <param name="
I
pAddress"></param>
/// <param name="
i
pAddress"></param>
/// <param name="
P
ort"></param>
/// <param name="
p
ort"></param>
/// <param name="
E
nableSsl"></param>
/// <param name="
e
nableSsl"></param>
protected
ProxyEndPoint
(
IPAddress
IpAddress
,
int
Port
,
bool
E
nableSsl
)
protected
ProxyEndPoint
(
IPAddress
ipAddress
,
int
port
,
bool
e
nableSsl
)
{
{
this
.
IpAddress
=
I
pAddress
;
this
.
IpAddress
=
i
pAddress
;
this
.
Port
=
P
ort
;
this
.
Port
=
p
ort
;
this
.
EnableSsl
=
E
nableSsl
;
this
.
EnableSsl
=
e
nableSsl
;
}
}
/// <summary>
/// <summary>
...
@@ -43,7 +43,7 @@ namespace Titanium.Web.Proxy.Models
...
@@ -43,7 +43,7 @@ namespace Titanium.Web.Proxy.Models
||
Equals
(
IpAddress
,
IPAddress
.
IPv6Loopback
)
||
Equals
(
IpAddress
,
IPAddress
.
IPv6Loopback
)
||
Equals
(
IpAddress
,
IPAddress
.
IPv6None
);
||
Equals
(
IpAddress
,
IPAddress
.
IPv6None
);
internal
TcpListener
l
istener
{
get
;
set
;
}
internal
TcpListener
L
istener
{
get
;
set
;
}
}
}
/// <summary>
/// <summary>
...
@@ -68,11 +68,11 @@ namespace Titanium.Web.Proxy.Models
...
@@ -68,11 +68,11 @@ namespace Titanium.Web.Proxy.Models
/// <summary>
/// <summary>
/// Constructor.
/// Constructor.
/// </summary>
/// </summary>
/// <param name="
I
pAddress"></param>
/// <param name="
i
pAddress"></param>
/// <param name="
P
ort"></param>
/// <param name="
p
ort"></param>
/// <param name="
E
nableSsl"></param>
/// <param name="
e
nableSsl"></param>
public
ExplicitProxyEndPoint
(
IPAddress
IpAddress
,
int
Port
,
bool
E
nableSsl
)
public
ExplicitProxyEndPoint
(
IPAddress
ipAddress
,
int
port
,
bool
e
nableSsl
)
:
base
(
IpAddress
,
Port
,
E
nableSsl
)
:
base
(
ipAddress
,
port
,
e
nableSsl
)
{
{
}
}
...
@@ -94,11 +94,11 @@ namespace Titanium.Web.Proxy.Models
...
@@ -94,11 +94,11 @@ namespace Titanium.Web.Proxy.Models
/// <summary>
/// <summary>
/// Constructor.
/// Constructor.
/// </summary>
/// </summary>
/// <param name="
I
pAddress"></param>
/// <param name="
i
pAddress"></param>
/// <param name="
P
ort"></param>
/// <param name="
p
ort"></param>
/// <param name="
E
nableSsl"></param>
/// <param name="
e
nableSsl"></param>
public
TransparentProxyEndPoint
(
IPAddress
IpAddress
,
int
Port
,
bool
E
nableSsl
)
public
TransparentProxyEndPoint
(
IPAddress
ipAddress
,
int
port
,
bool
e
nableSsl
)
:
base
(
IpAddress
,
Port
,
E
nableSsl
)
:
base
(
ipAddress
,
port
,
e
nableSsl
)
{
{
this
.
GenericCertificateName
=
"localhost"
;
this
.
GenericCertificateName
=
"localhost"
;
}
}
...
...
Titanium.Web.Proxy/Network/CertificateManager.cs
View file @
958511de
...
@@ -43,9 +43,10 @@ namespace Titanium.Web.Proxy.Network
...
@@ -43,9 +43,10 @@ namespace Titanium.Web.Proxy.Network
private
readonly
Action
<
Exception
>
exceptionFunc
;
private
readonly
Action
<
Exception
>
exceptionFunc
;
internal
string
Issuer
{
get
;
}
internal
string
Issuer
{
get
;
}
internal
string
RootCertificateName
{
get
;
}
internal
string
RootCertificateName
{
get
;
}
internal
X509Certificate2
r
ootCertificate
{
get
;
set
;
}
internal
X509Certificate2
R
ootCertificate
{
get
;
set
;
}
internal
CertificateManager
(
CertificateEngine
engine
,
internal
CertificateManager
(
CertificateEngine
engine
,
string
issuer
,
string
issuer
,
...
@@ -107,32 +108,32 @@ namespace Titanium.Web.Proxy.Network
...
@@ -107,32 +108,32 @@ namespace Titanium.Web.Proxy.Network
/// <returns>true if succeeded, else false</returns>
/// <returns>true if succeeded, else false</returns>
internal
bool
CreateTrustedRootCertificate
()
internal
bool
CreateTrustedRootCertificate
()
{
{
r
ootCertificate
=
GetRootCertificate
();
R
ootCertificate
=
GetRootCertificate
();
if
(
r
ootCertificate
!=
null
)
if
(
R
ootCertificate
!=
null
)
{
{
return
true
;
return
true
;
}
}
try
try
{
{
r
ootCertificate
=
CreateCertificate
(
RootCertificateName
,
true
);
R
ootCertificate
=
CreateCertificate
(
RootCertificateName
,
true
);
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
{
exceptionFunc
(
e
);
exceptionFunc
(
e
);
}
}
if
(
r
ootCertificate
!=
null
)
if
(
R
ootCertificate
!=
null
)
{
{
try
try
{
{
var
fileName
=
GetRootCertificatePath
();
var
fileName
=
GetRootCertificatePath
();
File
.
WriteAllBytes
(
fileName
,
r
ootCertificate
.
Export
(
X509ContentType
.
Pkcs12
));
File
.
WriteAllBytes
(
fileName
,
R
ootCertificate
.
Export
(
X509ContentType
.
Pkcs12
));
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
{
exceptionFunc
(
e
);
exceptionFunc
(
e
);
}
}
}
}
return
r
ootCertificate
!=
null
;
return
R
ootCertificate
!=
null
;
}
}
/// <summary>
/// <summary>
...
@@ -159,7 +160,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -159,7 +160,7 @@ namespace Titanium.Web.Proxy.Network
{
{
try
try
{
{
certificate
=
certEngine
.
MakeCertificate
(
certificateName
,
isRootCertificate
,
r
ootCertificate
);
certificate
=
certEngine
.
MakeCertificate
(
certificateName
,
isRootCertificate
,
R
ootCertificate
);
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
{
...
@@ -226,7 +227,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -226,7 +227,7 @@ namespace Titanium.Web.Proxy.Network
internal
void
TrustRootCertificate
(
StoreLocation
storeLocation
,
internal
void
TrustRootCertificate
(
StoreLocation
storeLocation
,
Action
<
Exception
>
exceptionFunc
)
Action
<
Exception
>
exceptionFunc
)
{
{
if
(
r
ootCertificate
==
null
)
if
(
R
ootCertificate
==
null
)
{
{
exceptionFunc
(
exceptionFunc
(
new
Exception
(
"Could not set root certificate"
new
Exception
(
"Could not set root certificate"
...
@@ -243,8 +244,8 @@ namespace Titanium.Web.Proxy.Network
...
@@ -243,8 +244,8 @@ namespace Titanium.Web.Proxy.Network
x509RootStore
.
Open
(
OpenFlags
.
ReadWrite
);
x509RootStore
.
Open
(
OpenFlags
.
ReadWrite
);
x509PersonalStore
.
Open
(
OpenFlags
.
ReadWrite
);
x509PersonalStore
.
Open
(
OpenFlags
.
ReadWrite
);
x509RootStore
.
Add
(
r
ootCertificate
);
x509RootStore
.
Add
(
R
ootCertificate
);
x509PersonalStore
.
Add
(
r
ootCertificate
);
x509PersonalStore
.
Add
(
R
ootCertificate
);
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
{
...
...
Titanium.Web.Proxy/ProxyAuthorizationHandler.cs
View file @
958511de
...
@@ -13,14 +13,14 @@ namespace Titanium.Web.Proxy
...
@@ -13,14 +13,14 @@ namespace Titanium.Web.Proxy
public
partial
class
ProxyServer
public
partial
class
ProxyServer
{
{
private
async
Task
<
bool
>
CheckAuthorization
(
StreamWriter
clientStreamWriter
,
IEnumerable
<
HttpHeader
>
H
eaders
)
private
async
Task
<
bool
>
CheckAuthorization
(
StreamWriter
clientStreamWriter
,
IEnumerable
<
HttpHeader
>
h
eaders
)
{
{
if
(
AuthenticateUserFunc
==
null
)
if
(
AuthenticateUserFunc
==
null
)
{
{
return
true
;
return
true
;
}
}
var
httpHeaders
=
Headers
as
HttpHeader
[]
??
H
eaders
.
ToArray
();
var
httpHeaders
=
headers
as
HttpHeader
[]
??
h
eaders
.
ToArray
();
try
try
{
{
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
958511de
...
@@ -491,12 +491,12 @@ namespace Titanium.Web.Proxy
...
@@ -491,12 +491,12 @@ namespace Titanium.Web.Proxy
/// <param name="endPoint"></param>
/// <param name="endPoint"></param>
private
void
Listen
(
ProxyEndPoint
endPoint
)
private
void
Listen
(
ProxyEndPoint
endPoint
)
{
{
endPoint
.
l
istener
=
new
TcpListener
(
endPoint
.
IpAddress
,
endPoint
.
Port
);
endPoint
.
L
istener
=
new
TcpListener
(
endPoint
.
IpAddress
,
endPoint
.
Port
);
endPoint
.
l
istener
.
Start
();
endPoint
.
L
istener
.
Start
();
endPoint
.
Port
=
((
IPEndPoint
)
endPoint
.
l
istener
.
LocalEndpoint
).
Port
;
endPoint
.
Port
=
((
IPEndPoint
)
endPoint
.
L
istener
.
LocalEndpoint
).
Port
;
// accept clients asynchronously
// accept clients asynchronously
endPoint
.
l
istener
.
BeginAcceptTcpClient
(
OnAcceptConnection
,
endPoint
);
endPoint
.
L
istener
.
BeginAcceptTcpClient
(
OnAcceptConnection
,
endPoint
);
}
}
/// <summary>
/// <summary>
...
@@ -505,9 +505,9 @@ namespace Titanium.Web.Proxy
...
@@ -505,9 +505,9 @@ namespace Titanium.Web.Proxy
/// <param name="endPoint"></param>
/// <param name="endPoint"></param>
private
void
QuitListen
(
ProxyEndPoint
endPoint
)
private
void
QuitListen
(
ProxyEndPoint
endPoint
)
{
{
endPoint
.
l
istener
.
Stop
();
endPoint
.
L
istener
.
Stop
();
endPoint
.
l
istener
.
Server
.
Close
();
endPoint
.
L
istener
.
Server
.
Close
();
endPoint
.
l
istener
.
Server
.
Dispose
();
endPoint
.
L
istener
.
Server
.
Dispose
();
}
}
/// <summary>
/// <summary>
...
@@ -541,7 +541,7 @@ namespace Titanium.Web.Proxy
...
@@ -541,7 +541,7 @@ namespace Titanium.Web.Proxy
try
try
{
{
//based on end point type call appropriate request handlers
//based on end point type call appropriate request handlers
tcpClient
=
endPoint
.
l
istener
.
EndAcceptTcpClient
(
asyn
);
tcpClient
=
endPoint
.
L
istener
.
EndAcceptTcpClient
(
asyn
);
}
}
catch
(
ObjectDisposedException
)
catch
(
ObjectDisposedException
)
{
{
...
@@ -595,7 +595,7 @@ namespace Titanium.Web.Proxy
...
@@ -595,7 +595,7 @@ namespace Titanium.Web.Proxy
}
}
// Get the listener that handles the client request.
// Get the listener that handles the client request.
endPoint
.
l
istener
.
BeginAcceptTcpClient
(
OnAcceptConnection
,
endPoint
);
endPoint
.
L
istener
.
BeginAcceptTcpClient
(
OnAcceptConnection
,
endPoint
);
}
}
/// <summary>
/// <summary>
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
958511de
...
@@ -212,7 +212,7 @@ namespace Titanium.Web.Proxy
...
@@ -212,7 +212,7 @@ namespace Titanium.Web.Proxy
endPoint
.
EnableSsl
?
endPoint
.
GenericCertificateName
:
null
,
endPoint
,
null
);
endPoint
.
EnableSsl
?
endPoint
.
GenericCertificateName
:
null
,
endPoint
,
null
);
}
}
private
async
Task
HandleHttpSessionRequestInternal
(
TcpConnection
connection
,
SessionEventArgs
args
,
ExternalProxy
customUpStreamHttpProxy
,
ExternalProxy
customUpStreamHttpsProxy
,
bool
C
loseConnection
)
private
async
Task
HandleHttpSessionRequestInternal
(
TcpConnection
connection
,
SessionEventArgs
args
,
ExternalProxy
customUpStreamHttpProxy
,
ExternalProxy
customUpStreamHttpsProxy
,
bool
c
loseConnection
)
{
{
try
try
{
{
...
@@ -331,7 +331,7 @@ namespace Titanium.Web.Proxy
...
@@ -331,7 +331,7 @@ namespace Titanium.Web.Proxy
return
;
return
;
}
}
if
(
C
loseConnection
)
if
(
c
loseConnection
)
{
{
//dispose
//dispose
connection
?.
Dispose
();
connection
?.
Dispose
();
...
...
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