Created
October 18, 2024 12:46
-
-
Save bauruine/50dcb28e91cf30277b1cd17f3c6e3f5a to your computer and use it in GitHub Desktop.
print_bridgeline.sh
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
| #!/usr/bin/env bash | |
| # | |
| # This script extracts the pieces that we need to compile our bridge line. | |
| # This will have to do until the following bug is fixed: | |
| # <https://gitlab.torproject.org/tpo/core/tor/-/issues/29128> | |
| TOR_DAEMON=tor@default | |
| PT_STATE=/var/lib/tor/pt_state/obfs4_bridgeline.txt | |
| addr=$(journalctl -u "$TOR_DAEMON" | grep 'is reachable from the outside' | grep -vP "\[.+:.*\[" | \ | |
| grep -Po "(?:[0-9]{1,3}\.){3}[0-9]{1,3}" | \ | |
| tail -1) | |
| port=$(journalctl -u "$TOR_DAEMON" | grep "Registered server transport 'obfs4' at" | \ | |
| sed "s/.*:\([0-9]\{1,5\}\)'$/\1/" | \ | |
| tail -1) | |
| fingerprint=$(journalctl -u "$TOR_DAEMON" | grep "Your Tor server's identity key *fingerprint is" | \ | |
| sed "s/.*\([0-9A-F]\{40\}\)'$/\1/" | \ | |
| tail -1) | |
| obfs4_args=$(grep '^Bridge obfs4' "$PT_STATE" | sed 's/.*\(cert=.*\)/\1/' | \ | |
| tail -1) | |
| if [[ "$addr" = "" || "$port" = "" || "$fingerprint" = "" || "$obfs4_args" = "" ]] | |
| then | |
| echo "Could not create bridge line. Tor's log format may have changed. This is a bug." | |
| exit 1 | |
| fi | |
| echo "obfs4 ${addr}:${port} ${fingerprint} ${obfs4_args}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment