Fixed multithreading
This commit is contained in:
@@ -19,8 +19,8 @@ ADD ./backend/requirements.txt /execute/requirements.txt
|
||||
RUN pip3 install --no-cache-dir -r /execute/requirements.txt --no-warn-script-location
|
||||
|
||||
COPY ./backend/binsrc /execute/binsrc
|
||||
RUN g++ binsrc/nfqueue.cpp -o modules/cppqueue -O3 -march=native -lnetfilter_queue -pthread -lpcre2-8 -ltins -lmnl -lnfnetlink
|
||||
RUN g++ binsrc/proxy.cpp -o modules/proxy -O3 -march=native -pthread -lboost_system -lboost_thread -lpcre2-8
|
||||
RUN g++ binsrc/nfqueue.cpp -o modules/cppqueue -O3 -lnetfilter_queue -pthread -lpcre2-8 -ltins -lmnl -lnfnetlink
|
||||
RUN g++ binsrc/proxy.cpp -o modules/proxy -O3 -pthread -lboost_system -lboost_thread -lpcre2-8
|
||||
|
||||
|
||||
COPY ./backend/ /execute/
|
||||
|
||||
@@ -80,9 +80,6 @@ struct regex_rules{
|
||||
shared_ptr<regex_rules> regex_config;
|
||||
|
||||
mutex update_mutex;
|
||||
#ifdef MULTI_THREAD
|
||||
mutex stdout_mutex;
|
||||
#endif
|
||||
|
||||
bool filter_data(unsigned char* data, const size_t& bytes_transferred, regex_rule_vector const &blacklist, regex_rule_vector const &whitelist){
|
||||
#ifdef DEBUG_PACKET
|
||||
@@ -97,10 +94,9 @@ bool filter_data(unsigned char* data, const size_t& bytes_transferred, regex_rul
|
||||
for (regex_rule_pair ele:blacklist){
|
||||
try{
|
||||
if(ele.second.match(str_data)){
|
||||
#ifdef MULTI_THREAD
|
||||
std::unique_lock<std::mutex> lck(stdout_mutex);
|
||||
#endif
|
||||
cout << "BLOCKED " << ele.first << endl;
|
||||
stringstream msg;
|
||||
msg << "BLOCKED " << ele.first << endl;
|
||||
cout << msg.str() << std::flush;
|
||||
return false;
|
||||
}
|
||||
} catch(...){
|
||||
@@ -110,10 +106,9 @@ bool filter_data(unsigned char* data, const size_t& bytes_transferred, regex_rul
|
||||
for (regex_rule_pair ele:whitelist){
|
||||
try{
|
||||
if(!ele.second.match(str_data)){
|
||||
#ifdef MULTI_THREAD
|
||||
std::unique_lock<std::mutex> lck(stdout_mutex);
|
||||
#endif
|
||||
cout << "BLOCKED " << ele.first << endl;
|
||||
stringstream msg;
|
||||
msg << "BLOCKED " << ele.first << endl;
|
||||
cout << msg.str() << std::flush;
|
||||
return false;
|
||||
}
|
||||
} catch(...){
|
||||
|
||||
1
tests/results/.~lock.netfilter-single.csv#
Normal file
1
tests/results/.~lock.netfilter-single.csv#
Normal file
@@ -0,0 +1 @@
|
||||
,nik,nik-deb,03.08.2022 12:06,file:///home/nik/.config/libreoffice/4;
|
||||
51
tests/results/netfilter-4thread.csv
Normal file
51
tests/results/netfilter-4thread.csv
Normal file
@@ -0,0 +1,51 @@
|
||||
0,730.449
|
||||
1,423.354
|
||||
2,307.163
|
||||
3,178.303
|
||||
4,139.111
|
||||
5,102.774
|
||||
6,100.106
|
||||
7,90.722
|
||||
8,67.083
|
||||
9,74.475
|
||||
10,56.209
|
||||
11,52.584
|
||||
12,43.16
|
||||
13,44.007
|
||||
14,41.597
|
||||
15,39.327
|
||||
16,37.487
|
||||
17,35.718
|
||||
18,39.123
|
||||
19,38.705
|
||||
20,36.028
|
||||
21,29.985
|
||||
22,34.013
|
||||
23,27.12
|
||||
24,30.239
|
||||
25,25.035
|
||||
26,28.456
|
||||
27,22.972
|
||||
28,26.196
|
||||
29,21.872
|
||||
30,24.821
|
||||
31,24.202
|
||||
32,20.028
|
||||
33,19.277
|
||||
34,18.47
|
||||
35,18.062
|
||||
36,17.525
|
||||
37,16.866
|
||||
38,16.496
|
||||
39,15.975
|
||||
40,15.702
|
||||
41,16.453
|
||||
42,16.58
|
||||
43,14.644
|
||||
44,15.084
|
||||
45,14.709
|
||||
46,14.754
|
||||
47,13.849
|
||||
48,14.306
|
||||
49,13.651
|
||||
50,12.954
|
||||
|
51
tests/results/netfilter-single.csv
Normal file
51
tests/results/netfilter-single.csv
Normal file
@@ -0,0 +1,51 @@
|
||||
0,684.571
|
||||
1,437.246
|
||||
2,304.309
|
||||
3,165.995
|
||||
4,119.457
|
||||
5,119.739
|
||||
6,86.956
|
||||
7,75.407
|
||||
8,67.627
|
||||
9,74.272
|
||||
10,56.015
|
||||
11,52.046
|
||||
12,57.892
|
||||
13,44.381
|
||||
14,48.976
|
||||
15,39.528
|
||||
16,36.876
|
||||
17,35.459
|
||||
18,38.16
|
||||
19,39.09
|
||||
20,36.559
|
||||
21,26.947
|
||||
22,32.913
|
||||
23,27.321
|
||||
24,30.553
|
||||
25,27.91
|
||||
26,28.058
|
||||
27,21.006
|
||||
28,23.086
|
||||
29,18.766
|
||||
30,19.982
|
||||
31,20.54
|
||||
32,20.093
|
||||
33,19.02
|
||||
34,18.207
|
||||
35,20.907
|
||||
36,17.078
|
||||
37,16.372
|
||||
38,16.342
|
||||
39,15.942
|
||||
40,15.874
|
||||
41,16.941
|
||||
42,15.426
|
||||
43,15.551
|
||||
44,14.26
|
||||
45,15.867
|
||||
46,14.913
|
||||
47,14.164
|
||||
48,14.059
|
||||
49,13.457
|
||||
50,12.727
|
||||
|
51
tests/results/proxy-4thread.csv
Normal file
51
tests/results/proxy-4thread.csv
Normal file
@@ -0,0 +1,51 @@
|
||||
0,769.618
|
||||
1,232.968
|
||||
2,154.656
|
||||
3,118.505
|
||||
4,97.084
|
||||
5,80.982
|
||||
6,69.532
|
||||
7,59.653
|
||||
8,56.235
|
||||
9,49.828
|
||||
10,45.603
|
||||
11,42.791
|
||||
12,39.231
|
||||
13,37.07
|
||||
14,34.347
|
||||
15,32.325
|
||||
16,33.11
|
||||
17,28.528
|
||||
18,31.477
|
||||
19,29.778
|
||||
20,27.93
|
||||
21,26.67
|
||||
22,25.907
|
||||
23,24.965
|
||||
24,20.498
|
||||
25,23.078
|
||||
26,22.077
|
||||
27,21.447
|
||||
28,20.666
|
||||
29,20.266
|
||||
30,19.219
|
||||
31,18.105
|
||||
32,14.124
|
||||
33,12.745
|
||||
34,14.128
|
||||
35,13.951
|
||||
36,13.488
|
||||
37,13.209
|
||||
38,13.084
|
||||
39,12.429
|
||||
40,12.044
|
||||
41,11.906
|
||||
42,11.261
|
||||
43,9.746
|
||||
44,10.95
|
||||
45,10.849
|
||||
46,10.203
|
||||
47,10.004
|
||||
48,8.958
|
||||
49,9.264
|
||||
50,9.757
|
||||
|
51
tests/results/proxy-single.csv
Normal file
51
tests/results/proxy-single.csv
Normal file
@@ -0,0 +1,51 @@
|
||||
0,803.99
|
||||
1,207.751
|
||||
2,107.739
|
||||
3,86.386
|
||||
4,69.129
|
||||
5,57.75
|
||||
6,50.605
|
||||
7,44.745
|
||||
8,39.99
|
||||
9,36.051
|
||||
10,33.123
|
||||
11,30.457
|
||||
12,27.997
|
||||
13,26.202
|
||||
14,24.211
|
||||
15,22.663
|
||||
16,34.662
|
||||
17,19.939
|
||||
18,31.032
|
||||
19,29.072
|
||||
20,28.32
|
||||
21,27.248
|
||||
22,25.699
|
||||
23,24.453
|
||||
24,24.184
|
||||
25,22.719
|
||||
26,22.098
|
||||
27,21.046
|
||||
28,20.256
|
||||
29,19.72
|
||||
30,19.099
|
||||
31,12.525
|
||||
32,18.613
|
||||
33,10.502
|
||||
34,17.247
|
||||
35,16.858
|
||||
36,16.479
|
||||
37,16.075
|
||||
38,15.444
|
||||
39,15.381
|
||||
40,14.867
|
||||
41,14.378
|
||||
42,14.067
|
||||
43,13.679
|
||||
44,13.27
|
||||
45,13.177
|
||||
46,12.926
|
||||
47,12.72
|
||||
48,12.585
|
||||
49,12.301
|
||||
50,11.851
|
||||
|
Reference in New Issue
Block a user