more logs + choose tor port

This commit is contained in:
Quentin 2021-01-14 14:36:01 +01:00
parent 0927433344
commit b5ad9f495e

View file

@ -18,7 +18,7 @@ struct measlat_ctx {
struct sockaddr_in addr; struct sockaddr_in addr;
socklen_t addrlen; socklen_t addrlen;
int verbose, connectionless, tor_flags; int verbose, connectionless, tor_flags;
char *host, *port, *transport; char *host, *port, *transport, *tor_port;
enum { MEASLAT_CLIENT = 0, MEASLAT_SERVER = 1 } role; enum { MEASLAT_CLIENT = 0, MEASLAT_SERVER = 1 } role;
struct measure_params mp; struct measure_params mp;
}; };
@ -78,6 +78,7 @@ struct evt_core_fdinfo* register_timer(struct evt_core_ctx* evts, struct measlat
sprintf(fdinfo.url, "timer:%d", msheap->fd); sprintf(fdinfo.url, "timer:%d", msheap->fd);
struct evt_core_fdinfo *new_fdinfo = evt_core_add_fd (evts, &fdinfo); struct evt_core_fdinfo *new_fdinfo = evt_core_add_fd (evts, &fdinfo);
printf("--- Timer registered\n"); printf("--- Timer registered\n");
printf("[states] measurement %d+%d started\n", msheap->fd, fdinfo.fd);
return new_fdinfo; return new_fdinfo;
} }
@ -99,7 +100,7 @@ void measlat_stop(
if (ms->mp_in->counter < mctx->mp.max_measure) return; if (ms->mp_in->counter < mctx->mp.max_measure) return;
if (ms->mp_out->counter < mctx->mp.max_measure) return; if (ms->mp_out->counter < mctx->mp.max_measure) return;
printf("All measurements done\n"); printf("[states] measurement %d+%d terminated\n", net_fd, timer_fd);
evt_core_rm_fd(ctx, timer_fd); evt_core_rm_fd(ctx, timer_fd);
if (!(mctx->connectionless && mctx->role == MEASLAT_SERVER)) if (!(mctx->connectionless && mctx->role == MEASLAT_SERVER))
evt_core_rm_fd(ctx, net_fd); evt_core_rm_fd(ctx, net_fd);
@ -272,7 +273,7 @@ void spawn_tor_client(struct evt_core_ctx* evts) {
} }
struct measlat_ctx* mctx = ucat->app_ctx; struct measlat_ctx* mctx = ucat->app_ctx;
socks5_create_dns_client (evts, "127.0.0.1", "9050", mctx->host, atoi(mctx->port)); socks5_create_dns_client (evts, "127.0.0.1", mctx->tor_port, mctx->host, atoi(mctx->port));
printf("--- Tor client SOCKS started\n"); printf("--- Tor client SOCKS started\n");
} }
@ -472,7 +473,7 @@ int main(int argc, char** argv) {
struct tor_ctl tctl = {0}; struct tor_ctl tctl = {0};
// 1. Parse parameters // 1. Parse parameters
while ((opt = getopt(argc, argv, "vh:p:c:s:i:t:ln")) != -1) { while ((opt = getopt(argc, argv, "vq:h:p:c:s:i:t:ln")) != -1) {
switch(opt) { switch(opt) {
case 'v': case 'v':
mctx.verbose++; mctx.verbose++;
@ -483,6 +484,9 @@ int main(int argc, char** argv) {
case 'p': // port case 'p': // port
mctx.port = optarg; mctx.port = optarg;
break; break;
case 'q':
mctx.tor_port = optarg;
break;
case 'l': case 'l':
mctx.role = MEASLAT_SERVER; mctx.role = MEASLAT_SERVER;
break; break;
@ -513,9 +517,10 @@ int main(int argc, char** argv) {
if (strcmp(mctx.transport, "udp") == 0) mctx.connectionless = 1; if (strcmp(mctx.transport, "udp") == 0) mctx.connectionless = 1;
if (mctx.host == NULL) mctx.host = "127.0.0.1"; if (mctx.host == NULL) mctx.host = "127.0.0.1";
if (mctx.port == NULL) mctx.port = mctx.connectionless ? "9000" : "7500"; if (mctx.port == NULL) mctx.port = mctx.connectionless ? "9000" : "7500";
if (mctx.tor_port == NULL) mctx.tor_port = "9050";
printf("[measlat_conf] host=%s, port=%s, listen=%d, transport=%s, count=%ld, size=%ld, interval=%ld\n", printf("[measlat_conf] host=%s, port=%s, listen=%d, transport=%s, count=%ld, size=%ld, interval=%ld, tor_port=%s\n",
mctx.host, mctx.port, mctx.role, mctx.transport, mctx.mp.max_measure, mctx.mp.payload_size, mctx.mp.interval); mctx.host, mctx.port, mctx.role, mctx.transport, mctx.mp.max_measure, mctx.mp.payload_size, mctx.mp.interval, mctx.tor_port);
// 3. Create event structure // 3. Create event structure
register_categories(&evts, &mctx); register_categories(&evts, &mctx);