Class WgQuickBackend

  • All Implemented Interfaces:
    Backend

    public final class WgQuickBackend
    extends java.lang.Object
    implements Backend
    Implementation of Backend that uses the kernel module and wg-quick to provide WireGuard tunnels.
    • Constructor Detail

      • WgQuickBackend

        public WgQuickBackend​(android.content.Context context,
                              RootShell rootShell,
                              ToolsInstaller toolsInstaller)
    • Method Detail

      • hasKernelSupport

        public static boolean hasKernelSupport()
      • getRunningTunnelNames

        public java.util.Set<java.lang.String> getRunningTunnelNames()
        Description copied from interface: Backend
        Enumerate names of currently-running tunnels.
        Specified by:
        getRunningTunnelNames in interface Backend
        Returns:
        The set of running tunnel names.
      • getState

        public Tunnel.State getState​(Tunnel tunnel)
        Description copied from interface: Backend
        Get the state of a tunnel.
        Specified by:
        getState in interface Backend
        Parameters:
        tunnel - The tunnel to examine the state of.
        Returns:
        The state of the tunnel.
      • getStatistics

        public Statistics getStatistics​(Tunnel tunnel)
        Description copied from interface: Backend
        Get statistics about traffic and errors on this tunnel. If the tunnel is not running, the statistics object will be filled with zero values.
        Specified by:
        getStatistics in interface Backend
        Parameters:
        tunnel - The tunnel to retrieve statistics for.
        Returns:
        The statistics for the tunnel.
      • getVersion

        public java.lang.String getVersion()
                                    throws java.lang.Exception
        Description copied from interface: Backend
        Determine version of underlying backend.
        Specified by:
        getVersion in interface Backend
        Returns:
        The version of the backend.
        Throws:
        java.lang.Exception - Exception raised while retrieving version.
      • setMultipleTunnels

        public void setMultipleTunnels​(boolean on)
      • setState

        public Tunnel.State setState​(Tunnel tunnel,
                                     Tunnel.State state,
                                     @Nullable
                                     Config config)
                              throws java.lang.Exception
        Description copied from interface: Backend
        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.
        Specified by:
        setState in interface Backend
        Parameters:
        tunnel - The tunnel to control the state of.
        state - The new state for this tunnel. Must be UP, DOWN, or TOGGLE.
        config - The configuration for this tunnel, may be null if state is DOWN.
        Returns:
        The updated state of the tunnel.
        Throws:
        java.lang.Exception - Exception raised while changing state.