crazy-max / docker-rtorrent-rutorrent

rTorrent and ruTorrent Docker image
MIT License
457 stars 103 forks source link

Keep PIA port forward updated #224

Open potter-jason opened 1 year ago

potter-jason commented 1 year ago

Hi -

I wrote this bash script to grab the forwarded port from PIA's API, then pass it to rtorrent via XML-RPC, the check every 30 minutes if PIA changed the port. I'm passing the port to network.port_range.set. Is this the correct variable to send that to? Is there not an IP address as well for the listening ADDRESS:PORT?

!/bin/bash

while true do

Get the current forwarded port from PIA

PIA_PORT=$(curl -s -u "${PIA_USERNAME}:${PIA_PASSWORD}" "http://209.222.18.222:2000/?client_id=${PIA_CLIENT_ID}&token=${PIA_TOKEN}" | jq -r '.port')

Set the new port range for rTorrent using XML-RPC

xmlrpc localhost network.port_range.set ${PIA_PORT} ${PIA_PORT}

Print the new port range

echo "Changed rTorrent port range to ${PIA_PORT}"

Wait for 30 minutes before checking PIA again

sleep 1800 done

potter-jason commented 1 year ago

!/bin/bash

while true do

REM Replace these values with your PIA username and password PIA_USERNAME=p2637123 PIA_PASSWORD=b69dWv8Ao6 PIA="/usr/local/bin/piactl"

REM Get the current forwarded port from PIA VPN_IP=$("$PIA" get vpnip) PIA_PORT=$("$PIA" get portforward)

REM Set the new ip:port for rTorrent using XML-RPC xmlrpc localhost RT_INC_PORT ${PIA_PORT} xmlrpc localhost WAN_IP ${VPN_IP}

REM Print the new port range echo "Changed rTorrent listen ip:port to "${VPN_IP}:${PIA_PORT}"

REM Wait for 30 minutes before checking PIA again sleep 1800 done

potter-jason commented 1 year ago

made some change above, as that curl method was deprecated, also found the answer tomy question about the listening ip:port.....now to test if my method to make xml-rpc calls works

JohanSF commented 6 months ago

Any progress on this?

CrappyHero commented 6 months ago

!/bin/bash

while true do

REM Replace these values with your PIA username and password PIA_USERNAME=REDACTED PIA_PASSWORD=REDACTED PIA="/usr/local/bin/piactl"

REM Get the current forwarded port from PIA VPN_IP=$("$PIA" get vpnip) PIA_PORT=$("$PIA" get portforward)

REM Set the new ip:port for rTorrent using XML-RPC xmlrpc localhost RT_INC_PORT ${PIA_PORT} xmlrpc localhost WAN_IP ${VPN_IP}

REM Print the new port range echo "Changed rTorrent listen ip:port to "${VPN_IP}:${PIA_PORT}"

REM Wait for 30 minutes before checking PIA again sleep 1800 done

@potter-jason you might want to remove your PIA details from this...

CupricReki commented 5 months ago

I'm not sure this can currently be accomplished with XML-RPC. The network.port_range exists but network.port_range.set does not.

https://github.com/rakshasa/rtorrent/blob/1da0e3476dcabbf74b2e836d6b4c37b4d96bde09/src/command_network.cc#L243

I think the only way to do this is to set RT_INC_PORT and restart.