diff options
Diffstat (limited to 'tunnel/src')
4 files changed, 31 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); diff --git a/tunnel/src/main/proto/libwg.proto b/tunnel/src/main/proto/libwg.proto index b25a10cd..4d060b7b 100644 --- a/tunnel/src/main/proto/libwg.proto +++ b/tunnel/src/main/proto/libwg.proto @@ -11,6 +11,7 @@ package api; service Libwg { rpc StopGrpc(StopGrpcRequest) returns (StopGrpcResponse); rpc Version(VersionRequest) returns (VersionResponse); + rpc SetConfig(SetConfigRequest) returns (SetConfigResponse); rpc StartHttpProxy(StartHttpProxyRequest) returns (StartHttpProxyResponse); rpc StopHttpProxy(StopHttpProxyRequest) returns (StopHttpProxyResponse); rpc Reverse(stream ReverseRequest) returns (stream ReverseResponse); @@ -50,6 +51,15 @@ message VersionResponse { string version = 1; } +message SetConfigRequest { + TunnelHandle tunnel = 1; + string settings = 2; +} + +message SetConfigResponse { + Error error = 1; +} + message StartHttpProxyRequest { string pacFileUrl = 1; } |