jamesmcm / vopono

Run applications through VPN tunnels with temporary network namespaces
GNU General Public License v3.0
885 stars 46 forks source link

Pass forwarded port to POSTUP script if port forwarding (Plex) #260

Closed jamesmcm closed 7 months ago

jamesmcm commented 7 months ago

Currently the callback script runs every time the port is reobtained, but for some cases (e.g. Plex where we cannot re-map the local port) we would want to run a command just once (for a proxy on that port) after establishing the connections.

E.g. for Plex 32400 is fixed as the local port, and we need to locally forward the outward forwarded port to that, within the network namespace:

$ vopono exec --custom ~/Downloads/wg-RO-9.conf --protocol wireguard --provider custom --custom-port-forwarding protonvpn --create-netns-only --keep-alive --forward 32400 --no-killswitch -o 32400 dummy

$ LD_LIBRARY_PATH=/usr/lib/plexmediaserver/lib PLEX_MEDIA_SERVER_HOME=/usr/lib/plexmediaserver PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/var/lib/plex PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6 PLEX_MEDIA_SERVER_TMPDIR=/tmp TMPDIR=/tmp sudo -E ip netns exec vo_c_UPcvBno sudo -Eu plex /usr/lib/plexmediaserver/Plex\ Media\ Server

$ sudo ip netns exec vo_c_UPcvBno socat tcp-l:42754,fork,reuseaddr tcp:10.200.1.2:32400

We would want to put the last command in a script, but need to pass in the port 42754 there which we'll get from the ProtonVPN port forwarding in vopono (note 10.200.1.2 is the local IP address of the network namespace).

jamesmcm commented 7 months ago

Added in #264 as $VOPONO_FORWARDED_PORT