From 58df40f0e0c6fa5aeba3374db2e77f03d3951f4b Mon Sep 17 00:00:00 2001 From: Jesse Nicholson Date: Wed, 7 Nov 2018 07:11:38 -0500 Subject: [PATCH] Lib now dynamically handles HTTP and HTTPS on a single port --- CitadelCore.Windows.Example/Program.cs | 18 ++++++++++++------ CitadelCore.Windows/CitadelCore.Windows.csproj | 10 +++++----- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CitadelCore.Windows.Example/Program.cs b/CitadelCore.Windows.Example/Program.cs index 707d682..402b155 100644 --- a/CitadelCore.Windows.Example/Program.cs +++ b/CitadelCore.Windows.Example/Program.cs @@ -33,6 +33,8 @@ internal class Program private static readonly ushort s_standardHttpPortNetworkOrder = (ushort)IPAddress.HostToNetworkOrder((short)80); private static readonly ushort s_standardHttpsPortNetworkOrder = (ushort)IPAddress.HostToNetworkOrder((short)443); + private static readonly ushort s_altHttpPortNetworkOrder = (ushort)IPAddress.HostToNetworkOrder((short)8080); + private static readonly ushort s_altHttpsPortNetworkOrder = (ushort)IPAddress.HostToNetworkOrder((short)8443); /// /// We pass this in to stream copy operations whenever the user has asked us to pull a @@ -53,11 +55,17 @@ internal class Program private static FirewallResponse OnFirewallCheck(FirewallRequest request) { // Only filter chrome. - var filtering = request.BinaryAbsolutePath.IndexOf("chrome", StringComparison.OrdinalIgnoreCase) != -1; + //var filtering = request.BinaryAbsolutePath.IndexOf("chrome", StringComparison.OrdinalIgnoreCase) != -1; + var filtering = true; if (filtering) { - if (request.RemotePort == s_standardHttpPortNetworkOrder || request.RemotePort == s_standardHttpsPortNetworkOrder) + if ( + request.RemotePort == s_standardHttpPortNetworkOrder || + request.RemotePort == s_standardHttpsPortNetworkOrder || + request.RemotePort == s_altHttpPortNetworkOrder || + request.RemotePort == s_altHttpsPortNetworkOrder + ) { // Let's allow chrome to access TCP 80 and 443, but block all other ports. Console.WriteLine("Filtering application {0} destined for {1}", request.BinaryAbsolutePath, (ushort)IPAddress.HostToNetworkOrder((short)request.RemotePort)); @@ -553,10 +561,8 @@ private static void Main(string[] args) // And you're up and running. Console.WriteLine("Proxy Running"); - Console.WriteLine("Listening for IPv4 HTTP connections on port {0}.", proxyServer.V4HttpEndpoint.Port); - Console.WriteLine("Listening for IPv4 HTTPS connections on port {0}.", proxyServer.V4HttpsEndpoint.Port); - Console.WriteLine("Listening for IPv6 HTTP connections on port {0}.", proxyServer.V6HttpEndpoint.Port); - Console.WriteLine("Listening for IPv6 HTTPS connections on port {0}.", proxyServer.V6HttpsEndpoint.Port); + Console.WriteLine("Listening for IPv4 HTTP/HTTPS connections on port {0}.", proxyServer.V4HttpEndpoint.Port); + Console.WriteLine("Listening for IPv6 HTTP/HTTPS connections on port {0}.", proxyServer.V6HttpEndpoint.Port); // Don't exit on me yet fam. manualResetEvent.WaitOne(); diff --git a/CitadelCore.Windows/CitadelCore.Windows.csproj b/CitadelCore.Windows/CitadelCore.Windows.csproj index 43c055c..61a3e7a 100644 --- a/CitadelCore.Windows/CitadelCore.Windows.csproj +++ b/CitadelCore.Windows/CitadelCore.Windows.csproj @@ -2,7 +2,7 @@ netstandard2.0 - 3.6.2 + 3.7.0 CitadeCore.Windows Jesse Nicholson Technik Empire @@ -11,11 +11,11 @@ https://www.mozilla.org/en-US/MPL/2.0/ https://github.com/TechnikEmpire/CitadelCore.Windows https://github.com/TechnikEmpire/CitadelCore.Windows - Fixes an issue where accessing content-type header could cause a null-ref exception. + Now dynamically handles HTTPS and HTTP streams on a single bound port. Clients no longer need to guess if a non-standard port connection is HTTP or HTTPS, the engine will figure this out itself. true true - 3.6.2.0 - 3.6.2.0 + 3.7.0.0 + 3.7.0.0 git proxy, filter, filtering, content filtering, content-filter, websocket proxy, http proxy, https proxy @@ -39,7 +39,7 @@ - +