Gluetun / PIA (Private Internet Access) VPN Peer Port updater for Transmission.
- Waits for gluetun to report healthy
- Checks gluetun's PIAVPN Peer Port (via control server), and keep trying until it gets a valid port
- If port can't be retrieved in x tries, it insrtucts gluetun to pick a new server.
- Checks Transmission's current Peer Port
- If transmission port can't be retrieved in x tries, it instructs gluetun to pick a new server.
- If there is a difference between the two ports, it instructs Transmission to update its Peer Port.
- Tests that transmission peer port is open, and updates it when things go sideways.
It keeps trying until you have a valid peer port.
Mandatory:
GLUETUN_CONTROL_ENDPOINT
: Full Control Server URL with port, e.g.:http://gluetun:8000
.GLUETUN_HEALTH_ENDPOINT
: Full Health URL with port,http://gluetun:9999
by default.TRANSMISSION_ENDPOINT
: Full Transmission RPC URL with port, service path, e.g.:http://transmission:9091/transmission/rpc
.TRANSMISSION_USER
: Username for transmission RPC auth.TRANSMISSION_PASS
: Password for transmission RPC auth.
Optional:
PEERPORT_CHECK_INTERVAL
: how often peer port should be validated. Default: 15, in seconds.GLUETUN_PICK_NEW_SERVER_AFTER
: pick a new server after X number of failures in detecting a working peer port. Default: 10, in number of retries.FORCED_COUNTRY_JUMP
: jump to a new country every X minutes. Default: 0 (means: disabled). Example: 120 (jump to new country every 2 hours).SANITIZE_LOGS
: sanitize logs. Default: 0 (means disabled). Set to 1 to omit potentially sensitive information from logs.
Export the necessary variables, for example:
export GLUETUN_CONTROL_ENDPOINT=http://gluetun:8000
export GLUETUN_HEALTH_ENDPOINT=http://gluetun:8080
export TRANSMISSION_ENDPOINT=http://transmission:9091/transmission/rpc
export TRANSMISSION_USER=transmission
export TRANSMISSION_PASS=transmission
Run the script:
./entrypoint.sh
Script logs to stdout, you can redirect it to a file if you want to with ./entrypoint.sh > /path/to/logfile.log
docker run \
-e GLUETUN_CONTROL_ENDPOINT=http://gluetun:8000 \
-e GLUETUN_HEALTH_ENDPOINT=http://gluetun:8080 \
-e TRANSMISSION_ENDPOINT=http://transmission:9091/transmission/rpc \
-e TRANSMISSION_USER=transmission \
-e TRANSMISSION_PASS=transmission \
miklosbagi/gluetranspia:latest
- Clone this repo, and
cd
into it - If this is not the first time you build, remove the old image with
docker rmi gluetranspia:local
- Build the image with
docker build -t gluetranspia:local .
- Run with:
docker run \
-e GLUETUN_CONTROL_ENDPOINT=http://gluetun:8000 \
-e GLUETUN_HEALTH_ENDPOINT=http://gluetun:8080 \
-e TRANSMISSION_ENDPOINT=http://transmission:9091/transmission/rpc \
-e TRANSMISSION_USER=transmission \
-e TRANSMISSION_PASS=transmission \
gluetranspia:local
Please note that data
directory will be created if this gets executed as is.
Also, please note that we test against versions, not :latest, as that's like a weather report.
services:
gluetun:
image: qmcgaw/gluetun:v3.35.0
volumes:
- ./data/gluetun:/gluetun
cap_add:
- NET_ADMIN
ports:
- 8000:8000 # Control server
- 9091:9091 # Transmission UI
environment:
VPN_SERVICE_PROVIDER: "private internet access"
OPENVPN_USER: My PIA Username
OPENVPN_PASSWORD: My PIA Password
SERVER_REGIONS: "FI Helsinki,France,Norway,SE Stockholm,Serbia"
VPN_PORT_FORWARDING: on
VPN_PORT_FORWARDING_PROVIDER: "private internet access"
restart: unless-stopped
transmission:
image: linuxserver/transmission:4.0.4
environment:
USER: My Transmission Username
PASS: My Transmission Password
#PEERPORT: # this is what we do here, so skip it.
volumes:
- ./data/transmission:/config
- ./data/transmission_downloads:/downloads
network_mode: "service:gluetun" # go through gluetun's VPN
restart: unless-stopped
depends_on:
- gluetun
gluetranspia:
image: miklosbagi/gluetranspia:latest
environment:
GLUETUN_CONTROL_ENDPOINT: http://localhost:8000
GLUETUN_HEALTH_ENDPOINT: http://localhost:9999
TRANSMISSION_ENDPOINT: http://localhost:9091/transmission/rpc
TRANSMISSION_USER: My Transmission Username
TRANSMISSION_PASS: My Transmission Password
PEERPORT_CHECK_INTERVAL: 30 # optional, default: 15, in seconds
GLUETUN_PICK_NEW_SERVER_AFTER: 15 # optional, default: 10, in number of retries
FORCED_COUNTRY_JUMP: 0 # optional, default: 0 (means: disabled). Example: 120 (jump to new country every 2 hours)
network_mode: "service:gluetun" # go through gluetun's VPN
depends_on:
- gluetun
docker logs -f gluetranspia
should reveal what's happening.
GlueTransPIA starting...
Oct 10 10:10:11 [gtpia] waiting for gluetun to become active...
Oct 10 10:10:17 [gtpia] gluetun is active, country details: "123.123.1.12,UK,Belgrade,CODE Test DataCenterHost Inc."
Oct 10 10:10:17 [gtpia] monitoring...
Oct 10 10:10:47 [gtpia] gluetun returned {"port":0}, retrying (1 / 15)...
Oct 10 10:11:17 [gtpia] tramsmission returned '', retrying (1/15)...
Oct 10 10:11:47 [gtpia] tramsmission returned '', retrying (2/15)...
Oct 10 10:12:18 [gtpia] tramsmission returned '', retrying (3/15)...
Oct 10 10:12:48 [gtpia] port change detected: gluetun is 12345, transmission is 0, updating...
Oct 10 10:12:54 [gtpia] success: transmission port updated successfully.
Oct 10 10:13:23 [gtpia] country jump timer: 14 minutes left on this server.
Oct 10 10:13:24 [gtpia] heartbeat: gluetun & transmission ports match (12345), Port is open: Yes
Please note that this data is sanitized.
GlueTransPIA starting...
Oct 10 10:10:11 [gtpia] waiting for gluetun to become active...
Oct 10 10:10:17 [gtpia] gluetun is active, country details: "123.123.1.12,UK,Belgrade,CODE Test DataCenterHost Inc."
Oct 10 10:10:17 [gtpia] monitoring...
Oct 10 10:10:47 [gtpia] gluetun returned {"port":0}, retrying (1 / 15)...
Oct 10 10:11:17 [gtpia] tramsmission returned '', retrying (1/15)...
Oct 10 10:11:47 [gtpia] tramsmission returned '', retrying (2/15)...
...
Oct 10 10:14:38 [gtpia] gluetun returned {"port":0}, retrying (15 / 15)...
Oct 10 10:11:38 [gtpia] gluetun port check failed 15 times, instructing gluetun to pick a new server.
Oct 10 10:15:17 [gtpia] gluetun is active, country details: "123.123.1.12,UK,Berlin,CODE Test DataCenterHost Inc."
Oct 10 10:15:47 [gtpia] gluetun returned {"port":0}, retrying (1 / 15)...
Oct 10 10:16:48 [gtpia] port change detected: gluetun is 12345, transmission is 0, updating...
Oct 10 10:16:54 [gtpia] success: transmission port updated successfully.
Oct 10 10:17:23 [gtpia] country jump timer: 14 minutes left on this server.
Oct 10 10:17:24 [gtpia] heartbeat: gluetun & transmission ports match (12345), Port is open: Yes
...
Please note that this data is sanitized.
- Transmission w/o RPC auth is not supported
- If you see that the thirs server you'd expect is still not returning a valid peer port, please check the logs of gluetun, as it might be that the server is not healthy, or the port is not open. If it keeps returning 0 as port, please stop and start it again, there is a known bug