Added multithreading
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#Building main conteiner
|
||||
FROM python:slim-buster
|
||||
|
||||
RUN apt-get update && apt-get -y install curl supervisor gettext-base build-essential libboost-dev nginx libboost-system-dev
|
||||
RUN apt-get update && apt-get -y install curl supervisor gettext-base build-essential libboost-dev nginx libboost-system-dev libboost-thread-dev
|
||||
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash
|
||||
RUN apt-get install nodejs
|
||||
|
||||
@@ -14,7 +14,7 @@ ADD ./backend/requirements.txt /execute/requirements.txt
|
||||
RUN pip install --no-cache-dir -r /execute/requirements.txt
|
||||
|
||||
COPY ./backend/ /execute/
|
||||
RUN c++ -O3 -o proxy/proxy proxy/proxy.cpp -pthread -lboost_system
|
||||
RUN c++ -O3 -o proxy/proxy proxy/proxy.cpp -pthread -lboost_system -lboost_thread
|
||||
COPY ./config/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
COPY ./config/nginx.conf /tmp/nginx.conf
|
||||
COPY ./config/start_nginx.sh /tmp/start_nginx.sh
|
||||
|
||||
@@ -4,16 +4,15 @@
|
||||
#include <string>
|
||||
#include <csignal>
|
||||
#include <fstream>
|
||||
|
||||
#include <regex>
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
#include <cctype> // is*
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
using namespace std;
|
||||
@@ -439,7 +438,11 @@ int main(int argc, char* argv[])
|
||||
|
||||
acceptor.accept_connections();
|
||||
|
||||
ios.run();
|
||||
boost::thread_group tg;
|
||||
for (unsigned i = 0; i < thread::hardware_concurrency(); ++i)
|
||||
tg.create_thread(boost::bind(&boost::asio::io_service::run, &ios));
|
||||
|
||||
tg.join_all();
|
||||
}
|
||||
catch(exception& e)
|
||||
{
|
||||
|
||||
72
backend/proxy/test
Normal file
72
backend/proxy/test
Normal file
@@ -0,0 +1,72 @@
|
||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
||||
@@ -153,9 +153,8 @@ class ProxyManager:
|
||||
self.__update_status_db(id, next_status)
|
||||
if saved_status[0] == "wait": saved_status[0] = next_status
|
||||
proxy_status = proxy.start(in_pause=(next_status==STATUS.PAUSE))
|
||||
if proxy_status != 0:
|
||||
saved_status[0] = STATUS.STOP
|
||||
self.__update_status_db(id, STATUS.STOP)
|
||||
saved_status[0] = STATUS.STOP
|
||||
self.__update_status_db(id, STATUS.STOP)
|
||||
return
|
||||
else:
|
||||
time.sleep(.5)
|
||||
|
||||
@@ -29,6 +29,7 @@ parser.add_argument("--password", "-p", type=str, required=True, help='Firegex p
|
||||
parser.add_argument("--num_of_regexes", "-r", type=int, required=True, help='Number of regexes to benchmark with')
|
||||
parser.add_argument("--duration", "-d", type=int, required=False, help='Duration of the Benchmark in seconds', default=5)
|
||||
parser.add_argument("--output_file", "-o", type=str, required=False, help='Output results csv file', default="benchmark.csv")
|
||||
parser.add_argument("--num_of_streams", "-s", type=int, required=False, help='Output results csv file', default=1)
|
||||
|
||||
args = parser.parse_args()
|
||||
sep()
|
||||
@@ -75,7 +76,10 @@ def getReading(port):
|
||||
client.server_hostname = '127.0.0.1'
|
||||
client.port = port
|
||||
client.protocol = 'tcp'
|
||||
return round(client.run().json['end']['sum_received']['bits_per_second']/8e+6 , 3)
|
||||
client.num_streams = args.num_of_streams
|
||||
run = client.run()
|
||||
print(run)
|
||||
return round(run.json['end']['sum_received']['bits_per_second']/8e+6 , 3)
|
||||
|
||||
server = Process(target=startServer)
|
||||
server.start()
|
||||
|
||||
Reference in New Issue
Block a user