Skip to content

Commit

Permalink
Lib now dynamically handles HTTP and HTTPS on a single port
Browse files Browse the repository at this point in the history
  • Loading branch information
TechnikEmpire committed Nov 7, 2018
1 parent a61edbf commit 58df40f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
18 changes: 12 additions & 6 deletions CitadelCore.Windows.Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/// <summary>
/// We pass this in to stream copy operations whenever the user has asked us to pull a
Expand All @@ -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));
Expand Down Expand Up @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions CitadelCore.Windows/CitadelCore.Windows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>3.6.2</Version>
<Version>3.7.0</Version>
<Title>CitadeCore.Windows</Title>
<Authors>Jesse Nicholson</Authors>
<Company>Technik Empire</Company>
Expand All @@ -11,11 +11,11 @@
<PackageLicenseUrl>https://www.mozilla.org/en-US/MPL/2.0/</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/TechnikEmpire/CitadelCore.Windows</PackageProjectUrl>
<RepositoryUrl>https://github.com/TechnikEmpire/CitadelCore.Windows</RepositoryUrl>
<PackageReleaseNotes>Fixes an issue where accessing content-type header could cause a null-ref exception.</PackageReleaseNotes>
<PackageReleaseNotes>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.</PackageReleaseNotes>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<AssemblyVersion>3.6.2.0</AssemblyVersion>
<FileVersion>3.6.2.0</FileVersion>
<AssemblyVersion>3.7.0.0</AssemblyVersion>
<FileVersion>3.7.0.0</FileVersion>
<RepositoryType>git</RepositoryType>
<PackageTags>proxy, filter, filtering, content filtering, content-filter, websocket proxy, http proxy, https proxy</PackageTags>
</PropertyGroup>
Expand All @@ -39,7 +39,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CitadelCore" Version="3.6.2" />
<PackageReference Include="CitadelCore" Version="3.7.0" />
<PackageReference Include="WinDivertSharp" Version="1.4.3.3" />
</ItemGroup>

Expand Down

0 comments on commit 58df40f

Please sign in to comment.