Merge branch 'defect/30941' into develop
[tor-bridgedb.git] / scripts / externalize-pt-client
blobbbe01c6a13f1433c6b5df7444443bb80d0789bfc
1 #!/bin/bash
2 set -e
3 CMDLINE="${@:?need a meek-client command line}"
4 TRANSPORTS=meek
5 # This could be controlled by a command-line arg.
6 PORT=10000
7 TOR_PT_MANAGED_TRANSPORT_VER=1 \
8 TOR_PT_CLIENT_TRANSPORTS="$TRANSPORTS" $CMDLINE \
9 | sed -n -u -e '/^CMETHOD /{s/^.*127\.0\.0\.1://;p}' | while read pt_port; do
10 echo "forwarding port $PORT -> $pt_port"
11 socat -v -v TCP-LISTEN:$PORT,fork,reuseaddr TCP-CONNECT:127.0.0.1:$pt_port &
12 done