Updated benchmark
This commit is contained in:
@@ -64,6 +64,7 @@ def get_status():
|
|||||||
|
|
||||||
@app.route("/api/login", methods = ['POST'])
|
@app.route("/api/login", methods = ['POST'])
|
||||||
def login():
|
def login():
|
||||||
|
if DEBUG: return { "status":"ok" }
|
||||||
if app.config["STATUS"] != "run": return abort(404)
|
if app.config["STATUS"] != "run": return abort(404)
|
||||||
req = request.get_json(force = True)
|
req = request.get_json(force = True)
|
||||||
|
|
||||||
@@ -89,12 +90,14 @@ def login():
|
|||||||
|
|
||||||
@app.route("/api/logout")
|
@app.route("/api/logout")
|
||||||
def logout():
|
def logout():
|
||||||
|
if DEBUG: return { "status":"ok" }
|
||||||
session["loggined"] = False
|
session["loggined"] = False
|
||||||
return { "status":"ok" }
|
return { "status":"ok" }
|
||||||
|
|
||||||
@app.route('/api/change-password', methods = ['POST'])
|
@app.route('/api/change-password', methods = ['POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def change_password():
|
def change_password():
|
||||||
|
if DEBUG: return { "status":"ok" }
|
||||||
if app.config["STATUS"] != "run": return abort(404)
|
if app.config["STATUS"] != "run": return abort(404)
|
||||||
req = request.get_json(force = True)
|
req = request.get_json(force = True)
|
||||||
|
|
||||||
@@ -123,6 +126,7 @@ def change_password():
|
|||||||
|
|
||||||
@app.route('/api/set-password', methods = ['POST'])
|
@app.route('/api/set-password', methods = ['POST'])
|
||||||
def set_password():
|
def set_password():
|
||||||
|
if DEBUG: return { "status":"ok" }
|
||||||
if app.config["STATUS"] != "init": return abort(404)
|
if app.config["STATUS"] != "init": return abort(404)
|
||||||
req = request.get_json(force = True)
|
req = request.get_json(force = True)
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/enable_shared_from_this.hpp>
|
#include <boost/enable_shared_from_this.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind/bind.hpp>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
|
|
||||||
@@ -45,15 +45,15 @@ struct regex_rules{
|
|||||||
shared_ptr<regex_rules> regex_config;
|
shared_ptr<regex_rules> regex_config;
|
||||||
|
|
||||||
const char* config_file;
|
const char* config_file;
|
||||||
mutex mtx;
|
mutex update_mutex;
|
||||||
|
|
||||||
bool filter_data(unsigned char* data, const size_t& bytes_transferred, vector<pair<string,regex>> const &blacklist, vector<pair<string,regex>> const &whitelist){
|
bool filter_data(unsigned char* data, const size_t& bytes_transferred, vector<pair<string,regex>> const &blacklist, vector<pair<string,regex>> const &whitelist){
|
||||||
#ifdef DEBUG_PACKET
|
#ifdef DEBUG_PACKET
|
||||||
cout << "---------------- Packet ----------------" << endl;
|
cerr << "---------------- Packet ----------------" << endl;
|
||||||
for(int i=0;i<bytes_transferred;i++){
|
for(int i=0;i<bytes_transferred;i++){
|
||||||
cout << data[i];
|
cerr << data[i];
|
||||||
}
|
}
|
||||||
cout << "\n" << "---------------- End Packet ----------------" << endl;
|
cerr << "\n" << "---------------- End Packet ----------------" << endl;
|
||||||
#endif
|
#endif
|
||||||
for (pair<string,regex> ele:blacklist){
|
for (pair<string,regex> ele:blacklist){
|
||||||
try{
|
try{
|
||||||
@@ -76,7 +76,7 @@ bool filter_data(unsigned char* data, const size_t& bytes_transferred, vector<pa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
cout << "Packet Accepted!" << endl;
|
cerr << "Packet Accepted!" << endl;
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -325,7 +325,6 @@ namespace tcp_proxy
|
|||||||
}
|
}
|
||||||
|
|
||||||
void push_regex(char* arg, bool case_sensitive, vector<pair<string,regex>> &v){
|
void push_regex(char* arg, bool case_sensitive, vector<pair<string,regex>> &v){
|
||||||
std::unique_lock<std::mutex> lck(mtx);
|
|
||||||
size_t expr_len = (strlen(arg)-2)/2;
|
size_t expr_len = (strlen(arg)-2)/2;
|
||||||
char expr[expr_len];
|
char expr[expr_len];
|
||||||
unhexlify(arg+2, arg+strlen(arg)-1, expr);
|
unhexlify(arg+2, arg+strlen(arg)-1, expr);
|
||||||
@@ -334,13 +333,13 @@ void push_regex(char* arg, bool case_sensitive, vector<pair<string,regex>> &v){
|
|||||||
if (case_sensitive){
|
if (case_sensitive){
|
||||||
regex regex(expr_str);
|
regex regex(expr_str);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
cout << "Added case sensitive regex " << expr_str << endl;
|
cerr << "Added case sensitive regex " << expr_str << endl;
|
||||||
#endif
|
#endif
|
||||||
v.push_back(make_pair(string(arg), regex));
|
v.push_back(make_pair(string(arg), regex));
|
||||||
} else {
|
} else {
|
||||||
regex regex(expr_str,regex_constants::icase);
|
regex regex(expr_str,regex_constants::icase);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
cout << "Added case insensitive regex " << expr_str << endl;
|
cerr << "Added case insensitive regex " << expr_str << endl;
|
||||||
#endif
|
#endif
|
||||||
v.push_back(make_pair(string(arg), regex));
|
v.push_back(make_pair(string(arg), regex));
|
||||||
}
|
}
|
||||||
@@ -351,6 +350,7 @@ void push_regex(char* arg, bool case_sensitive, vector<pair<string,regex>> &v){
|
|||||||
|
|
||||||
|
|
||||||
void update_regex(){
|
void update_regex(){
|
||||||
|
std::unique_lock<std::mutex> lck(update_mutex);
|
||||||
fstream fd;
|
fstream fd;
|
||||||
fd.open(config_file,ios::in);
|
fd.open(config_file,ios::in);
|
||||||
if (!fd.is_open()){
|
if (!fd.is_open()){
|
||||||
@@ -397,13 +397,19 @@ void signal_handler(int signal_num)
|
|||||||
{
|
{
|
||||||
if (signal_num == SIGUSR1){
|
if (signal_num == SIGUSR1){
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
cout << "Updating configurtation" << endl;
|
cerr << "Updating configurtation" << endl;
|
||||||
#endif
|
#endif
|
||||||
update_regex();
|
update_regex();
|
||||||
}else if(signal_num == SIGTERM){
|
}else if(signal_num == SIGTERM){
|
||||||
if (ios_loop != nullptr) ios_loop->stop();
|
if (ios_loop != nullptr) ios_loop->stop();
|
||||||
|
#ifdef DEBUG
|
||||||
|
cerr << "Close Requested" << endl;
|
||||||
|
#endif
|
||||||
exit(0);
|
exit(0);
|
||||||
}else if (signal_num == SIGSEGV){
|
}else if (signal_num == SIGSEGV){
|
||||||
|
#ifdef DEBUG
|
||||||
|
cerr << "Forced Close" << endl;
|
||||||
|
#endif
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,126 +0,0 @@
|
|||||||
S3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
S3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
S3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
S3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
S3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
S3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1C3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1S3733353138303461313162386234323563313931613664373937666264356630
|
|
||||||
1C3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1S3065376433366539666631353833373263633764613966396235313538633766
|
|
||||||
1C3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1S3638316561366437356466353765656265383933396630326262393338336438
|
|
||||||
1C3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
1S3739663566343265663536633261656665623338346135616464633539663930
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 18 KiB |
@@ -29,23 +29,25 @@ The testing methodology will soon be updated with more edge-cases.
|
|||||||
# Running a Benchmark
|
# Running a Benchmark
|
||||||
./benchmark.py
|
./benchmark.py
|
||||||
options:
|
options:
|
||||||
-h, --help show this help message and exit
|
--address ADDRESS, -a ADDRESS
|
||||||
--address ADDRESS, -a ADDRESS
|
Address of firegex backend
|
||||||
Address of firegex backend
|
--service_port SERVICE_PORT, -P SERVICE_PORT
|
||||||
--service_port SERVICE_PORT, -P SERVICE_PORT
|
Port of the Benchmark service
|
||||||
Port of the Benchmark service
|
--service_name SERVICE_NAME, -n SERVICE_NAME
|
||||||
--service_name SERVICE_NAME, -n SERVICE_NAME
|
Name of the Benchmark service
|
||||||
Name of the Benchmark service
|
--password PASSWORD, -p PASSWORD
|
||||||
--password PASSWORD, -p PASSWORD
|
Firegex password
|
||||||
Firegex password
|
--num_of_regexes NUM_OF_REGEXES, -r NUM_OF_REGEXES
|
||||||
--num_of_regexes NUM_OF_REGEXES, -r NUM_OF_REGEXES
|
Number of regexes to benchmark with
|
||||||
Number of regexes to benchmark with
|
--duration DURATION, -d DURATION
|
||||||
--duration DURATION, -d DURATION
|
Duration of the Benchmark in seconds
|
||||||
Duration of the Benchmark in seconds
|
--output_file OUTPUT_FILE, -o OUTPUT_FILE
|
||||||
--output_file OUTPUT_FILE, -o OUTPUT_FILE
|
Output results csv file
|
||||||
Output results csv file
|
--num_of_streams NUM_OF_STREAMS, -s NUM_OF_STREAMS
|
||||||
|
Output results csv file
|
||||||
|
--new_istance, -i Create a new service
|
||||||
|
|
||||||
Benchmarks let you evaluate the performance of the proxy. You can run one by typing in a shell ```test.py -p FIREGEX_PASSWORD -r NUM_OF_REGEX -d BENCHMARK_DURATION```.
|
Benchmarks let you evaluate the performance of the proxy. You can run one by typing in a shell ```test.py -p FIREGEX_PASSWORD -r NUM_OF_REGEX -d BENCHMARK_DURATION -i```.
|
||||||
|
|
||||||
It uses iperf3 to benchmark the throughput in MB/s of the server, both with proxy, without proxy, and for each new added regex. It will automatically add a new random regex untill it has reached NUM_OF_REGEX specified in the arguments.
|
It uses iperf3 to benchmark the throughput in MB/s of the server, both with proxy, without proxy, and for each new added regex. It will automatically add a new random regex untill it has reached NUM_OF_REGEX specified in the arguments.
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ def puts(text, *args, color=colors.white, is_bold=False, **kwargs):
|
|||||||
|
|
||||||
def sep(): puts("-----------------------------------", is_bold=True)
|
def sep(): puts("-----------------------------------", is_bold=True)
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("--address", "-a", type=str , required=False, help='Address of firegex backend', default="http://127.0.0.1:5000/")
|
parser.add_argument("--address", "-a", type=str , required=False, help='Address of firegex backend', default="http://127.0.0.1:4444/")
|
||||||
parser.add_argument("--service_port", "-P", type=int , required=False, help='Port of the Benchmark service', default=1337)
|
parser.add_argument("--service_port", "-P", type=int , required=False, help='Port of the Benchmark service', default=1337)
|
||||||
parser.add_argument("--service_name", "-n", type=str , required=False, help='Name of the Benchmark service', default="Benchmark Service")
|
parser.add_argument("--service_name", "-n", type=str , required=False, help='Name of the Benchmark service', default="Benchmark Service")
|
||||||
parser.add_argument("--password", "-p", type=str, required=True, help='Firegex password')
|
parser.add_argument("--password", "-p", type=str, required=True, help='Firegex password')
|
||||||
@@ -127,4 +127,4 @@ if args.new_istance:
|
|||||||
assert req.json()["status"] == "ok", f"Benchmark Failed: Couldn't delete service {req.text}"
|
assert req.json()["status"] == "ok", f"Benchmark Failed: Couldn't delete service {req.text}"
|
||||||
puts(f"Sucessfully delete service with id {service_id} ✔", color=colors.green)
|
puts(f"Sucessfully delete service with id {service_id} ✔", color=colors.green)
|
||||||
|
|
||||||
server.terminate()
|
server.terminate()
|
||||||
|
|||||||
Reference in New Issue
Block a user