Dump circuits tor

This commit is contained in:
Quentin Dufour 2019-04-17 15:51:27 +02:00
parent b6e9772304
commit c069e495d0
1 changed files with 40 additions and 0 deletions

40
scripts/dump_circuits Executable file
View File

@ -0,0 +1,40 @@
#!/bin/bash
declare -A circuits
declare -A streams
while read l; do
id=$(echo $l|grep -Po '^\d+')
circ=$(echo $l \
| grep -Po '[^ ]*$' \
| sed 's/,/ /g' \
| tr -d "\r")
#echo $id ++ ${circ[@]}
circuits[$id]=$circ
done <<< $( {
nc 127.0.0.1 9051 <<EOF
authenticate ""
getinfo circuit-status
quit
EOF
} | grep -Po '^\d+ BUILT [^ ]*' )
while read l; do
id=$(echo $l \
| grep -Po '^\d+ SUCCEEDED \d+' \
|grep -Po '\d+$')
url=$(echo $l \
|grep -Po '[^ ]*$' \
|tr -d "\r")
streams[$id]=$url
done <<< $( {
nc 127.0.0.1 9051 <<EOF
authenticate ""
getinfo stream-status
quit
EOF
} | grep -Po '^\d+ SUCCEEDED \d+ [^ ]*' )
for key in "${!streams[@]}"; do
echo "${streams[$key]} --> ${circuits[$key]}"
done