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

Keep PIA port forward updated #224

Open
potter-jason opened this issue Mar 29, 2023 · 5 comments
Open

Keep PIA port forward updated #224

potter-jason opened this issue Mar 29, 2023 · 5 comments

Comments

@potter-jason
Copy link

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
Copy link
Author

#!/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
Copy link
Author

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
Copy link

JohanSF commented Dec 17, 2023

Any progress on this?

@CrappyHero
Copy link

#!/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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants