From 86957a359eb80cd5e84c48e890e43fe930b01423 Mon Sep 17 00:00:00 2001 From: Gauthier Delacroix Date: Tue, 16 Jul 2019 20:44:12 +0200 Subject: [PATCH] Fix/improve port forwarding handling --- README.md | 2 +- portforward.sh | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 77b7dcbb..83f05043 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ docker run --rm --network=container:pia alpine:3.10 wget -qO- https://ipinfo.io | `BLOCK_NSA` | `off` | `on` or `off`, blocks NSA hostnames | | `UNBLOCK` | | comma separated string (i.e. `web.com,web2.ca`) to unblock hostnames | | `EXTRA_SUBNETS` | | comma separated subnets allowed in the container firewall (i.e. `192.168.1.0/24,192.168.10.121,10.0.0.5/28`) | -| `PORT_FORWARDING` | | Set to `true` to read the forwarded port | +| `PORT_FORWARDING` | false | Set to `true` to read the forwarded port | | `PROXY` | `on` | `on` or `off`, to switch the internal HTTP proxy | | `PROXY_LOG_LEVEL` | `Critical` | `Info`, `Warning`, `Error` or `Critical` | | `PROXY_PORT` | `8888` | `1024` to `65535` internal port for HTTP proxy | diff --git a/portforward.sh b/portforward.sh index 5d4beec2..821b41a0 100644 --- a/portforward.sh +++ b/portforward.sh @@ -13,12 +13,11 @@ exitOnError(){ printf "[INFO] Reading forwarded port\n" client_id=`head -n 100 /dev/urandom | sha256sum | tr -d " -"` -exitOnError $? -json=`wget -qO- "http://209.222.18.222:2000/?client_id=$client_id" 2>/dev/null` -exitOnError $? +exitOnError $? "Unable to generate Client ID" +json=`wget -qO- "http://209.222.18.222:2000/?client_id=$client_id"` if [ "$json" == "" ]; then - printf "Port forwarding is already activated on this connection, has expired, or you are not connected to a PIA region that supports port forwarding\n" - exit 1 + printf " * Port forwarding is already activated on this connection, has expired, or you are not connected to a PIA region that supports port forwarding\n" + exit 1 fi port=`echo $json | jq .port` port_file="/forwarded_port" @@ -26,7 +25,7 @@ echo "$port" > $port_file printf " * Written forwarded port to $port_file\n" ip=`wget -qO- https://diagnostic.opendns.com/myip` exitOnError $? -printf " * Forwarded port for IP $ip is: $port\n" +printf " * Forwarded port is $port on remote IP $ip\n" printf " * Detecting target VPN interface..." TARGET_PATH="/openvpn/target" vpn_device=$(cat $TARGET_PATH/config.ovpn | grep 'dev ' | cut -d" " -f 2)0