Fix/improve port forwarding handling
This commit is contained in:
@@ -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 |
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user