diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2022-11-05 23:16:04 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2022-11-05 23:16:04 +0100 |
commit | 16b5ef29a6e18cd47dc0d8842d8c94e26915f48c (patch) | |
tree | 7b7b08e36ad8fd8a8bf7ab447ec436b485b8913d /tunnel/src/main/java/com | |
parent | 98f1ad8f9cda1ea1ba61bd5822054a37412bcf8d (diff) |
WIP add uncommitted changesnew/tunnel-config-actions
Diffstat (limited to 'tunnel/src/main/java/com')
3 files changed, 21 insertions, 0 deletions
diff --git a/tunnel/src/main/java/com/wireguard/android/backend/Backend.java b/tunnel/src/main/java/com/wireguard/android/backend/Backend.java index 5aaad826..b6f7ab89 100644 --- a/tunnel/src/main/java/com/wireguard/android/backend/Backend.java +++ b/tunnel/src/main/java/com/wireguard/android/backend/Backend.java @@ -64,4 +64,6 @@ public interface Backend { * @throws Exception Exception raised while changing state. */ Tunnel.State setState(Tunnel tunnel, Tunnel.State state, @Nullable Config config) throws Exception; + + void setRunningTunnelConfig(Tunnel tunnel, Config config); } diff --git a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java index c8158a72..59397a03 100644 --- a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java +++ b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java @@ -28,10 +28,13 @@ import com.wireguard.android.backend.gen.GetConnectionOwnerUidResponse; import com.wireguard.android.backend.gen.LibwgGrpc; import com.wireguard.android.backend.gen.ReverseRequest; import com.wireguard.android.backend.gen.ReverseResponse; +import com.wireguard.android.backend.gen.SetConfigRequest; +import com.wireguard.android.backend.gen.SetConfigResponse; import com.wireguard.android.backend.gen.StartHttpProxyRequest; import com.wireguard.android.backend.gen.StartHttpProxyResponse; import com.wireguard.android.backend.gen.StopHttpProxyRequest; import com.wireguard.android.backend.gen.StopHttpProxyResponse; +import com.wireguard.android.backend.gen.TunnelHandle; import com.wireguard.android.backend.gen.VersionRequest; import com.wireguard.android.backend.gen.VersionResponse; import com.wireguard.android.util.SharedLibraryLoader; @@ -262,6 +265,18 @@ public final class GoBackend implements Backend { return getState(tunnel); } + @Override + public void setRunningTunnelConfig(final Tunnel tunnel, final Config config) { + LibwgGrpc.LibwgStub asyncStub = LibwgGrpc.newStub(channel); + LibwgGrpc.LibwgBlockingStub stub = LibwgGrpc.newBlockingStub(channel); + final String goConfig = config.toWgUserspaceString(); + SetConfigRequest.Builder reqBuilder = SetConfigRequest.newBuilder(); + TunnelHandle.Builder tunnelBuilder = TunnelHandle.newBuilder(); + tunnelBuilder.setHandle(currentTunnelHandle); + SetConfigRequest req = reqBuilder.setTunnel(tunnelBuilder.build()).setSettings(goConfig).build(); + SetConfigResponse resp = stub.setConfig(req); + } + private int startHttpProxy(Uri pacFileUrl) { LibwgGrpc.LibwgStub asyncStub = LibwgGrpc.newStub(channel); LibwgGrpc.LibwgBlockingStub stub = LibwgGrpc.newBlockingStub(channel); diff --git a/tunnel/src/main/java/com/wireguard/android/backend/WgQuickBackend.java b/tunnel/src/main/java/com/wireguard/android/backend/WgQuickBackend.java index 3121c996..8df89682 100644 --- a/tunnel/src/main/java/com/wireguard/android/backend/WgQuickBackend.java +++ b/tunnel/src/main/java/com/wireguard/android/backend/WgQuickBackend.java @@ -166,6 +166,10 @@ public final class WgQuickBackend implements Backend { return state; } + @Override + public void setRunningTunnelConfig(final Tunnel tunnel, final Config config) { + } + private void setStateInternal(final Tunnel tunnel, @Nullable final Config config, final State state) throws Exception { Log.i(TAG, "Bringing tunnel " + tunnel.getName() + ' ' + state); |