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
a0de0080
Commit
a0de0080
authored
Mar 24, 2018
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes 1
parent
f8d876c6
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
46 additions
and
23 deletions
+46
-23
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+32
-15
Titanium.Web.Proxy.Examples.Wpf.csproj
...Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.csproj
+2
-2
packages.config
Examples/Titanium.Web.Proxy.Examples.Wpf/packages.config
+1
-1
SessionEventArgs.cs
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
+7
-2
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+1
-0
Titanium.Web.Proxy.csproj
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
+1
-1
Titanium.Web.Proxy.nuspec
Titanium.Web.Proxy/Titanium.Web.Proxy.nuspec
+1
-1
packages.config
Titanium.Web.Proxy/packages.config
+1
-1
No files found.
Examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
a0de0080
...
...
@@ -5,6 +5,7 @@ using System.Net;
using
System.Net.Security
;
using
System.Threading.Tasks
;
using
Titanium.Web.Proxy.EventArguments
;
using
Titanium.Web.Proxy.Exceptions
;
using
Titanium.Web.Proxy.Helpers
;
using
Titanium.Web.Proxy.Http
;
using
Titanium.Web.Proxy.Models
;
...
...
@@ -35,7 +36,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
//generate root certificate without storing it in file system
//proxyServer.CertificateManager.CreateRootCertificate(false);
//proxyServer.CertificateManager.TrustRootCertificate();
//proxyServer.CertificateManager.TrustRootCertificateAsAdmin();
...
...
@@ -45,7 +46,15 @@ namespace Titanium.Web.Proxy.Examples.Basic
{
var
color
=
Console
.
ForegroundColor
;
Console
.
ForegroundColor
=
ConsoleColor
.
Red
;
Console
.
WriteLine
(
exception
.
Message
);
if
(
exception
is
ProxyHttpException
phex
)
{
Console
.
WriteLine
(
exception
.
Message
+
": "
+
phex
.
InnerException
?.
Message
);
}
else
{
Console
.
WriteLine
(
exception
.
Message
);
}
Console
.
ForegroundColor
=
color
;
}
};
...
...
@@ -63,7 +72,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
{
proxyServer
.
BeforeRequest
+=
OnRequest
;
proxyServer
.
BeforeResponse
+=
OnResponse
;
proxyServer
.
ServerCertificateValidationCallback
+=
OnCertificateValidation
;
proxyServer
.
ClientCertificateSelectionCallback
+=
OnCertificateSelection
;
...
...
@@ -71,12 +80,12 @@ namespace Titanium.Web.Proxy.Examples.Basic
explicitEndPoint
=
new
ExplicitProxyEndPoint
(
IPAddress
.
Any
,
8000
,
true
)
{
//You can set only one of the ExcludedHttpsHostNameRegex and IncludedHttpsHostNameRegex properties, otherwise ArgumentException will be thrown
//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
//GenericCertificate = new X509Certificate2(Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "genericcert.pfx"), "password")
//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
//GenericCertificate = new X509Certificate2(Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "genericcert.pfx"), "password")
};
//Fired when a CONNECT request is received
...
...
@@ -136,7 +145,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
private
async
Task
OnBeforeTunnelConnectRequest
(
object
sender
,
TunnelConnectSessionEventArgs
e
)
{
string
hostname
=
e
.
WebSession
.
Request
.
RequestUri
.
Host
;
Console
.
WriteLin
e
(
"Tunnel to: "
+
hostname
);
WriteToConsol
e
(
"Tunnel to: "
+
hostname
);
if
(
hostname
.
Contains
(
"dropbox.com"
))
{
...
...
@@ -154,8 +163,8 @@ namespace Titanium.Web.Proxy.Examples.Basic
//intecept & cancel redirect or update requests
private
async
Task
OnRequest
(
object
sender
,
SessionEventArgs
e
)
{
Console
.
WriteLin
e
(
"Active Client Connections:"
+
((
ProxyServer
)
sender
).
ClientConnectionCount
);
Console
.
WriteLin
e
(
e
.
WebSession
.
Request
.
Url
);
WriteToConsol
e
(
"Active Client Connections:"
+
((
ProxyServer
)
sender
).
ClientConnectionCount
);
WriteToConsol
e
(
e
.
WebSession
.
Request
.
Url
);
//read request headers
requestHeaderHistory
[
e
.
Id
]
=
e
.
WebSession
.
Request
.
Headers
;
...
...
@@ -203,16 +212,16 @@ namespace Titanium.Web.Proxy.Examples.Basic
private
void
MultipartRequestPartSent
(
object
sender
,
MultipartRequestPartSentEventArgs
e
)
{
var
session
=
(
SessionEventArgs
)
sender
;
Console
.
WriteLin
e
(
"Multipart form data headers:"
);
WriteToConsol
e
(
"Multipart form data headers:"
);
foreach
(
var
header
in
e
.
Headers
)
{
Console
.
WriteLine
(
header
);
WriteToConsole
(
header
.
ToString
()
);
}
}
private
async
Task
OnResponse
(
object
sender
,
SessionEventArgs
e
)
{
Console
.
WriteLin
e
(
"Active Server Connections:"
+
((
ProxyServer
)
sender
).
ServerConnectionCount
);
WriteToConsol
e
(
"Active Server Connections:"
+
((
ProxyServer
)
sender
).
ServerConnectionCount
);
//if (requestBodyHistory.ContainsKey(e.Id))
//{
...
...
@@ -224,7 +233,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
//responseHeaderHistory[e.Id] = e.WebSession.Response.Headers;
//// print out process id of current session
////
Console.WriteLin
e($"PID: {e.WebSession.ProcessId.Value}");
////
WriteToConsol
e($"PID: {e.WebSession.ProcessId.Value}");
////if (!e.ProxySession.Request.Host.Equals("medeczane.sgk.gov.tr")) return;
//if (e.WebSession.Request.Method == "GET" || e.WebSession.Request.Method == "POST")
...
...
@@ -270,5 +279,13 @@ namespace Titanium.Web.Proxy.Examples.Basic
return
Task
.
FromResult
(
0
);
}
private
void
WriteToConsole
(
string
message
)
{
lock
(
lockObj
)
{
Console
.
WriteLine
(
message
);
}
}
}
}
Examples/Titanium.Web.Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.csproj
View file @
a0de0080
...
...
@@ -51,8 +51,8 @@
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"StreamExtended, Version=1.0.1
38
.0, Culture=neutral, PublicKeyToken=bbfa0f1d54f50043, processorArchitecture=MSIL"
>
<HintPath>
..\..\packages\StreamExtended.1.0.1
38
-beta\lib\net45\StreamExtended.dll
</HintPath>
<Reference
Include=
"StreamExtended, Version=1.0.1
41
.0, Culture=neutral, PublicKeyToken=bbfa0f1d54f50043, processorArchitecture=MSIL"
>
<HintPath>
..\..\packages\StreamExtended.1.0.1
41
-beta\lib\net45\StreamExtended.dll
</HintPath>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Data"
/>
...
...
Examples/Titanium.Web.Proxy.Examples.Wpf/packages.config
View file @
a0de0080
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"StreamExtended"
version
=
"1.0.1
38
-beta"
targetFramework
=
"net45"
/>
<
package
id
=
"StreamExtended"
version
=
"1.0.1
41
-beta"
targetFramework
=
"net45"
/>
</
packages
>
\ No newline at end of file
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
View file @
a0de0080
...
...
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using
System.Globalization
;
using
System.IO
;
using
System.Net
;
using
System.Reflection
;
using
System.Threading.Tasks
;
using
StreamExtended.Helpers
;
using
StreamExtended.Network
;
...
...
@@ -325,7 +326,7 @@ namespace Titanium.Web.Proxy.EventArguments
{
if
(
newReader
)
{
var
bufStream
=
new
CustomBufferedStream
(
s
,
bufferSize
);
var
bufStream
=
new
CustomBufferedStream
(
s
,
bufferSize
,
true
);
s
=
bufStream
;
reader
=
new
CustomBinaryReader
(
bufStream
,
bufferSize
);
}
...
...
@@ -337,7 +338,11 @@ namespace Titanium.Web.Proxy.EventArguments
if
(
newReader
)
{
reader
?.
Dispose
();
decompressStream
?.
Dispose
();
if
(
decompressStream
!=
null
&&
decompressStream
!=
stream
)
{
decompressStream
.
Dispose
();
}
if
(
chunkedStream
!=
null
)
{
await
chunkedStream
.
Finish
();
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
a0de0080
...
...
@@ -465,6 +465,7 @@ namespace Titanium.Web.Proxy
catch
(
Exception
e
)
{
args
.
Exception
=
e
;
throw
e
;
}
finally
{
...
...
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
View file @
a0de0080
...
...
@@ -13,7 +13,7 @@
<ItemGroup>
<PackageReference Include="Portable.BouncyCastle" Version="1.8.1.4" />
<PackageReference Include="StreamExtended" Version="1.0.1
38
-beta" />
<PackageReference Include="StreamExtended" Version="1.0.1
41
-beta" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
...
...
Titanium.Web.Proxy/Titanium.Web.Proxy.nuspec
View file @
a0de0080
...
...
@@ -14,7 +14,7 @@
<copyright>
Copyright
©
Titanium. All rights reserved.
</copyright>
<tags></tags>
<dependencies>
<dependency
id=
"StreamExtended"
version=
"1.0.1
38
-beta"
/>
<dependency
id=
"StreamExtended"
version=
"1.0.1
41
-beta"
/>
<dependency
id=
"Portable.BouncyCastle"
version=
"1.8.1.4"
/>
</dependencies>
</metadata>
...
...
Titanium.Web.Proxy/packages.config
View file @
a0de0080
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"Portable.BouncyCastle"
version
=
"1.8.1.4"
targetFramework
=
"net45"
/>
<
package
id
=
"StreamExtended"
version
=
"1.0.1
38
-beta"
targetFramework
=
"net45"
/>
<
package
id
=
"StreamExtended"
version
=
"1.0.1
41
-beta"
targetFramework
=
"net45"
/>
</
packages
>
\ No newline at end of file
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