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
7840a4b9
Commit
7840a4b9
authored
Apr 14, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup test/example projects
parent
000f3715
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
1307 additions
and
1087 deletions
+1307
-1087
App.config
Examples/Titanium.Web.Proxy.Examples.Basic/App.config
+6
-5
ConsoleHelper.cs
...itanium.Web.Proxy.Examples.Basic/Helpers/ConsoleHelper.cs
+7
-7
AssemblyInfo.cs
...anium.Web.Proxy.Examples.Basic/Properties/AssemblyInfo.cs
+0
-1
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+13
-13
App.config
Examples/Titanium.Web.Proxy.Examples.Wpf/App.config
+6
-5
App.xaml
Examples/Titanium.Web.Proxy.Examples.Wpf/App.xaml
+2
-2
App.xaml.cs
Examples/Titanium.Web.Proxy.Examples.Wpf/App.xaml.cs
+1
-1
MainWindow.xaml
Examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml
+45
-44
MainWindow.xaml.cs
Examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs
+46
-48
Annotations.cs
...Titanium.Web.Proxy.Examples.Wpf/Properties/Annotations.cs
+1151
-941
AssemblyInfo.cs
...itanium.Web.Proxy.Examples.Wpf/Properties/AssemblyInfo.cs
+4
-6
Settings.settings
...anium.Web.Proxy.Examples.Wpf/Properties/Settings.settings
+1
-0
SessionListItem.cs
Examples/Titanium.Web.Proxy.Examples.Wpf/SessionListItem.cs
+6
-7
packages.config
Examples/Titanium.Web.Proxy.Examples.Wpf/packages.config
+1
-0
SslTests.cs
Tests/Titanium.Web.Proxy.IntegrationTests/SslTests.cs
+5
-3
CertificateManagerTests.cs
...s/Titanium.Web.Proxy.UnitTests/CertificateManagerTests.cs
+4
-0
ProxyServerTests.cs
Tests/Titanium.Web.Proxy.UnitTests/ProxyServerTests.cs
+6
-3
SystemProxyTest.cs
Tests/Titanium.Web.Proxy.UnitTests/SystemProxyTest.cs
+3
-1
No files found.
Examples/Titanium.Web.Proxy.Examples.Basic/App.config
View file @
7840a4b9
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
configuration
>
<
configuration
>
<
startup
>
<
startup
>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.5"
/>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.5"
/>
</
startup
>
</
startup
>
</
configuration
>
</
configuration
>
\ No newline at end of file
Examples/Titanium.Web.Proxy.Examples.Basic/Helpers/ConsoleHelper.cs
View file @
7840a4b9
...
@@ -4,24 +4,24 @@ using System.Runtime.InteropServices;
...
@@ -4,24 +4,24 @@ using System.Runtime.InteropServices;
namespace
Titanium.Web.Proxy.Examples.Basic.Helpers
namespace
Titanium.Web.Proxy.Examples.Basic.Helpers
{
{
/// <summary>
/// <summary>
/// Adapated from
///
Adapated from
/// http://stackoverflow.com/questions/13656846/how-to-programmatic-disable-c-sharp-console-applications-quick-edit-mode
///
http://stackoverflow.com/questions/13656846/how-to-programmatic-disable-c-sharp-console-applications-quick-edit-mode
/// </summary>
/// </summary>
internal
static
class
ConsoleHelper
internal
static
class
ConsoleHelper
{
{
const
uint
ENABLE_QUICK_EDIT
=
0x0040
;
private
const
uint
ENABLE_QUICK_EDIT
=
0x0040
;
// STD_INPUT_HANDLE (DWORD): -10 is the standard input device.
// STD_INPUT_HANDLE (DWORD): -10 is the standard input device.
const
int
STD_INPUT_HANDLE
=
-
10
;
private
const
int
STD_INPUT_HANDLE
=
-
10
;
[
DllImport
(
"kernel32.dll"
,
SetLastError
=
true
)]
[
DllImport
(
"kernel32.dll"
,
SetLastError
=
true
)]
static
extern
IntPtr
GetStdHandle
(
int
nStdHandle
);
private
static
extern
IntPtr
GetStdHandle
(
int
nStdHandle
);
[
DllImport
(
"kernel32.dll"
)]
[
DllImport
(
"kernel32.dll"
)]
static
extern
bool
GetConsoleMode
(
IntPtr
hConsoleHandle
,
out
uint
lpMode
);
private
static
extern
bool
GetConsoleMode
(
IntPtr
hConsoleHandle
,
out
uint
lpMode
);
[
DllImport
(
"kernel32.dll"
)]
[
DllImport
(
"kernel32.dll"
)]
static
extern
bool
SetConsoleMode
(
IntPtr
hConsoleHandle
,
uint
dwMode
);
private
static
extern
bool
SetConsoleMode
(
IntPtr
hConsoleHandle
,
uint
dwMode
);
internal
static
bool
DisableQuickEditMode
()
internal
static
bool
DisableQuickEditMode
()
{
{
...
...
Examples/Titanium.Web.Proxy.Examples.Basic/Properties/AssemblyInfo.cs
View file @
7840a4b9
using
System.Reflection
;
using
System.Reflection
;
using
System.Runtime.CompilerServices
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
// General Information about an assembly is controlled through the following
// General Information about an assembly is controlled through the following
...
...
Examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
7840a4b9
...
@@ -17,13 +17,16 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -17,13 +17,16 @@ namespace Titanium.Web.Proxy.Examples.Basic
private
readonly
object
lockObj
=
new
object
();
private
readonly
object
lockObj
=
new
object
();
private
readonly
ProxyServer
proxyServer
;
private
readonly
ProxyServer
proxyServer
;
private
ExplicitProxyEndPoint
explicitEndPoint
;
//keep track of request headers
//keep track of request headers
private
readonly
IDictionary
<
Guid
,
HeaderCollection
>
requestHeaderHistory
=
new
ConcurrentDictionary
<
Guid
,
HeaderCollection
>();
private
readonly
IDictionary
<
Guid
,
HeaderCollection
>
requestHeaderHistory
=
new
ConcurrentDictionary
<
Guid
,
HeaderCollection
>();
//keep track of response headers
//keep track of response headers
private
readonly
IDictionary
<
Guid
,
HeaderCollection
>
responseHeaderHistory
=
new
ConcurrentDictionary
<
Guid
,
HeaderCollection
>();
private
readonly
IDictionary
<
Guid
,
HeaderCollection
>
responseHeaderHistory
=
new
ConcurrentDictionary
<
Guid
,
HeaderCollection
>();
private
ExplicitProxyEndPoint
explicitEndPoint
;
//share requestBody outside handlers
//share requestBody outside handlers
//Using a dictionary is not a good idea since it can cause memory overflow
//Using a dictionary is not a good idea since it can cause memory overflow
...
@@ -78,13 +81,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -78,13 +81,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
//proxyServer.EnableWinAuth = true;
//proxyServer.EnableWinAuth = true;
explicitEndPoint
=
new
ExplicitProxyEndPoint
(
IPAddress
.
Any
,
8000
)
explicitEndPoint
=
new
ExplicitProxyEndPoint
(
IPAddress
.
Any
,
8000
);
{
//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
//Fired when a CONNECT request is received
explicitEndPoint
.
BeforeTunnelConnectRequest
+=
OnBeforeTunnelConnectRequest
;
explicitEndPoint
.
BeforeTunnelConnectRequest
+=
OnBeforeTunnelConnectRequest
;
...
@@ -111,7 +108,10 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -111,7 +108,10 @@ namespace Titanium.Web.Proxy.Examples.Basic
//proxyServer.UpStreamHttpsProxy = new ExternalProxy() { HostName = "localhost", Port = 8888 };
//proxyServer.UpStreamHttpsProxy = new ExternalProxy() { HostName = "localhost", Port = 8888 };
foreach
(
var
endPoint
in
proxyServer
.
ProxyEndPoints
)
foreach
(
var
endPoint
in
proxyServer
.
ProxyEndPoints
)
Console
.
WriteLine
(
"Listening on '{0}' endpoint at Ip {1} and port: {2} "
,
endPoint
.
GetType
().
Name
,
endPoint
.
IpAddress
,
endPoint
.
Port
);
{
Console
.
WriteLine
(
"Listening on '{0}' endpoint at Ip {1} and port: {2} "
,
endPoint
.
GetType
().
Name
,
endPoint
.
IpAddress
,
endPoint
.
Port
);
}
#if NETSTANDARD2_0
#if NETSTANDARD2_0
if
(
RuntimeInformation
.
IsOSPlatform
(
OSPlatform
.
Windows
))
if
(
RuntimeInformation
.
IsOSPlatform
(
OSPlatform
.
Windows
))
...
@@ -251,7 +251,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -251,7 +251,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
}
}
/// <summary>
/// <summary>
/// Allows overriding default certificate validation logic
///
Allows overriding default certificate validation logic
/// </summary>
/// </summary>
/// <param name="sender"></param>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <param name="e"></param>
...
@@ -267,7 +267,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -267,7 +267,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
}
}
/// <summary>
/// <summary>
/// Allows overriding default client certificate selection logic during mutual authentication
///
Allows overriding default client certificate selection logic during mutual authentication
/// </summary>
/// </summary>
/// <param name="sender"></param>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <param name="e"></param>
...
...
Examples/Titanium.Web.Proxy.Examples.Wpf/App.config
View file @
7840a4b9
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
configuration
>
<
configuration
>
<
startup
>
<
startup
>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.5"
/>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.5"
/>
</
startup
>
</
startup
>
</
configuration
>
</
configuration
>
\ No newline at end of file
Examples/Titanium.Web.Proxy.Examples.Wpf/App.xaml
View file @
7840a4b9
...
@@ -4,6 +4,6 @@
...
@@ -4,6 +4,6 @@
xmlns:local="clr-namespace:Titanium.Web.Proxy.Examples.Wpf"
xmlns:local="clr-namespace:Titanium.Web.Proxy.Examples.Wpf"
StartupUri="MainWindow.xaml">
StartupUri="MainWindow.xaml">
<Application.Resources>
<Application.Resources>
</Application.Resources>
</Application.Resources>
</Application>
</Application>
\ No newline at end of file
Examples/Titanium.Web.Proxy.Examples.Wpf/App.xaml.cs
View file @
7840a4b9
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
namespace
Titanium.Web.Proxy.Examples.Wpf
namespace
Titanium.Web.Proxy.Examples.Wpf
{
{
/// <summary>
/// <summary>
/// Interaction logic for App.xaml
///
Interaction logic for App.xaml
/// </summary>
/// </summary>
public
partial
class
App
:
Application
public
partial
class
App
:
Application
{
{
...
...
Examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml
View file @
7840a4b9
...
@@ -6,50 +6,51 @@
...
@@ -6,50 +6,51 @@
xmlns:local="clr-namespace:Titanium.Web.Proxy.Examples.Wpf"
xmlns:local="clr-namespace:Titanium.Web.Proxy.Examples.Wpf"
mc:Ignorable="d"
mc:Ignorable="d"
Title="MainWindow" Height="500" Width="1000" WindowState="Maximized"
Title="MainWindow" Height="500" Width="1000" WindowState="Maximized"
DataContext="{Binding RelativeSource={RelativeSource Self}}">
DataContext="{Binding RelativeSource={RelativeSource Self}}">
<Grid>
<Grid>
<Grid.ColumnDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="500" />
<ColumnDefinition Width="500" />
<ColumnDefinition Width="3" />
<ColumnDefinition Width="3" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
</Grid.RowDefinitions>
<GridSplitter Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" />
<GridSplitter Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" />
<ListView Grid.Column="0" Grid.Row="0" HorizontalAlignment="Stretch" ItemsSource="{Binding Sessions}" SelectedItem="{Binding SelectedSession}"
<ListView Grid.Column="0" Grid.Row="0" HorizontalAlignment="Stretch" ItemsSource="{Binding Sessions}"
KeyDown="ListViewSessions_OnKeyDown">
SelectedItem="{Binding SelectedSession}"
<ListView.View>
KeyDown="ListViewSessions_OnKeyDown">
<GridView>
<ListView.View>
<GridViewColumn Header="Result" DisplayMemberBinding="{Binding StatusCode}" />
<GridView>
<GridViewColumn Header="Protocol" DisplayMemberBinding="{Binding Protocol}" />
<GridViewColumn Header="Result" DisplayMemberBinding="{Binding StatusCode}" />
<GridViewColumn Header="Host" DisplayMemberBinding="{Binding Host}" />
<GridViewColumn Header="Protocol" DisplayMemberBinding="{Binding Protocol}" />
<GridViewColumn Header="Url" DisplayMemberBinding="{Binding Url}" />
<GridViewColumn Header="Host" DisplayMemberBinding="{Binding Host}" />
<GridViewColumn Header="BodySize" DisplayMemberBinding="{Binding BodySize}" />
<GridViewColumn Header="Url" DisplayMemberBinding="{Binding Url}" />
<GridViewColumn Header="Process" DisplayMemberBinding="{Binding Process}" />
<GridViewColumn Header="BodySize" DisplayMemberBinding="{Binding BodySize}" />
<GridViewColumn Header="SentBytes" DisplayMemberBinding="{Binding SentDataCount}" />
<GridViewColumn Header="Process" DisplayMemberBinding="{Binding Process}" />
<GridViewColumn Header="ReceivedBytes" DisplayMemberBinding="{Binding ReceivedDataCount}" />
<GridViewColumn Header="SentBytes" DisplayMemberBinding="{Binding SentDataCount}" />
</GridView>
<GridViewColumn Header="ReceivedBytes" DisplayMemberBinding="{Binding ReceivedDataCount}" />
</ListView.View>
</GridView>
</ListView>
</ListView.View>
<TabControl Grid.Column="2" Grid.Row="0">
</ListView>
<TabItem Header="Session">
<TabControl Grid.Column="2" Grid.Row="0">
<Grid Background="Red" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<TabItem Header="Session">
<Grid.RowDefinitions>
<Grid Background="Red" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<RowDefinition />
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<RowDefinition />
<TextBox x:Name="TextBoxRequest" Grid.Row="0" />
</Grid.RowDefinitions>
<TextBox x:Name="TextBoxResponse" Grid.Row="1" />
<TextBox x:Name="TextBoxRequest" Grid.Row="0" />
</Grid>
<TextBox x:Name="TextBoxResponse" Grid.Row="1" />
</TabItem>
</Grid>
</TabControl>
</TabItem>
<StackPanel Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="3" Orientation="Horizontal">
</TabControl>
<TextBlock Text="ClientConnectionCount:" />
<StackPanel Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="3" Orientation="Horizontal">
<TextBlock Text="{Binding ClientConnectionCount}" Margin="10,0,20,0" />
<TextBlock Text="ClientConnectionCount:" />
<TextBlock Text="ServerConnectionCount:" />
<TextBlock Text="{Binding ClientConnectionCount}" Margin="10,0,20,0" />
<TextBlock Text="{Binding ServerConnectionCount}" Margin="10,0,20,0" />
<TextBlock Text="ServerConnectionCount:" />
</StackPanel>
<TextBlock Text="{Binding ServerConnectionCount}" Margin="10,0,20,0" />
</StackPanel>
</Grid>
</Grid>
</Window>
</Window>
\ No newline at end of file
Examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs
View file @
7840a4b9
...
@@ -16,48 +16,22 @@ using Titanium.Web.Proxy.Models;
...
@@ -16,48 +16,22 @@ using Titanium.Web.Proxy.Models;
namespace
Titanium.Web.Proxy.Examples.Wpf
namespace
Titanium.Web.Proxy.Examples.Wpf
{
{
/// <summary>
/// <summary>
/// Interaction logic for MainWindow.xaml
///
Interaction logic for MainWindow.xaml
/// </summary>
/// </summary>
public
partial
class
MainWindow
:
Window
public
partial
class
MainWindow
:
Window
{
{
private
readonly
ProxyServer
proxyServer
;
private
int
lastSessionNumber
;
public
ObservableCollection
<
SessionListItem
>
Sessions
{
get
;
}
=
new
ObservableCollection
<
SessionListItem
>();
public
SessionListItem
SelectedSession
{
get
=>
selectedSession
;
set
{
if
(
value
!=
selectedSession
)
{
selectedSession
=
value
;
SelectedSessionChanged
();
}
}
}
public
static
readonly
DependencyProperty
ClientConnectionCountProperty
=
DependencyProperty
.
Register
(
public
static
readonly
DependencyProperty
ClientConnectionCountProperty
=
DependencyProperty
.
Register
(
nameof
(
ClientConnectionCount
),
typeof
(
int
),
typeof
(
MainWindow
),
new
PropertyMetadata
(
default
(
int
)));
nameof
(
ClientConnectionCount
),
typeof
(
int
),
typeof
(
MainWindow
),
new
PropertyMetadata
(
default
(
int
)));
public
int
ClientConnectionCount
{
get
=>
(
int
)
GetValue
(
ClientConnectionCountProperty
);
set
=>
SetValue
(
ClientConnectionCountProperty
,
value
);
}
public
static
readonly
DependencyProperty
ServerConnectionCountProperty
=
DependencyProperty
.
Register
(
public
static
readonly
DependencyProperty
ServerConnectionCountProperty
=
DependencyProperty
.
Register
(
nameof
(
ServerConnectionCount
),
typeof
(
int
),
typeof
(
MainWindow
),
new
PropertyMetadata
(
default
(
int
)));
nameof
(
ServerConnectionCount
),
typeof
(
int
),
typeof
(
MainWindow
),
new
PropertyMetadata
(
default
(
int
)));
public
int
ServerConnectionCount
private
readonly
ProxyServer
proxyServer
;
{
get
=>
(
int
)
GetValue
(
ServerConnectionCountProperty
);
private
readonly
Dictionary
<
HttpWebClient
,
SessionListItem
>
sessionDictionary
=
set
=>
SetValue
(
ServerConnectionCountProperty
,
value
);
new
Dictionary
<
HttpWebClient
,
SessionListItem
>();
}
private
readonly
Dictionary
<
HttpWebClient
,
SessionListItem
>
sessionDictionary
=
new
Dictionary
<
HttpWebClient
,
SessionListItem
>()
;
private
int
lastSessionNumber
;
private
SessionListItem
selectedSession
;
private
SessionListItem
selectedSession
;
public
MainWindow
()
public
MainWindow
()
...
@@ -90,7 +64,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -90,7 +64,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
//proxyServer.CertificateManager.LoadRootCertificate(@"C:\NameFolder\rootCert.pfx", "PfxPassword");
//proxyServer.CertificateManager.LoadRootCertificate(@"C:\NameFolder\rootCert.pfx", "PfxPassword");
var
explicitEndPoint
=
new
ExplicitProxyEndPoint
(
IPAddress
.
Any
,
8000
,
true
);
var
explicitEndPoint
=
new
ExplicitProxyEndPoint
(
IPAddress
.
Any
,
8000
,
true
);
proxyServer
.
AddEndPoint
(
explicitEndPoint
);
proxyServer
.
AddEndPoint
(
explicitEndPoint
);
//proxyServer.UpStreamHttpProxy = new ExternalProxy
//proxyServer.UpStreamHttpProxy = new ExternalProxy
//{
//{
...
@@ -105,8 +79,14 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -105,8 +79,14 @@ namespace Titanium.Web.Proxy.Examples.Wpf
proxyServer
.
AfterResponse
+=
ProxyServer_AfterResponse
;
proxyServer
.
AfterResponse
+=
ProxyServer_AfterResponse
;
explicitEndPoint
.
BeforeTunnelConnectRequest
+=
ProxyServer_BeforeTunnelConnectRequest
;
explicitEndPoint
.
BeforeTunnelConnectRequest
+=
ProxyServer_BeforeTunnelConnectRequest
;
explicitEndPoint
.
BeforeTunnelConnectResponse
+=
ProxyServer_BeforeTunnelConnectResponse
;
explicitEndPoint
.
BeforeTunnelConnectResponse
+=
ProxyServer_BeforeTunnelConnectResponse
;
proxyServer
.
ClientConnectionCountChanged
+=
delegate
{
Dispatcher
.
Invoke
(()
=>
{
ClientConnectionCount
=
proxyServer
.
ClientConnectionCount
;
});
};
proxyServer
.
ClientConnectionCountChanged
+=
delegate
proxyServer
.
ServerConnectionCountChanged
+=
delegate
{
Dispatcher
.
Invoke
(()
=>
{
ServerConnectionCount
=
proxyServer
.
ServerConnectionCount
;
});
};
{
Dispatcher
.
Invoke
(()
=>
{
ClientConnectionCount
=
proxyServer
.
ClientConnectionCount
;
});
};
proxyServer
.
ServerConnectionCountChanged
+=
delegate
{
Dispatcher
.
Invoke
(()
=>
{
ServerConnectionCount
=
proxyServer
.
ServerConnectionCount
;
});
};
proxyServer
.
Start
();
proxyServer
.
Start
();
proxyServer
.
SetAsSystemProxy
(
explicitEndPoint
,
ProxyProtocolType
.
AllHttp
);
proxyServer
.
SetAsSystemProxy
(
explicitEndPoint
,
ProxyProtocolType
.
AllHttp
);
...
@@ -114,6 +94,33 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -114,6 +94,33 @@ namespace Titanium.Web.Proxy.Examples.Wpf
InitializeComponent
();
InitializeComponent
();
}
}
public
ObservableCollection
<
SessionListItem
>
Sessions
{
get
;
}
=
new
ObservableCollection
<
SessionListItem
>();
public
SessionListItem
SelectedSession
{
get
=>
selectedSession
;
set
{
if
(
value
!=
selectedSession
)
{
selectedSession
=
value
;
SelectedSessionChanged
();
}
}
}
public
int
ClientConnectionCount
{
get
=>
(
int
)
GetValue
(
ClientConnectionCountProperty
);
set
=>
SetValue
(
ClientConnectionCountProperty
,
value
);
}
public
int
ServerConnectionCount
{
get
=>
(
int
)
GetValue
(
ServerConnectionCountProperty
);
set
=>
SetValue
(
ServerConnectionCountProperty
,
value
);
}
private
async
Task
ProxyServer_BeforeTunnelConnectRequest
(
object
sender
,
TunnelConnectSessionEventArgs
e
)
private
async
Task
ProxyServer_BeforeTunnelConnectRequest
(
object
sender
,
TunnelConnectSessionEventArgs
e
)
{
{
string
hostname
=
e
.
WebSession
.
Request
.
RequestUri
.
Host
;
string
hostname
=
e
.
WebSession
.
Request
.
RequestUri
.
Host
;
...
@@ -122,10 +129,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -122,10 +129,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
e
.
DecryptSsl
=
false
;
e
.
DecryptSsl
=
false
;
}
}
await
Dispatcher
.
InvokeAsync
(()
=>
await
Dispatcher
.
InvokeAsync
(()
=>
{
AddSession
(
e
);
});
{
AddSession
(
e
);
});
}
}
private
async
Task
ProxyServer_BeforeTunnelConnectResponse
(
object
sender
,
TunnelConnectSessionEventArgs
e
)
private
async
Task
ProxyServer_BeforeTunnelConnectResponse
(
object
sender
,
TunnelConnectSessionEventArgs
e
)
...
@@ -142,10 +146,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -142,10 +146,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
private
async
Task
ProxyServer_BeforeRequest
(
object
sender
,
SessionEventArgs
e
)
private
async
Task
ProxyServer_BeforeRequest
(
object
sender
,
SessionEventArgs
e
)
{
{
SessionListItem
item
=
null
;
SessionListItem
item
=
null
;
await
Dispatcher
.
InvokeAsync
(()
=>
await
Dispatcher
.
InvokeAsync
(()
=>
{
item
=
AddSession
(
e
);
});
{
item
=
AddSession
(
e
);
});
if
(
e
.
WebSession
.
Request
.
HasBody
)
if
(
e
.
WebSession
.
Request
.
HasBody
)
{
{
...
@@ -172,10 +173,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -172,10 +173,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
e
.
WebSession
.
Response
.
KeepBody
=
true
;
e
.
WebSession
.
Response
.
KeepBody
=
true
;
await
e
.
GetResponseBody
();
await
e
.
GetResponseBody
();
await
Dispatcher
.
InvokeAsync
(()
=>
await
Dispatcher
.
InvokeAsync
(()
=>
{
item
.
Update
();
});
{
item
.
Update
();
});
}
}
}
}
}
}
...
@@ -207,7 +205,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -207,7 +205,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
{
{
Number
=
lastSessionNumber
,
Number
=
lastSessionNumber
,
WebSession
=
e
.
WebSession
,
WebSession
=
e
.
WebSession
,
IsTunnelConnect
=
isTunnelConnect
,
IsTunnelConnect
=
isTunnelConnect
};
};
if
(
isTunnelConnect
||
e
.
WebSession
.
Request
.
UpgradeToWebSocket
)
if
(
isTunnelConnect
||
e
.
WebSession
.
Request
.
UpgradeToWebSocket
)
...
...
Examples/Titanium.Web.Proxy.Examples.Wpf/Properties/Annotations.cs
View file @
7840a4b9
This diff is collapsed.
Click to expand it.
Examples/Titanium.Web.Proxy.Examples.Wpf/Properties/AssemblyInfo.cs
View file @
7840a4b9
using
System.Reflection
;
using
System.Reflection
;
using
System.Resources
;
using
System.Runtime.CompilerServices
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
using
System.Windows
;
using
System.Windows
;
...
@@ -33,11 +31,11 @@ using System.Windows;
...
@@ -33,11 +31,11 @@ using System.Windows;
[
assembly
:
ThemeInfo
(
[
assembly
:
ThemeInfo
(
ResourceDictionaryLocation
.
None
,
//where theme specific resource dictionaries are located
ResourceDictionaryLocation
.
None
,
//where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
//(used if a resource is not found in the page,
// or application resource dictionaries)
// or application resource dictionaries)
ResourceDictionaryLocation
.
SourceAssembly
//where the generic resource dictionary is located
ResourceDictionaryLocation
.
SourceAssembly
//where the generic resource dictionary is located
//(used if a resource is not found in the page,
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
// app, or any theme specific resource dictionaries)
)]
)]
...
...
Examples/Titanium.Web.Proxy.Examples.Wpf/Properties/Settings.settings
View file @
7840a4b9
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile
xmlns=
"uri:settings"
CurrentProfile=
"(Default)"
>
<SettingsFile
xmlns=
"uri:settings"
CurrentProfile=
"(Default)"
>
<Profiles>
<Profiles>
<Profile
Name=
"(Default)"
/>
<Profile
Name=
"(Default)"
/>
...
...
Examples/Titanium.Web.Proxy.Examples.Wpf/SessionListItem.cs
View file @
7840a4b9
using
System
;
using
System
;
using
System.ComponentModel
;
using
System.ComponentModel
;
using
System.Runtime.CompilerServices
;
using
System.Runtime.CompilerServices
;
using
Titanium.Web.Proxy.EventArguments
;
using
Titanium.Web.Proxy.Examples.Wpf.Annotations
;
using
Titanium.Web.Proxy.Examples.Wpf.Annotations
;
using
Titanium.Web.Proxy.Http
;
using
Titanium.Web.Proxy.Http
;
...
@@ -9,15 +8,15 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -9,15 +8,15 @@ namespace Titanium.Web.Proxy.Examples.Wpf
{
{
public
class
SessionListItem
:
INotifyPropertyChanged
public
class
SessionListItem
:
INotifyPropertyChanged
{
{
private
string
statusCode
;
private
string
protocol
;
private
string
host
;
private
string
url
;
private
long
?
bodySize
;
private
long
?
bodySize
;
private
Exception
exception
;
private
string
host
;
private
string
process
;
private
string
process
;
private
string
protocol
;
private
long
receivedDataCount
;
private
long
receivedDataCount
;
private
long
sentDataCount
;
private
long
sentDataCount
;
private
Exception
exception
;
private
string
statusCode
;
private
string
url
;
public
int
Number
{
get
;
set
;
}
public
int
Number
{
get
;
set
;
}
...
@@ -81,7 +80,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -81,7 +80,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
public
event
PropertyChangedEventHandler
PropertyChanged
;
public
event
PropertyChangedEventHandler
PropertyChanged
;
protected
void
SetField
<
T
>(
ref
T
field
,
T
value
,[
CallerMemberName
]
string
propertyName
=
null
)
protected
void
SetField
<
T
>(
ref
T
field
,
T
value
,
[
CallerMemberName
]
string
propertyName
=
null
)
{
{
if
(!
Equals
(
field
,
value
))
if
(!
Equals
(
field
,
value
))
{
{
...
...
Examples/Titanium.Web.Proxy.Examples.Wpf/packages.config
View file @
7840a4b9
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
packages
>
<
package
id
=
"StreamExtended"
version
=
"1.0.141-beta"
targetFramework
=
"net45"
/>
<
package
id
=
"StreamExtended"
version
=
"1.0.141-beta"
targetFramework
=
"net45"
/>
</
packages
>
</
packages
>
\ No newline at end of file
Tests/Titanium.Web.Proxy.IntegrationTests/SslTests.cs
View file @
7840a4b9
...
@@ -35,7 +35,7 @@ namespace Titanium.Web.Proxy.IntegrationTests
...
@@ -35,7 +35,7 @@ namespace Titanium.Web.Proxy.IntegrationTests
var
handler
=
new
HttpClientHandler
var
handler
=
new
HttpClientHandler
{
{
Proxy
=
new
WebProxy
(
$"http://localhost:
{
localProxyPort
}
"
,
false
),
Proxy
=
new
WebProxy
(
$"http://localhost:
{
localProxyPort
}
"
,
false
),
UseProxy
=
true
,
UseProxy
=
true
};
};
var
client
=
new
HttpClient
(
handler
);
var
client
=
new
HttpClient
(
handler
);
...
@@ -68,8 +68,10 @@ namespace Titanium.Web.Proxy.IntegrationTests
...
@@ -68,8 +68,10 @@ namespace Titanium.Web.Proxy.IntegrationTests
proxyServer
.
Start
();
proxyServer
.
Start
();
foreach
(
var
endPoint
in
proxyServer
.
ProxyEndPoints
)
foreach
(
var
endPoint
in
proxyServer
.
ProxyEndPoints
)
{
Console
.
WriteLine
(
"Listening on '{0}' endpoint at Ip {1} and port: {2} "
,
Console
.
WriteLine
(
"Listening on '{0}' endpoint at Ip {1} and port: {2} "
,
endPoint
.
GetType
().
Name
,
endPoint
.
IpAddress
,
endPoint
.
Port
);
endPoint
.
GetType
().
Name
,
endPoint
.
IpAddress
,
endPoint
.
Port
);
}
}
}
public
void
Stop
()
public
void
Stop
()
...
@@ -96,7 +98,7 @@ namespace Titanium.Web.Proxy.IntegrationTests
...
@@ -96,7 +98,7 @@ namespace Titanium.Web.Proxy.IntegrationTests
}
}
/// <summary>
/// <summary>
/// Allows overriding default certificate validation logic
///
Allows overriding default certificate validation logic
/// </summary>
/// </summary>
/// <param name="sender"></param>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <param name="e"></param>
...
@@ -112,7 +114,7 @@ namespace Titanium.Web.Proxy.IntegrationTests
...
@@ -112,7 +114,7 @@ namespace Titanium.Web.Proxy.IntegrationTests
}
}
/// <summary>
/// <summary>
/// Allows overriding default client certificate selection logic during mutual authentication
///
Allows overriding default client certificate selection logic during mutual authentication
/// </summary>
/// </summary>
/// <param name="sender"></param>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <param name="e"></param>
...
...
Tests/Titanium.Web.Proxy.UnitTests/CertificateManagerTests.cs
View file @
7840a4b9
...
@@ -27,6 +27,7 @@ namespace Titanium.Web.Proxy.UnitTests
...
@@ -27,6 +27,7 @@ namespace Titanium.Web.Proxy.UnitTests
mgr
.
CertificateEngine
=
CertificateEngine
.
BouncyCastle
;
mgr
.
CertificateEngine
=
CertificateEngine
.
BouncyCastle
;
mgr
.
ClearIdleCertificates
();
mgr
.
ClearIdleCertificates
();
for
(
int
i
=
0
;
i
<
5
;
i
++)
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
foreach
(
string
host
in
hostNames
)
foreach
(
string
host
in
hostNames
)
{
{
tasks
.
Add
(
Task
.
Run
(()
=>
tasks
.
Add
(
Task
.
Run
(()
=>
...
@@ -36,6 +37,7 @@ namespace Titanium.Web.Proxy.UnitTests
...
@@ -36,6 +37,7 @@ namespace Titanium.Web.Proxy.UnitTests
Assert
.
IsNotNull
(
certificate
);
Assert
.
IsNotNull
(
certificate
);
}));
}));
}
}
}
await
Task
.
WhenAll
(
tasks
.
ToArray
());
await
Task
.
WhenAll
(
tasks
.
ToArray
());
...
@@ -59,6 +61,7 @@ namespace Titanium.Web.Proxy.UnitTests
...
@@ -59,6 +61,7 @@ namespace Titanium.Web.Proxy.UnitTests
mgr
.
ClearIdleCertificates
();
mgr
.
ClearIdleCertificates
();
for
(
int
i
=
0
;
i
<
5
;
i
++)
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
foreach
(
string
host
in
hostNames
)
foreach
(
string
host
in
hostNames
)
{
{
tasks
.
Add
(
Task
.
Run
(()
=>
tasks
.
Add
(
Task
.
Run
(()
=>
...
@@ -68,6 +71,7 @@ namespace Titanium.Web.Proxy.UnitTests
...
@@ -68,6 +71,7 @@ namespace Titanium.Web.Proxy.UnitTests
Assert
.
IsNotNull
(
certificate
);
Assert
.
IsNotNull
(
certificate
);
}));
}));
}
}
}
await
Task
.
WhenAll
(
tasks
.
ToArray
());
await
Task
.
WhenAll
(
tasks
.
ToArray
());
mgr
.
RemoveTrustedRootCertificate
(
true
);
mgr
.
RemoveTrustedRootCertificate
(
true
);
...
...
Tests/Titanium.Web.Proxy.UnitTests/ProxyServerTests.cs
View file @
7840a4b9
...
@@ -9,7 +9,8 @@ namespace Titanium.Web.Proxy.UnitTests
...
@@ -9,7 +9,8 @@ namespace Titanium.Web.Proxy.UnitTests
public
class
ProxyServerTests
public
class
ProxyServerTests
{
{
[
TestMethod
]
[
TestMethod
]
public
void
GivenOneEndpointIsAlreadyAddedToAddress_WhenAddingNewEndpointToExistingAddress_ThenExceptionIsThrown
()
public
void
GivenOneEndpointIsAlreadyAddedToAddress_WhenAddingNewEndpointToExistingAddress_ThenExceptionIsThrown
()
{
{
// Arrange
// Arrange
var
proxy
=
new
ProxyServer
();
var
proxy
=
new
ProxyServer
();
...
@@ -34,7 +35,8 @@ namespace Titanium.Web.Proxy.UnitTests
...
@@ -34,7 +35,8 @@ namespace Titanium.Web.Proxy.UnitTests
}
}
[
TestMethod
]
[
TestMethod
]
public
void
GivenOneEndpointIsAlreadyAddedToAddress_WhenAddingNewEndpointToExistingAddress_ThenTwoEndpointsExists
()
public
void
GivenOneEndpointIsAlreadyAddedToAddress_WhenAddingNewEndpointToExistingAddress_ThenTwoEndpointsExists
()
{
{
// Arrange
// Arrange
var
proxy
=
new
ProxyServer
();
var
proxy
=
new
ProxyServer
();
...
@@ -74,7 +76,8 @@ namespace Titanium.Web.Proxy.UnitTests
...
@@ -74,7 +76,8 @@ namespace Titanium.Web.Proxy.UnitTests
}
}
[
TestMethod
]
[
TestMethod
]
public
void
GivenOneEndpointIsAlreadyAddedToZeroPort_WhenAddingNewEndpointToExistingPort_ThenTwoEndpointsExists
()
public
void
GivenOneEndpointIsAlreadyAddedToZeroPort_WhenAddingNewEndpointToExistingPort_ThenTwoEndpointsExists
()
{
{
// Arrange
// Arrange
var
proxy
=
new
ProxyServer
();
var
proxy
=
new
ProxyServer
();
...
...
Tests/Titanium.Web.Proxy.UnitTests/SystemProxyTest.cs
View file @
7840a4b9
...
@@ -85,7 +85,9 @@ namespace Titanium.Web.Proxy.UnitTests
...
@@ -85,7 +85,9 @@ namespace Titanium.Web.Proxy.UnitTests
{
{
hostName
=
Dns
.
GetHostName
();
hostName
=
Dns
.
GetHostName
();
}
}
catch
{}
catch
{
}
if
(
hostName
!=
null
)
if
(
hostName
!=
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