Skip to content

Commit b652737

Browse files
author
Jesse Nicholson
committed
Massive changes
Completely dropped ABP filters from the project, except for CSS selectors. Entire system now hashes strings to size_t, then stores those to eliminate the need to store strings of arbitrary size. Added content classification callback. Added ability to specify block page for blocked HTML payloads.
1 parent 20b88b6 commit b652737

23 files changed

Lines changed: 828 additions & 826 deletions

ide/msvc/libhttpfilteringengine.sln

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,97 @@ EndProject
1313
Global
1414
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1515
Debug x64|Win = Debug x64|Win
16+
Debug x64|x64 = Debug x64|x64
17+
Debug x64|x86 = Debug x64|x86
1618
Debug x86|Win = Debug x86|Win
19+
Debug x86|x64 = Debug x86|x64
20+
Debug x86|x86 = Debug x86|x86
21+
Debug|Win = Debug|Win
22+
Debug|x64 = Debug|x64
23+
Debug|x86 = Debug|x86
1724
Release x64|Win = Release x64|Win
25+
Release x64|x64 = Release x64|x64
26+
Release x64|x86 = Release x64|x86
1827
Release x86|Win = Release x86|Win
28+
Release x86|x64 = Release x86|x64
29+
Release x86|x86 = Release x86|x86
30+
Release|Win = Release|Win
31+
Release|x64 = Release|x64
32+
Release|x86 = Release|x86
1933
EndGlobalSection
2034
GlobalSection(ProjectConfigurationPlatforms) = postSolution
2135
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Debug x64|Win.ActiveCfg = Debug x64|x64
2236
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Debug x64|Win.Build.0 = Debug x64|x64
37+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Debug x64|x64.ActiveCfg = Debug x64|x64
38+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Debug x64|x64.Build.0 = Debug x64|x64
39+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Debug x64|x86.ActiveCfg = Debug x64|Win32
40+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Debug x64|x86.Build.0 = Debug x64|Win32
2341
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Debug x86|Win.ActiveCfg = Debug x86|Win32
2442
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Debug x86|Win.Build.0 = Debug x86|Win32
43+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Debug x86|x64.ActiveCfg = Debug x86|x64
44+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Debug x86|x64.Build.0 = Debug x86|x64
45+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Debug x86|x86.ActiveCfg = Debug x86|Win32
46+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Debug x86|x86.Build.0 = Debug x86|Win32
47+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Debug|Win.ActiveCfg = Debug x86|x64
48+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Debug|Win.Build.0 = Debug x86|x64
49+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Debug|x64.ActiveCfg = Debug x86|x64
50+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Debug|x64.Build.0 = Debug x86|x64
51+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Debug|x86.ActiveCfg = Debug x64|Win32
52+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Debug|x86.Build.0 = Debug x64|Win32
2553
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Release x64|Win.ActiveCfg = Release x64|x64
2654
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Release x64|Win.Build.0 = Release x64|x64
55+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Release x64|x64.ActiveCfg = Release x64|x64
56+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Release x64|x64.Build.0 = Release x64|x64
57+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Release x64|x86.ActiveCfg = Release x64|Win32
58+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Release x64|x86.Build.0 = Release x64|Win32
2759
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Release x86|Win.ActiveCfg = Release x86|Win32
2860
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Release x86|Win.Build.0 = Release x86|Win32
61+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Release x86|x64.ActiveCfg = Release x86|x64
62+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Release x86|x64.Build.0 = Release x86|x64
63+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Release x86|x86.ActiveCfg = Release x86|Win32
64+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Release x86|x86.Build.0 = Release x86|Win32
65+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Release|Win.ActiveCfg = Debug x86|x64
66+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Release|Win.Build.0 = Debug x86|x64
67+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Release|x64.ActiveCfg = Release x86|x64
68+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Release|x64.Build.0 = Release x86|x64
69+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Release|x86.ActiveCfg = Release x64|Win32
70+
{A91768BF-1314-41FE-9E6F-A4B4D3A777B4}.Release|x86.Build.0 = Release x64|Win32
2971
{CE29AD88-4255-450F-9FA1-22252959CE94}.Debug x64|Win.ActiveCfg = Debug x64|x64
3072
{CE29AD88-4255-450F-9FA1-22252959CE94}.Debug x64|Win.Build.0 = Debug x64|x64
73+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Debug x64|x64.ActiveCfg = Debug x64|x64
74+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Debug x64|x64.Build.0 = Debug x64|x64
75+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Debug x64|x86.ActiveCfg = Debug x64|Win32
76+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Debug x64|x86.Build.0 = Debug x64|Win32
3177
{CE29AD88-4255-450F-9FA1-22252959CE94}.Debug x86|Win.ActiveCfg = Debug x86|Win32
3278
{CE29AD88-4255-450F-9FA1-22252959CE94}.Debug x86|Win.Build.0 = Debug x86|Win32
79+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Debug x86|x64.ActiveCfg = Debug x86|x64
80+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Debug x86|x64.Build.0 = Debug x86|x64
81+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Debug x86|x86.ActiveCfg = Debug x86|Win32
82+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Debug x86|x86.Build.0 = Debug x86|Win32
83+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Debug|Win.ActiveCfg = Debug x86|x64
84+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Debug|Win.Build.0 = Debug x86|x64
85+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Debug|x64.ActiveCfg = Debug x86|x64
86+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Debug|x64.Build.0 = Debug x86|x64
87+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Debug|x86.ActiveCfg = Debug x64|Win32
88+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Debug|x86.Build.0 = Debug x64|Win32
3389
{CE29AD88-4255-450F-9FA1-22252959CE94}.Release x64|Win.ActiveCfg = Release x64|x64
3490
{CE29AD88-4255-450F-9FA1-22252959CE94}.Release x64|Win.Build.0 = Release x64|x64
91+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Release x64|x64.ActiveCfg = Release x64|x64
92+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Release x64|x64.Build.0 = Release x64|x64
93+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Release x64|x86.ActiveCfg = Release x64|Win32
94+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Release x64|x86.Build.0 = Release x64|Win32
3595
{CE29AD88-4255-450F-9FA1-22252959CE94}.Release x86|Win.ActiveCfg = Release x86|Win32
3696
{CE29AD88-4255-450F-9FA1-22252959CE94}.Release x86|Win.Build.0 = Release x86|Win32
97+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Release x86|x64.ActiveCfg = Release x86|x64
98+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Release x86|x64.Build.0 = Release x86|x64
99+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Release x86|x86.ActiveCfg = Release x86|Win32
100+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Release x86|x86.Build.0 = Release x86|Win32
101+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Release|Win.ActiveCfg = Debug x86|x64
102+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Release|Win.Build.0 = Debug x86|x64
103+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Release|x64.ActiveCfg = Release x86|x64
104+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Release|x64.Build.0 = Release x86|x64
105+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Release|x86.ActiveCfg = Release x64|Win32
106+
{CE29AD88-4255-450F-9FA1-22252959CE94}.Release|x86.Build.0 = Release x64|Win32
37107
EndGlobalSection
38108
GlobalSection(SolutionProperties) = preSolution
39109
HideSolutionNode = FALSE

ide/msvc/libhttpfilteringengine.vcxproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -538,10 +538,7 @@ xcopy /Y "$(ProjectDir)..\..\deps\windivert\msvc\x64\*.sys" "$(OutDir)"</Command
538538
<Reference Include="System.Xml" />
539539
</ItemGroup>
540540
<ItemGroup>
541-
<ClInclude Include="..\..\src\te\httpengine\filtering\http\AbpFilterParser.hpp" />
542541
<ClInclude Include="..\..\src\te\httpengine\filtering\http\CategorizedCssSelector.hpp" />
543-
<ClInclude Include="..\..\src\te\httpengine\filtering\http\AbpFilter.hpp" />
544-
<ClInclude Include="..\..\src\te\httpengine\filtering\http\AbpFilterOptions.hpp" />
545542
<ClInclude Include="..\..\src\te\httpengine\filtering\http\HttpFilteringEngine.hpp" />
546543
<ClInclude Include="..\..\src\te\httpengine\filtering\options\HttpFilteringOptions.hpp" />
547544
<ClInclude Include="..\..\src\te\httpengine\filtering\options\ProgramWideOptions.hpp" />
@@ -567,9 +564,7 @@ xcopy /Y "$(ProjectDir)..\..\deps\windivert\msvc\x64\*.sys" "$(OutDir)"</Command
567564
</ItemGroup>
568565
<ItemGroup>
569566
<ClCompile Include="..\..\deps\http-parser\http_parser.c" />
570-
<ClCompile Include="..\..\src\te\httpengine\filtering\http\AbpFilterParser.cpp" />
571567
<ClCompile Include="..\..\src\te\httpengine\filtering\http\CategorizedCssSelector.cpp" />
572-
<ClCompile Include="..\..\src\te\httpengine\filtering\http\AbpFilter.cpp" />
573568
<ClCompile Include="..\..\src\te\httpengine\filtering\http\HttpFilteringEngine.cpp" />
574569
<ClCompile Include="..\..\src\te\httpengine\filtering\options\ProgramWideOptions.cpp" />
575570
<ClCompile Include="..\..\src\te\httpengine\HttpFilteringEngineControl.cpp" />

ide/msvc/libhttpfilteringengine.vcxproj.filters

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@
180180
<ClInclude Include="..\..\src\te\httpengine\mitm\secure\TlsCapableHttpBridge.hpp">
181181
<Filter>Header Files\te\httpengine\mitm\secure</Filter>
182182
</ClInclude>
183-
<ClInclude Include="..\..\src\te\httpengine\HttpFilteringEngineManaged.hpp">
184-
<Filter>Header Files\te\httpengine</Filter>
185-
</ClInclude>
186183
<ClInclude Include="..\..\src\te\httpengine\mitm\diversion\BaseDiverter.hpp">
187184
<Filter>Header Files\te\httpengine\mitm\diversion</Filter>
188185
</ClInclude>
@@ -216,14 +213,8 @@
216213
<ClInclude Include="..\..\src\te\httpengine\mitm\secure\TlsCapableHttpAcceptor.hpp">
217214
<Filter>Header Files\te\httpengine\mitm\secure</Filter>
218215
</ClInclude>
219-
<ClInclude Include="..\..\src\te\httpengine\filtering\http\AbpFilterParser.hpp">
220-
<Filter>Header Files\te\httpengine\filtering\http</Filter>
221-
</ClInclude>
222-
<ClInclude Include="..\..\src\te\httpengine\filtering\http\AbpFilter.hpp">
223-
<Filter>Header Files\te\httpengine\filtering\http</Filter>
224-
</ClInclude>
225-
<ClInclude Include="..\..\src\te\httpengine\filtering\http\AbpFilterOptions.hpp">
226-
<Filter>Header Files\te\httpengine\filtering\http</Filter>
216+
<ClInclude Include="..\..\src\te\httpengine\HttpFilteringEngineManaged.hpp">
217+
<Filter>Header Files\te\httpengine</Filter>
227218
</ClInclude>
228219
</ItemGroup>
229220
<ItemGroup>
@@ -251,9 +242,6 @@
251242
<ClCompile Include="..\..\src\te\httpengine\mitm\secure\TlsCapableHttpBridge.cpp">
252243
<Filter>Source Files\te\httpengine\mitm\secure</Filter>
253244
</ClCompile>
254-
<ClCompile Include="..\..\src\te\httpengine\HttpFilteringEngineManaged.cpp">
255-
<Filter>Source Files\te\httpengine</Filter>
256-
</ClCompile>
257245
<ClCompile Include="..\..\src\te\httpengine\mitm\diversion\BaseDiverter.cpp">
258246
<Filter>Source Files\te\httpengine\mitm\diversion</Filter>
259247
</ClCompile>
@@ -275,15 +263,12 @@
275263
<ClCompile Include="..\..\src\te\httpengine\HttpFilteringEngineCAPI.cpp">
276264
<Filter>Source Files\te\httpengine</Filter>
277265
</ClCompile>
278-
<ClCompile Include="..\..\src\te\httpengine\filtering\http\AbpFilterParser.cpp">
279-
<Filter>Source Files\te\httpengine\filtering\http</Filter>
280-
</ClCompile>
281-
<ClCompile Include="..\..\src\te\httpengine\filtering\http\AbpFilter.cpp">
282-
<Filter>Source Files\te\httpengine\filtering\http</Filter>
283-
</ClCompile>
284266
<ClCompile Include="..\..\deps\http-parser\http_parser.c">
285267
<Filter>Source Files\http_parser</Filter>
286268
</ClCompile>
269+
<ClCompile Include="..\..\src\te\httpengine\HttpFilteringEngineManaged.cpp">
270+
<Filter>Source Files\te\httpengine</Filter>
271+
</ClCompile>
287272
</ItemGroup>
288273
<ItemGroup>
289274
<ResourceCompile Include="app.rc">

src/te/httpengine/HttpFilteringEngineCAPI.cpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ PHttpFilteringEngineCtl fe_ctl_create(
4343
FirewallCheckCallback firewallCb,
4444
const char* caBundleAbsolutePath,
4545
uint32_t caBundleAbsolutePathLength,
46+
const char* blockedHtmlPage,
47+
uint32_t blockedHtmlPageLength,
4648
uint16_t httpListenerPort,
4749
uint16_t httpsListenerPort,
4850
uint32_t numThread,
@@ -79,11 +81,18 @@ PHttpFilteringEngineCtl fe_ctl_create(
7981

8082
std::string caPath(u8"none");
8183

84+
std::string blockedHtmlPageStr;
85+
8286
if (caBundleAbsolutePathLength > 0 && caBundleAbsolutePath != nullptr)
8387
{
8488
caPath = std::string(caBundleAbsolutePath, static_cast<size_t>(caBundleAbsolutePathLength));
8589
}
8690

91+
if (blockedHtmlPageLength > 0 && blockedHtmlPage != nullptr)
92+
{
93+
blockedHtmlPageStr = std::string(blockedHtmlPage, static_cast<size_t>(blockedHtmlPageLength));
94+
}
95+
8796
PHttpFilteringEngineCtl inst = nullptr;
8897

8998
bool success = false;
@@ -92,6 +101,7 @@ PHttpFilteringEngineCtl fe_ctl_create(
92101
inst = reinterpret_cast<PHttpFilteringEngineCtl>(new te::httpengine::HttpFilteringEngineControl(
93102
firewallCb,
94103
caPath,
104+
blockedHtmlPageStr,
95105
httpListenerPort,
96106
httpsListenerPort,
97107
numThread,
@@ -113,7 +123,7 @@ PHttpFilteringEngineCtl fe_ctl_create(
113123
}
114124
catch (std::exception& e)
115125
{
116-
126+
std::cout << "error: " << e.what() << std::endl;
117127
}
118128

119129
return inst;
@@ -591,3 +601,27 @@ void fe_ctl_unload_rules_for_category(PHttpFilteringEngineCtl ptr, const uint8_t
591601

592602
assert(callSuccess == true && u8"In fe_ctl_get_rootca_pem(...) - Caught exception and failed to unload rules for category.");
593603
}
604+
605+
void fe_ctl_unload_text_triggers_for_category(PHttpFilteringEngineCtl ptr, const uint8_t category)
606+
{
607+
#ifndef NDEBUG
608+
assert(ptr != nullptr && u8"In fe_ctl_unload_rules_for_category(char**, size_t*) - Supplied PHttpFilteringEngineCtl ptr is nullptr!");
609+
#endif
610+
611+
bool callSuccess = false;
612+
613+
try
614+
{
615+
if (ptr != nullptr)
616+
{
617+
reinterpret_cast<te::httpengine::HttpFilteringEngineControl*>(ptr)->UnloadTextTriggersForCategory(category);
618+
callSuccess = true;
619+
}
620+
}
621+
catch (std::exception& e)
622+
{
623+
reinterpret_cast<te::httpengine::HttpFilteringEngineControl*>(ptr)->ReportError(e.what());
624+
}
625+
626+
assert(callSuccess == true && u8"In fe_ctl_get_rootca_pem(...) - Caught exception and failed to unload rules for category.");
627+
}

src/te/httpengine/HttpFilteringEngineCAPI.h

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ extern "C" {
6464
/// <summary>
6565
/// Creates a new instance of the HttpFilteringEngineCtl class, which manages the operation of
6666
/// the HTTP Filtering Engine.
67-
///
67+
///
6868
/// It's a little messy having so many defined callbacks required at creation time, but there is
6969
/// a lot of information that the Engine can report and request, and is also multithreaded in
7070
/// nearly every aspect. Avoiding incurring the cost of synchronizing callbacks post creation is
@@ -83,29 +83,41 @@ extern "C" {
8383
/// The length of the previous caBundleAbsolutePath string. Supply zero if nullptr was supplied
8484
/// to the caBundleAbsolutePath argument.
8585
/// </param>
86+
/// <param name="blockedHtmlPage">
87+
/// An optional, but recommended, pointer to a HTML string to display whenever a HTML payload is
88+
/// blocked.
89+
/// </param>
90+
/// <param name="blockedHtmlPageLength">
91+
/// The length of the previous blockedHtmlPage string. Supply zero if nullptr was supplied to the
92+
/// blockedHtmlPage argument.
93+
/// </param>
8694
/// <param name="httpListenerPort">
8795
/// The desired port for the proxy to listen for incoming plain TCP HTTP clients on. Recommended
8896
/// to supply a value of zero, as it is recommended to allow the OS to select an available port
8997
/// from the ephimeral port range.
9098
/// </param>
9199
/// <param name="httpsListenerPort">
92100
/// The desired port for the proxy to listen for incoming secure HTTP clients on. Recommended to
93-
/// supply a value of zero, as it is recommended to allow the OS to select an available port
94-
/// from the ephimeral port range.
101+
/// supply a value of zero, as it is recommended to allow the OS to select an available port from
102+
/// the ephimeral port range.
95103
/// </param>
96104
/// <param name="numThreads">
97105
/// The number of thread to be run against the io_service that drives the proxy and all
98106
/// associated functionality, barring the platform dependent Diverter. If a value of zero is
99107
/// supplied, the value will be set internally to the number of logical cores on the device. Be
100108
/// advised that these threads are the same threads that execute the filtering functionality.
101109
/// </param>
110+
/// <param name="onClassify">
111+
/// A pointer to a method that can accept a byte array along with a mime-type and attempt to
112+
/// perform classification of the supplied binary content.
113+
/// </param>
102114
/// <param name="onInfo">
103115
/// A pointer to a method that can accept string informational data generated by the underlying
104116
/// Engine. This callback cannot be supplied post-construction.
105117
/// </param>
106118
/// <param name="onWarn">
107-
/// A pointer to a method that can accept string warning data generated by the underlying
108-
/// Engine. This callback cannot be supplied post-construction.
119+
/// A pointer to a method that can accept string warning data generated by the underlying Engine.
120+
/// This callback cannot be supplied post-construction.
109121
/// </param>
110122
/// <param name="onError">
111123
/// A pointer to a method that can accept string error data generated by the underlying Engine.
@@ -116,9 +128,8 @@ extern "C" {
116128
/// underlying Engine. This callback cannot be supplied post-construction.
117129
/// </param>
118130
/// <param name="onElementsBlocked">
119-
/// A pointer to a method that can accept information about HTML elements removed by CSS
120-
/// selects, generated by the underlying Engine. This callback cannot be supplied
121-
/// post-construction.
131+
/// A pointer to a method that can accept information about HTML elements removed by CSS selects,
132+
/// generated by the underlying Engine. This callback cannot be supplied post-construction.
122133
/// </param>
123134
/// <returns>
124135
/// A valid pointer to the created instance if the call succeeded, nullptr otherwise.
@@ -127,6 +138,8 @@ extern "C" {
127138
FirewallCheckCallback firewallCb,
128139
const char* caBundleAbsolutePath,
129140
uint32_t caBundleAbsolutePathLength,
141+
const char* blockedHtmlPage,
142+
uint32_t blockedHtmlPageLength,
130143
uint16_t httpListenerPort,
131144
uint16_t httpsListenerPort,
132145
uint32_t numThreads,
@@ -475,6 +488,17 @@ extern "C" {
475488
/// </param>
476489
HTTP_FILTERING_ENGINE_API void fe_ctl_unload_rules_for_category(PHttpFilteringEngineCtl ptr, const uint8_t category);
477490

491+
/// <summary>
492+
/// Unloads any and all text triggers for the given category.
493+
/// </summary>
494+
/// <param name="ptr">
495+
/// A valid pointer to an existing Engine instance.
496+
/// </param>
497+
/// <param name="category">
498+
/// The category for which to unload any and all text triggers.
499+
/// </param>
500+
HTTP_FILTERING_ENGINE_API void fe_ctl_unload_text_triggers_for_category(PHttpFilteringEngineCtl ptr, const uint8_t category);
501+
478502
#ifdef __cplusplus
479503
};
480504
#endif // __cplusplus

src/te/httpengine/HttpFilteringEngineControl.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ namespace te
8585
HttpFilteringEngineControl::HttpFilteringEngineControl(
8686
util::cb::FirewallCheckFunction firewallCb,
8787
std::string caBundleAbsolutePath,
88+
std::string blockedHtmlPage,
8889
uint16_t httpListenerPort,
8990
uint16_t httpsListenerPort,
9091
uint32_t proxyNumThreads,
@@ -102,7 +103,7 @@ namespace te
102103
m_httpListenerPort(httpListenerPort),
103104
m_httpsListenerPort(httpsListenerPort),
104105
m_proxyNumThreads(proxyNumThreads),
105-
m_programWideOptions(new filtering::options::ProgramWideOptions()),
106+
m_programWideOptions(new filtering::options::ProgramWideOptions(blockedHtmlPage)),
106107
m_httpFilteringEngine(new filtering::http::HttpFilteringEngine(m_programWideOptions.get(), onInfo, onWarn, onError, onClassify, onRequestBlocked, onElementsBlocked)),
107108
m_isRunning(false)
108109
{
@@ -389,5 +390,13 @@ namespace te
389390
}
390391
}
391392

393+
void HttpFilteringEngineControl::UnloadTextTriggersForCategory(const uint8_t category)
394+
{
395+
if (m_httpFilteringEngine != nullptr && category != 0)
396+
{
397+
m_httpFilteringEngine->UnloadAllTextTriggersForCategory(category);
398+
}
399+
}
400+
392401
} /* namespace httpengine */
393402
} /* namespace te */

0 commit comments

Comments
 (0)