Last active
April 17, 2019 13:58
-
-
Save superboum/df20d533e3fa60a413c6f330af20e5d2 to your computer and use it in GitHub Desktop.
Tor Streams To Circuits Mapping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
declare -A circuits | |
declare -A streams | |
# CircuitID SP CircStatus [SP Path] | |
# We capture CircuitID and Path | |
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 [^ ]*' ) | |
# StreamID SP StreamStatus SP CircuitID SP Target CRLF | |
# We capture CircuitID and Target | |
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+ [^ ]*' ) | |
# We show Target --> Path | |
for key in "${!streams[@]}"; do | |
echo "${streams[$key]} --> ${circuits[$key]}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment