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

[feature request] Allow a user-specified callback for port_forwarding.sh #138

Open
JasonMaloney opened this issue Nov 16, 2021 · 0 comments

Comments

@JasonMaloney
Copy link

JasonMaloney commented Nov 16, 2021

Hi all, I would like to request the ability to pass a user-specified callback script to port_forwarding.sh to be executed after binding the port.

I already have an existing OpenVPN configuration and scripts to connect to PIA (which also perform iptables and routing rules to force a split VPN for a specified user account). This worked great until the old port forwarding API stopped working recently. To be able to utilize the port_forwarding.sh script in this project, I made a small change to execute a callback script (this is immediately above the sleep command:

154 if [ -n "$PF_CALLBACK" ]; then
155 # Execute the specified callback script
156 export PF_PORT=$port
157 /usr/bin/env bash -c "$PF_CALLBACK"
158 # Unset so this does not get called again
159 PF_CALLBACK=
160 fi

This allows me to do the following:

  1. Wrap get_token.sh and port_forwarding.sh into a daemon that runs independently.
  2. Immediately receive the port number after binding, for use in other scripts.
  3. Capture the exported payload_and_signature variable for future calls to port_forwarding.sh (for example, upon VPN reconnect).

Obviously this is a fairly simple implementation, and you may wish to write it differently or more robustly. Any thoughts? This would be extremely useful for allowing people to use the port forwarding script with only minimal changes to existing setups.

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

1 participant