Commit 7840a4b9 authored by justcoding121's avatar justcoding121

cleanup test/example projects

parent 000f3715
<?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
...@@ -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()
{ {
......
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
......
...@@ -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>
......
<?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
...@@ -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
...@@ -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
{ {
......
...@@ -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
...@@ -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)
......
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)
)] )]
......
<?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)" />
......
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))
{ {
......
<?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
...@@ -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>
......
...@@ -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);
......
...@@ -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();
......
...@@ -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)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment