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 interface
GoBackend.AlwaysOnCallback
Callback forGoBackend
that is invoked whenGoBackend.VpnService
is started by the system's Always-On VPN mode.static class
GoBackend.VpnService
VpnService
implementation 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.Tunnel.State
getState(Tunnel tunnel)
Get the associatedTunnel.State
for a givenTunnel
.Statistics
getStatistics(Tunnel tunnel)
Get the associatedStatistics
for a givenTunnel
.java.lang.String
getVersion()
Get the version of the underlying wireguard-go library.static void
setAlwaysOnCallback(GoBackend.AlwaysOnCallback cb)
Set aGoBackend.AlwaysOnCallback
to be invoked whenGoBackend.VpnService
is started by the system's Always-On VPN mode.Tunnel.State
setState(Tunnel tunnel, Tunnel.State state, Config config)
-
-
-
Method Detail
-
setAlwaysOnCallback
public static void setAlwaysOnCallback(GoBackend.AlwaysOnCallback cb)
Set aGoBackend.AlwaysOnCallback
to be invoked whenGoBackend.VpnService
is 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:
getRunningTunnelNames
in interfaceBackend
- Returns:
- A set of string values denoting names of running tunnels.
-
getState
public Tunnel.State getState(Tunnel tunnel)
Get the associatedTunnel.State
for a givenTunnel
.- Specified by:
getState
in interfaceBackend
- Parameters:
tunnel
- The tunnel to examine the state of.- Returns:
Tunnel.State
associated with the given tunnel.
-
getStatistics
public Statistics getStatistics(Tunnel tunnel)
Get the associatedStatistics
for a givenTunnel
.- Specified by:
getStatistics
in interfaceBackend
- Parameters:
tunnel
- The tunnel to retrieve statistics for.- Returns:
Statistics
associated with the given tunnel.
-
getVersion
public java.lang.String getVersion()
Get the version of the underlying wireguard-go library.- Specified by:
getVersion
in interfaceBackend
- Returns:
String
value 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:
setState
in 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.State
of the tunnel after state changes are applied.- Throws:
java.lang.Exception
- Exception raised while changing tunnel state.
-
-