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

Add pre/post up/down support for rooted GoBackend #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adamirr
Copy link
Contributor

@adamirr adamirr commented Oct 10, 2020

When using the GoBackend on a rooted device allow for pre/post up/down
actions to be executed when the tunnel state changes. On non-rooted
devices the scripts are not executed but will still be parsed from the
configuration file. %i syntax is not supported. If any script fails to
execute the remaining scripts in that step are skipped


This is part of my efforts to make my AndroidTV device (Nvidia Shield) support the traditional WireGuard server options. I tested the GoBackend on my rooted Nvidia Shield and the scripts were executed. The changes the the wg-quick script are untested as I do not have access to a device with the kernel module installed.

I am unsure of the expected behavior of any failing scripts in the pre/post up/down section of the configs. As currently implemented, a failure results in the rest of the scripts not running. If other WireGuard implementations have a different behavior, I am happy to make this match the existing behavior.

I didn't implement the %i functionality since it is unclear to me if there is a standard interface name for Android's VPNs (it is tun0 on my Pixel3 and my Nvidia shield). If this is the standard name i can do the %i replacement. Using the normal tunnelName from the code doesn't work since that name comes from the WG config's name which doesn't match the actual interface name on Android.

Copy link
Member

@msfjarvis msfjarvis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jason will decide whether or not this will be merged, but I've done a preliminary review regardless.

When using the GoBackend on a rooted device allow for pre/post up/down
actions to be executed when the tunnel state changes. On non-rooted
devices the scripts are not executed but will still be parsed from the
configuration file. %i syntax is not supported. If any script fails to
execute the remaining scripts in that step are skipped

Signed-off-by: Adam Irr <adam.irr@outlook.com>
@msfjarvis
Copy link
Member

We're looking at the possibility of allowing wg-quick to control GoBackend tunnels as well, once we're able to know if that's doable we'll revisit this.

@adamirr
Copy link
Contributor Author

adamirr commented Oct 13, 2020

We're looking at the possibility of allowing wg-quick to control GoBackend tunnels as well, once we're able to know if that's doable we'll revisit this.

Thanks for the update.

Would this be something beyond the existing WG_QUICK_USERSPACE_IMPLEMENTATION environment variable that wg-quick supports? I ask because at one point I did compile the wireguard-go binary to for Android and tried using wg-quick with the backend specified and it wasn't able to modify the device interfaces.

@msfjarvis
Copy link
Member

We're looking at the possibility of allowing wg-quick to control GoBackend tunnels as well, once we're able to know if that's doable we'll revisit this.

Thanks for the update.

Would this be something beyond the existing WG_QUICK_USERSPACE_IMPLEMENTATION environment variable that wg-quick supports? I ask because at one point I did compile the wireguard-go binary to for Android and tried using wg-quick with the backend specified and it wasn't able to modify the device interfaces.

Yes it's going to be different. We're currently evaluating if the infrastructure we've built for remote control apps can be leveraged by wg-quick through calls to am.

Comment on lines +280 to +287
for (final String script : preUp)
sb.append("PreUp = ").append(script).append('\n');
for (final String script : postUp)
sb.append("PostUp = ").append(script).append('\n');
for (final String script : preDown)
sb.append("PreDown = ").append(script).append('\n');
for (final String script : postDown)
sb.append("PostDown = ").append(script).append('\n');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails since Android's wg-quick implementation doesn't support these actions. I have some changes pending that add support there as well but I'll wait to send that patch until the outcome of the potential redesign is completed.

@zzb-zzb
Copy link

zzb-zzb commented Dec 6, 2022

Mavent 上没有1.0.20220516,这个怎么解决

@zzb-zzb
Copy link

zzb-zzb commented Dec 6, 2022

Failed to resolve: com.wireguard.android:tunnel:1.0.20220516

@nickolasclarke
Copy link

nickolasclarke commented Feb 16, 2023

@msfjarvis Are there still any major blockers on this? Will it be merged at some point? Or is this a dead PR?

@zx2c4-bot zx2c4-bot force-pushed the master branch 4 times, most recently from 581ab92 to ec126a9 Compare March 28, 2023 14:04
@zx2c4-bot zx2c4-bot force-pushed the master branch 2 times, most recently from 77dc1ed to 5692307 Compare March 28, 2023 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants