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
f2988f4a
Commit
f2988f4a
authored
May 07, 2017
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#205 IncludedHttpsHostNameRegex
parent
958511de
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
5 deletions
+54
-5
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+7
-1
EndPoint.cs
Titanium.Web.Proxy/Models/EndPoint.cs
+36
-2
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+11
-2
No files found.
Examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
f2988f4a
...
...
@@ -37,9 +37,15 @@ namespace Titanium.Web.Proxy.Examples.Basic
{
//Exclude Https addresses you don't want to proxy
//Useful for clients that use certificate pinning
//for example dropbox.com
//for example
google.com and
dropbox.com
// ExcludedHttpsHostNameRegex = new List<string>() { "google.com", "dropbox.com" }
//Include Https addresses you want to proxy (others will be excluded)
//for example github.com
// IncludedHttpsHostNameRegex = new List<string>() { "github.com" }
//You can set only one of the ExcludedHttpsHostNameRegex and IncludedHttpsHostNameRegex properties, otherwise ArgumentException will be thrown
//Use self-issued generic certificate on all https requests
//Optimizes performance by not creating a certificate for each https-enabled domain
//Useful when certificate trust is not required by proxy clients
...
...
Titanium.Web.Proxy/Models/EndPoint.cs
View file @
f2988f4a
using
System.Collections.Generic
;
using
System
;
using
System.Collections.Generic
;
using
System.Net
;
using
System.Net.Sockets
;
using
System.Security.Cryptography.X509Certificates
;
...
...
@@ -52,13 +53,46 @@ namespace Titanium.Web.Proxy.Models
/// </summary>
public
class
ExplicitProxyEndPoint
:
ProxyEndPoint
{
private
List
<
string
>
_excludedHttpsHostNameRegex
;
private
List
<
string
>
_includedHttpsHostNameRegex
;
internal
bool
IsSystemHttpProxy
{
get
;
set
;
}
internal
bool
IsSystemHttpsProxy
{
get
;
set
;
}
/// <summary>
/// List of host names to exclude using Regular Expressions.
/// </summary>
public
List
<
string
>
ExcludedHttpsHostNameRegex
{
get
;
set
;
}
public
List
<
string
>
ExcludedHttpsHostNameRegex
{
get
{
return
_excludedHttpsHostNameRegex
;
}
set
{
if
(
IncludedHttpsHostNameRegex
!=
null
)
{
throw
new
ArgumentException
(
"Cannot set excluded when included is set"
);
}
_excludedHttpsHostNameRegex
=
value
;
}
}
/// <summary>
/// List of host names to exclude using Regular Expressions.
/// </summary>
public
List
<
string
>
IncludedHttpsHostNameRegex
{
get
{
return
_includedHttpsHostNameRegex
;
}
set
{
if
(
ExcludedHttpsHostNameRegex
!=
null
)
{
throw
new
ArgumentException
(
"Cannot set included when excluded is set"
);
}
_includedHttpsHostNameRegex
=
value
;
}
}
/// <summary>
/// Generic certificate to use for SSL decryption.
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
f2988f4a
...
...
@@ -72,8 +72,17 @@ namespace Titanium.Web.Proxy
}
//filter out excluded host names
var
excluded
=
endPoint
.
ExcludedHttpsHostNameRegex
!=
null
&&
endPoint
.
ExcludedHttpsHostNameRegex
.
Any
(
x
=>
Regex
.
IsMatch
(
httpRemoteUri
.
Host
,
x
));
bool
excluded
=
false
;
if
(
endPoint
.
ExcludedHttpsHostNameRegex
!=
null
)
{
excluded
=
endPoint
.
ExcludedHttpsHostNameRegex
.
Any
(
x
=>
Regex
.
IsMatch
(
httpRemoteUri
.
Host
,
x
));
}
if
(
endPoint
.
IncludedHttpsHostNameRegex
!=
null
)
{
excluded
=
!
endPoint
.
IncludedHttpsHostNameRegex
.
Any
(
x
=>
Regex
.
IsMatch
(
httpRemoteUri
.
Host
,
x
));
}
List
<
HttpHeader
>
connectRequestHeaders
=
null
;
...
...
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