-
Notifications
You must be signed in to change notification settings - Fork 0
/
show-bridge-line
executable file
·29 lines (25 loc) · 1.19 KB
/
show-bridge-line
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env bash
#
# Get the "bridge line" for this bridge. This is the configuration TOR clients
# need to connect to the bridge.
#
# Original script:
# https://gitlab.torproject.org/tpo/anti-censorship/docker-obfs4-bridge/-/blob/303c90fbfde8ea3ac8985b9d79b8d4db0d1704d2/get-bridge-line
set -Eeuo pipefail
# CONFIG must be set.
config="${CONFIG}"
addr="$(flyctl ips list --json --config "${config}" | \
jq --raw-output '.[] | select(.Type == "v4") | .Address')"
port="$(flyctl config display --config "${config}" | \
jq '.services[1].ports[0].port')"
fingerprint="$(flyctl ssh console --command 'cat /var/log/tor/log' --config "${config}" | \
sed $'s/\r$//' | \
sed "s|^.*Your Tor server's identity key *fingerprint is .*\([0-9A-F]\{40\}\)'$|\1|gp;d")"
obfs4_args="$(flyctl ssh console --command 'cat /var/lib/tor/pt_state/obfs4_bridgeline.txt' --config "${config}" | \
sed "s|^Bridge obfs4 .*\(cert=.*\)$|\1|gp;d")"
obfs4_args="${obfs4_args%"${obfs4_args##*[![:space:]]}"}" # Remove trailing whitespace.
obfs4_line="obfs4 ${addr}:${port} ${fingerprint} ${obfs4_args}"
echo "${obfs4_line}"
if command -v qrencode >/dev/null 2>&1; then
echo "${obfs4_line}" | tr -d '\n' | qrencode -t UTF8
fi