-
-
Notifications
You must be signed in to change notification settings - Fork 410
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
feat(portforwarding): Allow running script upon port forwarding success #2399
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thank you for this PR 👍
We need to notably:
- change this to a run command (instead of script file)
- make code ready for a down command (later 🙏, if anyone needs such command)
- make a PR to the github wiki to document this (probably in the setup/advance/vpn-port-forwarding document) and mention the command is a single command, which doesn't understand shell specific syntax such as
&&
, and one should use/bin/sh -c "my shell syntax"
to do so if they want (bash isn't installed by default, only sh)
Thanks!
Ok, I believe that I have resolved all the issues with the initial implementation, I am not a huge fan of comma separating the ports, but that is how the current code works to give maximum compatibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job! 👍
Just 2 renames to do 😉
And once done I'll handle the using-that-command-package-and-plug-lines-to-the-logger. I just worked on it yesterday so it's still fresh in my mind 😉 !
FYI I'm working on your branch right now, almost done rebasing+fixing the last feedback I left, so please hold 😉 Thanks!! |
Hi @lavalleeale could you give me (force) push access to your Gluetun branch |
Thanks for working on this, can't wait ! |
Anything happening here? |
@lavalleeale I still don't have push access to your fork, can you please allow force push access? Otherwise I'll create another PR with another branch, but would like to give you the credits for it ideally! |
Done! |
Thanks @lavalleeale |
Merged, thanks! I've tested it locally, it looks like it's working fine. |
@qdm12 Thanks for merging! I've already successfully migrated my setup from polling the control server to this hook, but I'd rather not follow the master branch. Any plans on a new release soon? |
For those wanting to use this new feature with Transmission, I wrote a simple Python script to automatically update the docker-compose.yml
I had to create a custom Docker image for gluetun to install Python, gluetun/Dockerfile
Finally, the Python script wich uses https://pypi.org/project/transmission-rpc/. gluetun/transmission-sync.py
I put that here in case it can be useful :-) |
Thank you for this great feature !!! :-D
Prerequisites: Have a great holiday :-) |
Thanks @Marsu31 for your command. I hope y'all are enjoying your holiday! Here, I managed to simplify it a little 👇 VPN_PORT_FORWARDING_UP_COMMAND=wget -qO- --post-data=json={\"listen_port\":{{PORTS}}} http://127.0.0.1:8080/api/v2/app/setPreferences If your Gluetun container starts before qBittorrent, the command will fail because there is no service to contact yet. personally have qBittorrent depend on Gluetun, and will not start until it's healthy. qbittorrent:
...
depends_on:
gluetun:
condition: service_healthy For reliability, consider adding the
All in all, I'd suggest using this command 👇 VPN_PORT_FORWARDING_UP_COMMAND=wget --retry-connrefused --tries=6 -qO- --post-data=json={\"listen_port\":{{PORTS}}} http://127.0.0.1:8080/api/v2/app/setPreferences Personally, instead of using the ERROR [port forwarding] failed: Connection refused.
ERROR [port forwarding] URL:http://127.0.0.1:8080/api/v2/app/setPreferences [0/0] -> "setPreferences" [4] *👈 not an error* |
How do you guys handle the gluetun container restart ? |
Thank you @ramennbowls for your improvements ! :-) The lack of logging made me not see the error you pointed out. To see output not in "ERROR" category I had to surround the command with shell and redirect stderr like this:
I don't use |
This PR allows an environment variable (VPN_PORT_FORWARDING_STATUS_SCRIPT) to be set that will run a script whenever there is an update to port forwarding status that could be used to sync with other programs that need to know what ports have been forwarded.
EDIT by qdm12: