diff --git a/scripts/Makefile b/scripts/Makefile index 5983cbf..72ce788 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -3,11 +3,10 @@ SHELL := /bin/bash simple_test: ./run-3 \ 1,simple_test . \ - thunder-client 600 100 100 8 . \ - thunder-server 8 . \ + thunder-client 600 100 100 8 150 . \ + thunder-server 8 150 . \ tor3 -f /etc/torrc_simple . \ tor3 -f /etc/torrc_simple - tor_bw_small: ./run-3 \ 1,tor_bw_small . \ diff --git a/scripts/run-3 b/scripts/run-3 index 290b046..6fe7ead 100755 --- a/scripts/run-3 +++ b/scripts/run-3 @@ -103,7 +103,7 @@ echo " launch clients" echo " instance=$i - exec=${CLIENT_TARGETS[$i]}" docker exec donarxp_client_$i ${CLIENT_TARGETS[$i]} ${run_fold}-$i & sleep 10 - done; wait; echo " ok"; kill -9 $subshellpid)) 2>/dev/null + done; wait; echo " ok"; docker exec donarxp_client_${i} killall -15 donar; docker exec donarxp_server_${i} killall -15 donar; kill -15 $subshellpid)) 2>/dev/null done diff --git a/scripts/thunder-client b/scripts/thunder-client index 601ec5d..8113e35 100755 --- a/scripts/thunder-client +++ b/scripts/thunder-client @@ -1,10 +1,11 @@ #!/bin/bash -mkdir -p $5/{log,shared,res} +mkdir -p $6/{log,shared,res} donar \ -a thunder \ -c \ - -o $5/shared/onion_services.pub \ + -o $6/shared/onion_services.pub \ -l $4 \ + -p $5 \ -b \ -r 9000 \ > $5/log/client-donar-stdout.log 2> $5/log/client-donar-stderr.log & diff --git a/scripts/thunder-server b/scripts/thunder-server index 0ec570f..1b2af24 100755 --- a/scripts/thunder-server +++ b/scripts/thunder-server @@ -1,11 +1,12 @@ #!/bin/bash -mkdir -p $2/{log,shared} -cd $2/shared +mkdir -p $3/{log,shared} +cd $3/shared donar \ -a thunder \ -s \ -l $1 \ + -p $2 \ -b \ -e 9000 \ > ../log/server-donar-stdout.log 2> ../log/server-donar-stderr.log & diff --git a/src/algo_thunder.c b/src/algo_thunder.c index 3b30208..c5ee743 100644 --- a/src/algo_thunder.c +++ b/src/algo_thunder.c @@ -20,6 +20,7 @@ struct thunder_ctx { uint64_t received_pkts_on_link[MAX_LINKS]; uint64_t blacklisted[MAX_LINKS]; size_t monit_pkt_size; + uint64_t allowed_jitter_ms; struct timespec prev_link_time, prev_rcv_link_time; }; @@ -372,12 +373,18 @@ void algo_thunder_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, struc thunderc->emit_id = 1; thunderc->total_links = app_ctx->ap.links; thunderc->selected_link = thunderc->total_links - 1; + thunderc->allowed_jitter_ms = 200; for (int i = 0; i < MAX_LINKS; i++) thunderc->received_pkts_on_link[i] = 1; union abstract_packet links = {}; //fprintf(stderr, "Total links %d\n", thunderc->total_links); thunderc->monit_pkt_size = sizeof(links.fmt.headers) + sizeof(links.fmt.content.link_monitoring_thunder) + sizeof(struct link_info) * (thunderc->total_links - 1); + if (ap->algo_specific_params != NULL) { + sscanf(ap->algo_specific_params, "%ld", &thunderc->allowed_jitter_ms); + } + printf("Allowed jitter set to %ld ms\n", thunderc->allowed_jitter_ms); + init_timer(ctx); } diff --git a/src/donar.c b/src/donar.c index 058ec8c..fa283b5 100644 --- a/src/donar.c +++ b/src/donar.c @@ -14,7 +14,7 @@ int main(int argc, char** argv) { struct donar_params dp = {0}; donar_init_params (&dp); - while ((dp.opt = getopt(argc, argv, "nvcse:r:o:a:bhl:d:f:i:")) != -1) { + while ((dp.opt = getopt(argc, argv, "nvcse:r:o:a:bl:d:f:i:p:")) != -1) { switch(dp.opt) { case 'n': dp.tof |= TOR_ONION_FLAG_NON_ANONYMOUS; @@ -44,8 +44,8 @@ int main(int argc, char** argv) { case 'a': dp.algo = strdup(optarg); break; - case 'h': - dp.is_healing = 1; + case 'p': + dp.algo_specific_params = strdup(optarg); break; case 'b': dp.is_waiting_bootstrap = 1; @@ -95,6 +95,7 @@ terminate: if (dp.algo != NULL) free(dp.algo); if (dp.capture_file != NULL) free(dp.capture_file); if (dp.bound_ip != NULL) free(dp.bound_ip); + if (dp.algo_specific_params != NULL) free(dp.algo_specific_params); g_ptr_array_free(dp.exposed_ports, TRUE); g_ptr_array_free(dp.remote_ports, TRUE); diff --git a/src/donar_client.c b/src/donar_client.c index 0f1246f..14314af 100644 --- a/src/donar_client.c +++ b/src/donar_client.c @@ -72,7 +72,7 @@ void init_socks5_sinks(struct donar_client_ctx* app_ctx) { void donar_client(struct donar_client_ctx* ctx, struct donar_params* dp) { struct algo_params ap = { .is_waiting_bootstrap = dp->is_waiting_bootstrap, - .is_healing = dp->is_healing, + .algo_specific_params = dp->algo_specific_params, .algo_name = dp->algo, .links = dp->links, .fresh_data = dp->fresh_data, diff --git a/src/donar_init.c b/src/donar_init.c index 0975f47..b6a1ce7 100644 --- a/src/donar_init.c +++ b/src/donar_init.c @@ -20,7 +20,7 @@ int on_signal(struct evt_core_ctx* evts, struct evt_core_fdinfo* fdinfo) { } printf("Signal received: %d\n", fdsi.ssi_signo); - if (fdsi.ssi_signo == SIGINT || fdsi.ssi_signo == SIGQUIT) { + if (fdsi.ssi_signo == SIGINT || fdsi.ssi_signo == SIGQUIT || fdsi.ssi_signo == SIGTERM) { printf("Stop main loop and quit\n"); evts->loop = 0; } @@ -42,6 +42,7 @@ void signal_init(struct evt_core_ctx* evts) { sigaddset(&mask, SIGINT); sigaddset(&mask, SIGQUIT); + sigaddset(&mask, SIGTERM); if (sigprocmask(SIG_BLOCK, &mask, NULL) == -1) { perror("sigprocmask"); exit(EXIT_FAILURE); @@ -150,7 +151,7 @@ void donar_init_params(struct donar_params* dp) { dp->bound_ip = NULL; dp->is_server = 0; dp->is_client = 0; - dp->is_healing = 0; + dp->algo_specific_params = NULL; dp->is_waiting_bootstrap = 0; dp->errored = 0; dp->links = 8; diff --git a/src/donar_init.h b/src/donar_init.h index ac29df2..8b9c781 100644 --- a/src/donar_init.h +++ b/src/donar_init.h @@ -10,8 +10,8 @@ #include "tor_ctl.h" struct donar_params { - int opt, is_server, is_client, is_waiting_bootstrap, is_healing, errored, verbose, links, fresh_data, redundant_data; - char *bound_ip, *port, *onion_file, *algo, *capture_file; + int opt, is_server, is_client, is_waiting_bootstrap, errored, verbose, links, fresh_data, redundant_data; + char *bound_ip, *port, *onion_file, *algo, *capture_file, *algo_specific_params; GPtrArray *remote_ports, *exposed_ports; enum TOR_ONION_FLAGS tof; }; diff --git a/src/donar_server.c b/src/donar_server.c index eeccc4a..2208fa0 100644 --- a/src/donar_server.c +++ b/src/donar_server.c @@ -54,7 +54,7 @@ socket_create_err: void donar_server(struct donar_server_ctx* ctx, struct donar_params* dp) { struct algo_params ap = { .is_waiting_bootstrap = dp->is_waiting_bootstrap, - .is_healing = dp->is_healing, + .algo_specific_params = dp->algo_specific_params, .algo_name = dp->algo, .links = dp->links, .fresh_data = dp->fresh_data, diff --git a/src/proxy.h b/src/proxy.h index 7fbbaba..9d115f9 100644 --- a/src/proxy.h +++ b/src/proxy.h @@ -13,8 +13,7 @@ struct algo_params { uint8_t is_waiting_bootstrap; - uint8_t is_healing; - char *algo_name, *capture_file; + char *algo_name, *capture_file, *algo_specific_params; int links, fresh_data, redundant_data; };