diff --git a/src/donar.c b/src/donar.c index cbe4fb0..e3085d0 100644 --- a/src/donar.c +++ b/src/donar.c @@ -11,7 +11,7 @@ int main(int argc, char** argv) { setvbuf(stdout, NULL, _IONBF, 0); printf("~ Donar ~\n"); - timing_fx_init (&static_tfx, TIMING_ACTIVATED | TIMING_DISPLAY_END, "", "fn=%s"); + timing_fx_init (static_tfx(), TIMING_ACTIVATED | TIMING_DISPLAY_END, "", "fn=%s"); struct donar_params dp = {0}; donar_init_params (&dp); diff --git a/src/meas_lat.c b/src/meas_lat.c index 985c645..25df406 100644 --- a/src/meas_lat.c +++ b/src/meas_lat.c @@ -335,7 +335,7 @@ void spawn_udp_server(struct evt_core_ctx* evts) { printf("--- UDP server is listening\n"); } -void spawn_tor_server(struct evt_core_ctx* evts, uint16_t *ports) { +void spawn_tcp_server(struct evt_core_ctx* evts, uint16_t *ports) { char buffer[1024]; int tcp_serv_sock, err; @@ -438,13 +438,13 @@ int main(int argc, char** argv) { if (mctx.mc.is_server && strcmp(mctx.transport, "udp") == 0) { spawn_udp_server (&evts); mctx.is_from_needed = 1; - } else if (mctx.mc.is_server && strcmp(mctx.transport, "tor") == 0) { - spawn_tor_server(&evts, ports); + spawn_tcp_server(&evts, ports); measlat_create_onion_services (&tos, &tctl, ports, ports_count, mctx.tor_flags); printf("--- Onion services created\n"); } + else if (mctx.mc.is_server && strcmp(mctx.transport, "tcp") == 0) spawn_tcp_server(&evts, ports); else if (strcmp(mctx.transport, "udp") == 0) spawn_udp_client(&evts); else if (strcmp(mctx.transport, "tor") == 0) spawn_tor_client(&evts); else exit(EXIT_FAILURE); diff --git a/src/socks5.h b/src/socks5.h index 3fc16db..3365a60 100644 --- a/src/socks5.h +++ b/src/socks5.h @@ -1,4 +1,5 @@ #pragma once + #include #include #include diff --git a/src/stopwatch.c b/src/stopwatch.c index 1d409f9..dfe2639 100644 --- a/src/stopwatch.c +++ b/src/stopwatch.c @@ -1,5 +1,9 @@ #include "stopwatch.h" +struct timing_fx _static_tfx; + +struct timing_fx* static_tfx() { return &_static_tfx; } + void timing_fx_init(struct timing_fx* tfx, enum timing_config conf, char* startt, char* endt) { tfx->config = conf; strncpy (tfx->start_template, startt, sizeof(tfx->start_template) - 1); diff --git a/src/stopwatch.h b/src/stopwatch.h index 9efaa4a..02738f7 100644 --- a/src/stopwatch.h +++ b/src/stopwatch.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef donar_stopwatch +#define donar_stopwatch #include #include @@ -22,8 +23,8 @@ struct timing_fx { char start_template[255], end_template[255]; }; -struct timing_fx static_tfx; - +struct timing_fx* static_tfx(); void timing_fx_init(struct timing_fx* tfx, enum timing_config conf, char* startt, char* endt); void timing_fx_start(struct timing_fx* tfx, ...); double timing_fx_stop(struct timing_fx* tfx, ...); +#endif diff --git a/src/test.c b/src/test.c index 15d48a6..520863a 100644 --- a/src/test.c +++ b/src/test.c @@ -10,9 +10,9 @@ int main(int argc, char** argv) { setvbuf(stdout, NULL, _IONBF, 0); printf("~ test ~\n"); - timing_fx_init (&static_tfx, TIMING_ACTIVATED|TIMING_DISPLAY_END, "", "info=%s"); - timing_fx_start (&static_tfx); + timing_fx_init (static_tfx (), TIMING_ACTIVATED|TIMING_DISPLAY_END, "", "info=%s"); + timing_fx_start (static_tfx()); sleep(1); - timing_fx_stop(&static_tfx, "sleep(1)"); + timing_fx_stop(static_tfx(), "sleep(1)"); }