Skip to content

Instantly share code, notes, and snippets.

@sinsukehlab
Created November 8, 2022 07:28
Show Gist options
  • Save sinsukehlab/88433b1315578c1912af3f9bcdcbcba6 to your computer and use it in GitHub Desktop.
Save sinsukehlab/88433b1315578c1912af3f9bcdcbcba6 to your computer and use it in GitHub Desktop.
Edit torrc with jq
#!/bin/sh
badexitpath='http://dud2sxm6feahhuwj4y4lzktduy7v3qpaqsfkggtj2ojmzathttkegoid.onion/summary?flag=badexit'
while IFS= read -r name && IFS= read -r finger; do
echo $name
echo $finger
if [[ $(grep -c $name /etc/tor/torrc) == 0 && $(grep -c $finger /etc/tor/torrc) == 0 ]]; then
echo "not found"
sed -i "/^ExcludeNodes/s/$/,$finger/" /etc/tor/torrc
fi
done < <(torsocks curl -s ${badexitpath} | jq -r '.relays | .[] | (.n, .f)')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment