summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--tunnel/src/main/java/com/wireguard/android/backend/Backend.java2
-rw-r--r--tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java15
-rw-r--r--tunnel/src/main/java/com/wireguard/android/backend/WgQuickBackend.java4
-rw-r--r--tunnel/src/main/proto/libwg.proto10
-rw-r--r--tunnel/tools/libwg-go/service.go23
m---------tunnel/tools/wireguard-tools0
6 files changed, 54 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;
}
diff --git a/tunnel/tools/libwg-go/service.go b/tunnel/tools/libwg-go/service.go
index 37fb4b40..6563772b 100644
--- a/tunnel/tools/libwg-go/service.go
+++ b/tunnel/tools/libwg-go/service.go
@@ -83,6 +83,29 @@ func (e *LibwgServiceImpl) Version(ctx context.Context, req *gen.VersionRequest)
return r, nil
}
+func (e *LibwgServiceImpl) SetConfig(ctx context.Context, req *gen.SetConfigRequest) (*gen.SetConfigResponse, error) {
+ handle, ok := tunnelHandles[req.Tunnel.Handle]
+ if !ok {
+ r := &gen.SetConfigResponse{
+ }
+ return r, nil
+ }
+ err := handle.device.IpcSet(req.Settings)
+
+ if err != nil {
+ r := &gen.SetConfigResponse{
+ Error: &gen.Error{
+ Message: fmt.Sprintln(err),
+ },
+ }
+ return r, nil
+ }
+
+ r := &gen.SetConfigResponse{
+ }
+ return r, nil
+}
+
func (e *LibwgServiceImpl) StopGrpc(ctx context.Context, req *gen.StopGrpcRequest) (*gen.StopGrpcResponse, error) {
if server != nil {
server.Stop()
diff --git a/tunnel/tools/wireguard-tools b/tunnel/tools/wireguard-tools
-Subproject c0b68d2eafaf2b44df9377ba0844bc315163247
+Subproject 3ba6527130c502144e7388b900138bca6260f4e