Skip to content

Commit

Permalink
Inherits several fixes from external packages
Browse files Browse the repository at this point in the history
First true "stable" version of 3.0.x due to external issues inherited.
  • Loading branch information
TechnikEmpire committed Jul 26, 2018
1 parent 08f04a3 commit 2bf9814
Show file tree
Hide file tree
Showing 6 changed files with 375 additions and 353 deletions.
14 changes: 10 additions & 4 deletions CitadelCore.Windows.Example/CitadelCore.Windows.Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
Expand Down Expand Up @@ -62,12 +62,18 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="CitadelCore.Windows">
<Version>3.0.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.WebUtilities">
<Version>2.1.1</Version>
</PackageReference>
<PackageReference Include="WinDivertSharp">
<Version>1.4.3.2</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CitadelCore.Windows\CitadelCore.Windows.csproj">
<Project>{08845003-f4af-4062-b8c8-fc2b6524144f}</Project>
<Name>CitadelCore.Windows</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
6 changes: 6 additions & 0 deletions CitadelCore.Windows.Example/CitadelCore.Windows.Example.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.27703.2042
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CitadelCore.Windows.Example", "CitadelCore.Windows.Example.csproj", "{6310E947-2EEE-4822-BDBF-59C8CE7F02B7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CitadelCore.Windows", "..\CitadelCore.Windows\CitadelCore.Windows.csproj", "{08845003-F4AF-4062-B8C8-FC2B6524144F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{6310E947-2EEE-4822-BDBF-59C8CE7F02B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6310E947-2EEE-4822-BDBF-59C8CE7F02B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6310E947-2EEE-4822-BDBF-59C8CE7F02B7}.Release|Any CPU.Build.0 = Release|Any CPU
{08845003-F4AF-4062-B8C8-FC2B6524144F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{08845003-F4AF-4062-B8C8-FC2B6524144F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{08845003-F4AF-4062-B8C8-FC2B6524144F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{08845003-F4AF-4062-B8C8-FC2B6524144F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
33 changes: 16 additions & 17 deletions CitadelCore.Windows.Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Microsoft.AspNetCore.WebUtilities;
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;

Expand All @@ -22,35 +23,33 @@ internal class Program
{
private static byte[] s_blockPageBytes;

private static readonly ushort s_standardHttpPortNetworkOrder = (ushort)IPAddress.HostToNetworkOrder((short)80);
private static readonly ushort s_standardHttpsPortNetworkOrder = (ushort)IPAddress.HostToNetworkOrder((short)443);

private static FirewallResponse OnFirewallCheck(FirewallRequest request)
{
// Only filter chrome.
var filtering = request.BinaryAbsolutePath.IndexOf("chrome", StringComparison.OrdinalIgnoreCase) != -1;

if (filtering)
{
switch (request.RemotePort)
if (request.RemotePort == s_standardHttpPortNetworkOrder || request.RemotePort == s_standardHttpsPortNetworkOrder)
{
// 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));
return new FirewallResponse(FirewallAction.FilterApplication);
}
else
{
case 80:
case 443:
{
// 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, request.RemotePort);
return new FirewallResponse(FirewallAction.FilterApplication);
}

default:
{
// Let's allow chrome to access TCP 80 and 443, but block all other
// ports. This is where we're blocking any non-80/443 bound transmission.
Console.WriteLine("Blocking internet for application {0} destined for {1}", request.BinaryAbsolutePath, request.RemotePort);
return new FirewallResponse(FirewallAction.BlockInternetForApplication);
}
// Let's allow chrome to access TCP 80 and 443, but block all other
// ports. This is where we're blocking any non-80/443 bound transmission.
Console.WriteLine("Blocking internet for application {0} destined for {1}", request.BinaryAbsolutePath, (ushort)IPAddress.HostToNetworkOrder((short)request.RemotePort));
return new FirewallResponse(FirewallAction.BlockInternetForApplication);
}
}

// For all other applications, just let them access the internet without filtering.
Console.WriteLine("Not filtering application {0} destined for {1}", request.BinaryAbsolutePath, request.RemotePort);
Console.WriteLine("Not filtering application {0} destined for {1}", request.BinaryAbsolutePath, (ushort)IPAddress.HostToNetworkOrder((short)request.RemotePort));
return new FirewallResponse(FirewallAction.DontFilterApplication);
}

Expand Down
31 changes: 7 additions & 24 deletions CitadelCore.Windows/CitadelCore.Windows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,20 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>3.0.7</Version>
<Version>3.0.8</Version>
<Title>CitadeCore.Windows</Title>
<Authors>Jesse Nicholson</Authors>
<Company>Technik Empire</Company>
<Description>Transparent filtering proxy engine for Windows.</Description>
<Copyright>Copyright 2017-Present Jesse Nicholson</Copyright>
<PackageLicenseUrl>https://www.gnu.org/licenses/lgpl-3.0.en.html</PackageLicenseUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/TechnikEmpire/CitadelCore.Windows/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/TechnikEmpire/CitadelCore.Windows</PackageProjectUrl>
<RepositoryUrl>https://github.com/TechnikEmpire/CitadelCore.Windows</RepositoryUrl>
<PackageReleaseNotes>Now has ci via travis.
Removed WinDivert, changed license to MPL 2.0 and linked to WinDivertSharp library instead.
No longer requires unsafe code internally.
Cleaned up some unused variables.
Fixes a minor issue with overlapped events not being cleaned up correctly always.</PackageReleaseNotes>
<PackageReleaseNotes>Inherits several critical fixes from WinDivertSharp and CitadelCore.</PackageReleaseNotes>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<AssemblyVersion>3.0.7.0</AssemblyVersion>
<FileVersion>3.0.7.0</FileVersion>
<AssemblyVersion>3.0.8.0</AssemblyVersion>
<FileVersion>3.0.8.0</FileVersion>
<RepositoryType>git</RepositoryType>
<PackageTags>proxy, filter, filtering, content filtering, content-filter, websocket proxy, http proxy, https proxy</PackageTags>
</PropertyGroup>
Expand All @@ -43,25 +39,12 @@ Fixes a minor issue with overlapped events not being cleaned up correctly always
</ItemGroup>

<ItemGroup>
<PackageReference Include="CitadelCore" Version="3.0.4" />
<PackageReference Include="WinDivertSharp" Version="1.4.3" />
<PackageReference Include="CitadelCore" Version="3.0.5" />
<PackageReference Include="WinDivertSharp" Version="1.4.3.2" />
</ItemGroup>

<Target Name="CollectRuntimeOutputs" BeforeTargets="_GetPackageFiles">
<!-- Collect these items inside a target that runs after build but before packaging. -->
<ItemGroup>
<Content Include="$(OutputPath)\x86\*.dll;$(OutputPath)\x86\*.sys;">
<Pack>true</Pack>
<PackagePath>build\x86\</PackagePath>
</Content>
</ItemGroup>

<ItemGroup>
<Content Include="$(OutputPath)\x64\*.dll;$(OutputPath)\x64\*.sys;">
<Pack>true</Pack>
<PackagePath>build\x64\</PackagePath>
</Content>
</ItemGroup>

<ItemGroup>
<Content Include="$(OutputPath)\*.pdb;">
Expand Down
Loading

0 comments on commit 2bf9814

Please sign in to comment.