2018-01-01 09:06:37 +01:00
|
|
|
package com.wireguard.android.backend;
|
|
|
|
|
|
|
|
import com.wireguard.android.model.Tunnel;
|
|
|
|
import com.wireguard.android.model.Tunnel.State;
|
|
|
|
import com.wireguard.android.model.Tunnel.Statistics;
|
|
|
|
import com.wireguard.config.Config;
|
|
|
|
|
2018-01-06 12:07:17 +01:00
|
|
|
import java.util.Set;
|
|
|
|
|
2018-01-01 09:06:37 +01:00
|
|
|
/**
|
|
|
|
* Interface for implementations of the WireGuard secure network tunnel.
|
|
|
|
*/
|
|
|
|
|
|
|
|
public interface Backend {
|
|
|
|
/**
|
2018-01-07 07:24:56 +01:00
|
|
|
* Update the volatile configuration of a running tunnel and return the resulting configuration.
|
|
|
|
* If the tunnel is not up, return the configuration that would result (if known), or else
|
|
|
|
* simply return the given configuration.
|
2018-01-01 09:06:37 +01:00
|
|
|
*
|
|
|
|
* @param tunnel The tunnel to apply the configuration to.
|
|
|
|
* @param config The new configuration for this tunnel.
|
2018-01-07 07:24:56 +01:00
|
|
|
* @return The updated configuration of the tunnel.
|
2018-01-01 09:06:37 +01:00
|
|
|
*/
|
2018-01-07 07:24:56 +01:00
|
|
|
Config applyConfig(Tunnel tunnel, Config config) throws Exception;
|
2018-01-01 09:06:37 +01:00
|
|
|
|
2018-01-06 12:07:17 +01:00
|
|
|
/**
|
|
|
|
* Enumerate the names of currently-running tunnels.
|
|
|
|
*
|
2018-01-07 07:24:56 +01:00
|
|
|
* @return The set of running tunnel names.
|
2018-01-06 12:07:17 +01:00
|
|
|
*/
|
2018-01-09 03:42:58 +01:00
|
|
|
Set<String> enumerate();
|
2018-01-06 12:07:17 +01:00
|
|
|
|
2018-01-01 09:06:37 +01:00
|
|
|
/**
|
2018-01-07 07:24:56 +01:00
|
|
|
* Get the actual state of a tunnel.
|
2018-01-01 09:06:37 +01:00
|
|
|
*
|
|
|
|
* @param tunnel The tunnel to examine the state of.
|
2018-01-07 07:24:56 +01:00
|
|
|
* @return The state of the tunnel.
|
2018-01-01 09:06:37 +01:00
|
|
|
*/
|
2018-01-07 07:24:56 +01:00
|
|
|
State getState(Tunnel tunnel) throws Exception;
|
2018-01-01 09:06:37 +01:00
|
|
|
|
|
|
|
/**
|
2018-01-07 07:24:56 +01:00
|
|
|
* Get statistics about traffic and errors on this tunnel. If the tunnel is not running, the
|
|
|
|
* statistics object will be filled with zero values.
|
2018-01-01 09:06:37 +01:00
|
|
|
*
|
|
|
|
* @param tunnel The tunnel to retrieve statistics for.
|
2018-01-07 07:24:56 +01:00
|
|
|
* @return The statistics for the tunnel.
|
2018-01-01 09:06:37 +01:00
|
|
|
*/
|
2018-01-07 07:24:56 +01:00
|
|
|
Statistics getStatistics(Tunnel tunnel) throws Exception;
|
2018-01-01 09:06:37 +01:00
|
|
|
|
|
|
|
/**
|
2018-01-07 07:24:56 +01:00
|
|
|
* Set the state of a tunnel.
|
2018-01-01 09:06:37 +01:00
|
|
|
*
|
|
|
|
* @param tunnel The tunnel to control the state of.
|
|
|
|
* @param state The new state for this tunnel. Must be {@code UP}, {@code DOWN}, or
|
|
|
|
* {@code TOGGLE}.
|
2018-01-07 07:24:56 +01:00
|
|
|
* @return The updated state of the tunnel.
|
2018-01-01 09:06:37 +01:00
|
|
|
*/
|
2018-01-07 07:24:56 +01:00
|
|
|
State setState(Tunnel tunnel, State state) throws Exception;
|
2018-01-01 09:06:37 +01:00
|
|
|
}
|