Skip to content

Expose isAlwaysOn and isLockdownEnabled #72

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tunnel/src/main/java/com/wireguard/android/backend/Backend.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,28 @@ public interface Backend {
*/
String getVersion() throws Exception;

/**
* Determines whether the service is running in always-on VPN mode.
* In this mode the system ensures that the service is always running by restarting it when necessary,
* e.g. after reboot.
*
* @returns A boolean indicating whether the service is running in always-on VPN mode.
* @throws Exception Exception raised while retrieving the always-on status.
*/

boolean isAlwaysOn() throws Exception;

/**
* Determines whether the service is running in always-on VPN lockdown mode.
* In this mode the system ensures that the service is always running and that the apps
* aren't allowed to bypass the VPN.
*
* @returns A boolean indicating whether the service is running in always-on VPN lockdown mode.
* @throws Exception Exception raised while retrieving the lockdown status.
*/

boolean isLockdownEnabled() throws Exception;

/**
* Set the state of a tunnel, updating it's configuration. If the tunnel is already up, config
* may update the running configuration; config may be null when setting the tunnel down.
Expand Down
18 changes: 18 additions & 0 deletions tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,24 @@ public String getVersion() {
return wgVersion();
}

/**
* Determines if the service is running in always-on VPN mode.
* @return {@link boolean} whether the service is running in always-on VPN mode.
*/
@Override
public boolean isAlwaysOn() {
return vpnService.get(0, TimeUnit.NANOSECONDS).isAlwaysOn();
}

/**
* Determines if the service is running in always-on VPN lockdown mode.
* @return {@link boolean} whether the service is running in always-on VPN lockdown mode.
*/
@Override
public boolean isLockdownEnabled() {
return vpnService.get(0, TimeUnit.NANOSECONDS).isLockdownEnabled();
}

/**
* Change the state of a given {@link Tunnel}, optionally applying a given {@link Config}.
*
Expand Down