Package com.wireguard.android.backend
Class GoBackend
- java.lang.Object
-
- com.wireguard.android.backend.GoBackend
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceGoBackend.AlwaysOnCallbackCallback forGoBackendthat is invoked whenGoBackend.VpnServiceis started by the system's Always-On VPN mode.static classGoBackend.VpnServiceVpnServiceimplementation forGoBackend
-
Constructor Summary
Constructors Constructor Description GoBackend(android.content.Context context)Public constructor for GoBackend.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Set<java.lang.String>getRunningTunnelNames()Method to get the names of running tunnels.intgetState()Tunnel.StategetState(Tunnel tunnel)Get the associatedTunnel.Statefor a givenTunnel.StatisticsgetStatistics(Tunnel tunnel)Get the associatedStatisticsfor a givenTunnel.java.lang.StringgetVersion()Get the version of the underlying wireguard-go library.static voidsetAlwaysOnCallback(GoBackend.AlwaysOnCallback cb)Set aGoBackend.AlwaysOnCallbackto be invoked whenGoBackend.VpnServiceis started by the system's Always-On VPN mode.voidsetNetworkAvailable(boolean available)Tunnel.StatesetState(Tunnel tunnel, Tunnel.State state, Config config)Tunnel.StatesetState(Tunnel tunnel, Tunnel.State state, Config config, java.lang.String socketType)
-
-
-
Method Detail
-
setAlwaysOnCallback
public static void setAlwaysOnCallback(GoBackend.AlwaysOnCallback cb)
Set aGoBackend.AlwaysOnCallbackto be invoked whenGoBackend.VpnServiceis started by the system's Always-On VPN mode.- Parameters:
cb- Callback to be invoked
-
getRunningTunnelNames
public java.util.Set<java.lang.String> getRunningTunnelNames()
Method to get the names of running tunnels.- Specified by:
getRunningTunnelNamesin interfaceBackend- Returns:
- A set of string values denoting names of running tunnels.
-
getState
public Tunnel.State getState(Tunnel tunnel)
Get the associatedTunnel.Statefor a givenTunnel.- Specified by:
getStatein interfaceBackend- Parameters:
tunnel- The tunnel to examine the state of.- Returns:
Tunnel.Stateassociated with the given tunnel.
-
getStatistics
public Statistics getStatistics(Tunnel tunnel)
Get the associatedStatisticsfor a givenTunnel.- Specified by:
getStatisticsin interfaceBackend- Parameters:
tunnel- The tunnel to retrieve statistics for.- Returns:
Statisticsassociated with the given tunnel.
-
setNetworkAvailable
public void setNetworkAvailable(boolean available)
-
getState
public int getState()
-
getVersion
public java.lang.String getVersion()
Get the version of the underlying wireguard-go library.- Specified by:
getVersionin interfaceBackend- Returns:
Stringvalue of the version of the wireguard-go library.
-
setState
public Tunnel.State setState(Tunnel tunnel, Tunnel.State state, @Nullable Config config) throws java.lang.Exception
- Specified by:
setStatein interfaceBackend- Parameters:
tunnel- The tunnel to control the state of.state- The new state for this tunnel. Must beUP,DOWN, orTOGGLE.config- The configuration for this tunnel, may be null if state isDOWN.- Returns:
Tunnel.Stateof the tunnel after state changes are applied.- Throws:
java.lang.Exception- Exception raised while changing tunnel state.
-
setState
public Tunnel.State setState(Tunnel tunnel, Tunnel.State state, @Nullable Config config, @NonNull java.lang.String socketType) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-