From eb1dad3ceadd9ba1647d5f9b95d304641bd7f1ac Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Wed, 27 Jan 2021 22:35:12 +0100 Subject: [PATCH] WIP --- scripts/2021/donaralt | 99 +++++++++++++++++++++++++++++++++++++++++++ scripts/2021/donardup | 6 +-- src/proxy.c | 3 +- src/proxy.h | 1 + 4 files changed, 105 insertions(+), 4 deletions(-) create mode 100755 scripts/2021/donaralt diff --git a/scripts/2021/donaralt b/scripts/2021/donaralt new file mode 100755 index 0000000..ea7a414 --- /dev/null +++ b/scripts/2021/donaralt @@ -0,0 +1,99 @@ +#!/bin/bash + +red() { IFS= ; while read -r line; do echo -e '\e[31m'$line'\e[0m'; done; } +green() { IFS= ; while read -r line; do echo -e '\e[32m'$line'\e[0m'; done; } +yellow() { IFS= ; while read -r line; do echo -e '\e[33m'$line'\e[0m'; done; } +blue() { IFS= ; while read -r line; do echo -e '\e[34m'$line'\e[0m'; done; } +purple() { IFS= ; while read -r line; do echo -e '\e[35m'$line'\e[0m'; done; } +cyan() { IFS= ; while read -r line; do echo -e '\e[36m'$line'\e[0m'; done; } + +SOCK_PORT=$((9000+$1)) +CONTROL_PORT=$((9100+$1)) +LOCAL_PORT=$((9200+$1)) +DONAR_PORT=$((7000+$1*12)) + +while true; do +touch /tmp/empty +rm -rf /tmp/tor$CONTROL_PORT +/usr/bin/tor \ + -f /tmp/empty --defaults-torrc /tmp/empty \ + --hush \ + --UseEntryGuards 1 \ + --NumEntryGuards 2 \ + --NumPrimaryGuards 2 \ + --SocksPort 0 \ + --ControlPort $CONTROL_PORT \ + --DataDirectory /tmp/tor$CONTROL_PORT | red & +sleep 1 + +rm -rf /tmp/tor$SOCK_PORT +/usr/bin/tor \ + -f /tmp/empty --defaults-torrc /tmp/empty \ + --hush \ + --UseEntryGuards 1 \ + --NumEntryGuards 2 \ + --NumPrimaryGuards 2 \ + --SocksPort "127.0.0.1:$SOCK_PORT IsolateDestPort IsolateDestAddr IsolateClientAddr" \ + --DataDirectory /tmp/tor$SOCK_PORT | green & +sleep 1 + +rm -rf state_$LOCAL_PORT/ +mkdir state_$LOCAL_PORT/ +pushd . +cd state_$LOCAL_PORT/ +/usr/local/bin/donar \ + -s \ + -a lightning \ + -q $CONTROL_PORT \ + -k $DONAR_PORT \ + -l 12 \ + -p 'fast_count=3!tick_tock=1!measlat=0!window=2000' \ + -b \ + -e $LOCAL_PORT 2>&1 | yellow & +sleep 1 + +/usr/local/bin/donar \ + -c \ + -a lightning \ + -q $SOCK_PORT \ + -k $DONAR_PORT \ + -o ./onion_services.pub \ + -l 12 \ + -p 'fast_count=3!tick_tock=1!measlat=0!window=2000' \ + -b \ + -r $LOCAL_PORT 2>&1 | blue & +sleep 1 +popd + +/usr/local/bin/measlat \ + -l \ + -t udp \ + -h 127.0.0.1 \ + -p $LOCAL_PORT \ + -c 135000 \ + -i 40 \ + -m donaralt \ + -s 172 2>&1 | cyan & +sleep 1 + +/usr/local/bin/measlat \ + -t udp \ + -h 127.13.3.7 \ + -p $LOCAL_PORT \ + -b \ + -c 1 \ + -i 5000 \ + -m donaralt \ + -s 172 2>&1 | purple + +/usr/local/bin/measlat \ + -t udp \ + -h 127.13.3.7 \ + -p $LOCAL_PORT \ + -c 135000 \ + -i 40 \ + -m donaralt \ + -s 172 2>&1 | purple + +kill -9 $(jobs -p) +done diff --git a/scripts/2021/donardup b/scripts/2021/donardup index baea86f..7c0cff4 100755 --- a/scripts/2021/donardup +++ b/scripts/2021/donardup @@ -70,7 +70,7 @@ popd -t udp \ -h 127.0.0.1 \ -p $LOCAL_PORT \ - -c 1350 \ + -c 135000 \ -i 40 \ -m donardup \ -s 172 2>&1 | cyan & @@ -90,10 +90,10 @@ sleep 1 -t udp \ -h 127.13.3.7 \ -p $LOCAL_PORT \ - -c 1350 \ + -c 135000 \ -i 40 \ -m donardup \ -s 172 2>&1 | purple -kill $(jobs -p) +kill -9 $(jobs -p) done diff --git a/src/proxy.c b/src/proxy.c index e3e73e1..12a5099 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -102,8 +102,9 @@ int main_on_tcp_write(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) // 0. Show some information about circuits uint8_t is_rdy = fdinfo->cat->socklist->len >= app_ctx->link_count ? 1 : 0; if (!app_ctx->is_rdy && is_rdy) printf("=== Our %d requested circuits are now up ===\n", app_ctx->link_count); - else if (app_ctx->is_rdy && !is_rdy) printf("=== Only %d/%d circuits are available, results could be biased ===\n", fdinfo->cat->socklist->len, app_ctx->link_count); + else if (app_ctx->is_rdy && !is_rdy && fdinfo->cat->socklist->len != app_ctx->past_links) printf("=== Only %d/%d circuits are available, results could be biased ===\n", fdinfo->cat->socklist->len, app_ctx->link_count); app_ctx->is_rdy = app_ctx->is_rdy || is_rdy; // we don't want deactivation finally, after all the test is running + app_ctx->past_links = fdinfo->cat->socklist->len; // 1. Get current write buffer OR a buffer from the waiting queue OR leave if ((bp = get_write_buffer(&app_ctx->br, fdinfo)) == NULL) return 1; diff --git a/src/proxy.h b/src/proxy.h index 2c298dd..6b618ac 100644 --- a/src/proxy.h +++ b/src/proxy.h @@ -39,6 +39,7 @@ struct algo_ctx { struct algo_desc* desc; uint8_t link_count; uint8_t is_rdy; + uint8_t past_links; struct algo_params ap; int ref_count; uint64_t udp_rcv, udp_sent, cell_rcv, cell_sent;