Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to port forward the incoming port when using PIA (Private Internet Access) #31

Open
wants to merge 3 commits into
base: bionic
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ $ docker run --privileged -d \
|`UMASK`| No | GID applied to config files and downloads |`UMASK=002`|
|`WEBUI_PORT_ENV`| No | Applies WebUI port to qBittorrents config at boot (Must change exposed ports to match) |`WEBUI_PORT_ENV=8080`|
|`INCOMING_PORT_ENV`| No | Applies Incoming port to qBittorrents config at boot (Must change exposed ports to match) |`INCOMING_PORT_ENV=8999`|
|`PIA_PORT_FORWARD`| No | Request and set a port forward when using PIA (Private Internet Access) Overrides `INCOMING_PORT` when enabled |`PIA_PORT_FORWARD=true`|

## Volumes
| Volume | Required | Function | Example |
Expand Down
22 changes: 21 additions & 1 deletion openvpn/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,27 @@ if [[ $VPN_ENABLED == "yes" ]]; then
exec openvpn --config ${VPN_CONFIG} &
# give openvpn some time to connect
sleep 5
#exec /bin/bash /etc/openvpn/openvpn.init start &
#exec /bin/bash /etc/openvpn/openvpn.init start &

# PIA port Forward
# https://www.privateinternetaccess.com/helpdesk/kb/articles/can-i-use-port-forwarding-without-using-the-pia-client
if [[ $PIA_PORT_FORWARD == "true" ]]; then

echo "Trying to get a port forward from PIA" | ts '%Y-%m-%d %H:%M:%.S'

client_id=`head -n 100 /dev/urandom | sha256sum | tr -d " -"`

json=`curl "http://209.222.18.222:2000/?client_id=$client_id" 2>/dev/null`
if [ "$json" == "" ]; then
echo 'Port forwarding is already activated on this connection, has expired, or you are not connected to a PIA region that supports port forwarding' | ts '%Y-%m-%d %H:%M:%.S'
else
port=$(echo ${json} | tr -dc '0-9')
echo "Setting INCOMMING_PORT to pia port : ${port}" | ts '%Y-%m-%d %H:%M:%.S'
export INCOMING_PORT=${port}
fi

fi

exec /bin/bash /etc/qbittorrent/iptables.sh
else
exec /bin/bash /etc/qbittorrent/start.sh
Expand Down