Always fixing things

This commit is contained in:
Quentin 2021-01-27 17:56:29 +01:00
parent 1262d08278
commit 1a8e088431
2 changed files with 42 additions and 29 deletions

View File

@ -1,31 +1,36 @@
#!/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
echo "tor daemon serv"
/usr/bin/tor \
-f /tmp/empty --defaults-torrc /tmp/empty \
--hush \
--UseEntryGuards 0 \
--SocksPort 0 \
--ControlPort $CONTROL_PORT \
--DataDirectory /tmp/tor$CONTROL_PORT &
--DataDirectory /tmp/tor$CONTROL_PORT | red &
sleep 1
echo "tor client serv"
/usr/bin/tor \
-f /tmp/empty --defaults-torrc /tmp/empty \
--hush \
--UseEntryGuards 0 \
--SocksPort "127.0.0.1:$SOCK_PORT IsolateDestPort IsolateDestAddr IsolateClientAddr" \
--DataDirectory /tmp/tor$SOCK_PORT &
--DataDirectory /tmp/tor$SOCK_PORT | green &
sleep 1
echo "donar serv"
rm -rf state_$LOCAL_PORT/
mkdir state_$LOCAL_PORT/
pushd .
@ -36,10 +41,10 @@ cd state_$LOCAL_PORT/
-q $CONTROL_PORT \
-k $DONAR_PORT \
-l 2 \
-e $LOCAL_PORT &
-b \
-e $LOCAL_PORT 2>&1 | yellow &
sleep 1
echo "donar client"
/usr/local/bin/donar \
-c \
-a dup2 \
@ -47,37 +52,40 @@ echo "donar client"
-k $DONAR_PORT \
-o ./onion_services.pub \
-l 2 \
-r $LOCAL_PORT &
-b \
-r $LOCAL_PORT 2>&1 | blue &
sleep 1
popd
echo "measlat serv"
/usr/local/bin/measlat \
-l \
-t udp \
-h 127.0.0.1 \
-p $LOCAL_PORT \
-c 135 \
-c 1350 \
-i 40 \
-s 172 &
-m torfone \
-s 172 2>&1 | cyan &
sleep 1
echo "measlat client bootstrap"
/usr/local/bin/measlat \
-t udp \
-h 127.13.3.7 \
-p $LOCAL_PORT \
-b \
-c 1 \
-i 1000 \
-s 172
-i 5000 \
-m torfone \
-s 172 2>&1 | purple
echo "measlat client collect"
/usr/local/bin/measlat \
-t udp \
-h 127.13.3.7 \
-p $LOCAL_PORT \
-c 135 \
-c 1350 \
-i 40 \
-s 172
-m torfone \
-s 172 2>&1 | purple
kill $(jobs -p)
done

View File

@ -151,7 +151,22 @@ int on_receive_measure_packet(struct evt_core_ctx* ctx, struct evt_core_fdinfo*
// 3. Process data in our measurement object
measure_parse (&mctx->mp, ms, mctx->verbose);
// 4. Persist our measurement object if needed
// 4. Detect if it is a probe
if (ms->mp_in->probe) { // Allow for probing without registering a timer
int s = mctx->connectionless && mctx->role == MEASLAT_SERVER ?
sendto(ms->fd, ms->mp_in, mctx->mp.payload_size, 0, (struct sockaddr*)&mctx->addr, mctx->addrlen) :
send(ms->fd, ms->mp_in, mctx->mp.payload_size, 0);
if (!mctx->connectionless || mctx->role == MEASLAT_CLIENT)
evt_core_rm_fd (ctx, fdinfo->fd);
if (mctx->role == MEASLAT_CLIENT)
exit(EXIT_SUCCESS);
return 1;
}
// 5. Persist our measurement object if needed
// It includes starting a timer.
if (ms == &ms_transi) {
if (ms->mp_in->counter != 1) { // Guard against rando scanning the IPv4 range
@ -159,16 +174,6 @@ int on_receive_measure_packet(struct evt_core_ctx* ctx, struct evt_core_fdinfo*
evt_core_rm_fd (ctx, fdinfo->fd);
return 1;
}
if (ms->mp_in->probe) { // Allow for probing without registering a timer
int s = mctx->connectionless && mctx->role == MEASLAT_SERVER ?
sendto(ms->fd, ms->mp_in, mctx->mp.payload_size, 0, (struct sockaddr*)&mctx->addr, mctx->addrlen) :
send(ms->fd, ms->mp_in, mctx->mp.payload_size, 0);
if (!(mctx->connectionless && mctx->role == MEASLAT_SERVER))
evt_core_rm_fd (ctx, fdinfo->fd);
return 1;
}
struct timespec next_tick = {0};
struct measure_state ms_new = {0};
measure_state_init(&mctx->mp, &ms_new);
@ -179,7 +184,7 @@ int on_receive_measure_packet(struct evt_core_ctx* ctx, struct evt_core_fdinfo*
assoc_timer = register_timer (ctx, mctx, &ms_new, &next_tick);
}
// 5. Check if our measurements are done
// 6. Check if our measurements are done
if (ms->mp_in->counter >= mctx->mp.max_measure && ms->mp_out->counter >= mctx->mp.max_measure) {
measlat_stop(ctx, mctx, ms, fdinfo->fd, assoc_timer->fd);
return 1;