diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-05-24 22:48:37 +0200 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-10-26 22:28:29 +0200 |
commit | c6f1fddf2e52ce2d4e50c5e6d1931765ada1fe7e (patch) | |
tree | ef8aacf6826e099b247c0d0dede77c3bd68dfed5 /tunnel/src/main/java/com/wireguard/android | |
parent | fcdbd17d5101d9661d2ce581dc502c1bdabc4cd6 (diff) |
tunnel: implement gRPC based wgSetConfig
Diffstat (limited to 'tunnel/src/main/java/com/wireguard/android')
-rw-r--r-- | tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java | 13 |
1 files changed, 11 insertions, 2 deletions
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 acd2cd13..f53a1fc9 100644 --- a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java +++ b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java @@ -32,6 +32,8 @@ import com.wireguard.android.backend.Tunnel.State; import com.wireguard.android.backend.gen.DhcpRequest; import com.wireguard.android.backend.gen.DhcpResponse; import com.wireguard.android.backend.gen.GetConnectionOwnerUidResponse; +import com.wireguard.android.backend.gen.IpcSetRequest; +import com.wireguard.android.backend.gen.IpcSetResponse; import com.wireguard.android.backend.gen.Lease; import com.wireguard.android.backend.gen.LibwgGrpc; import com.wireguard.android.backend.gen.ReverseRequest; @@ -40,6 +42,7 @@ 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; @@ -319,7 +322,10 @@ public final class GoBackend implements Backend { // TODO removed removeNetworks Log.w(TAG, "Wg user string: " + goConfig); - wgSetConfig(currentTunnelHandle, goConfig); + LibwgGrpc.LibwgBlockingStub stub = LibwgGrpc.newBlockingStub(channel); + TunnelHandle handle = TunnelHandle.newBuilder().setHandle(currentTunnelHandle).build(); + IpcSetRequest request = IpcSetRequest.newBuilder().setTunnel(handle).setConfig(goConfig).build(); + IpcSetResponse resp = stub.ipcSet(request); } private static String downloadPacFile(Network network, Uri pacFileUrl) { @@ -869,7 +875,10 @@ public final class GoBackend implements Backend { final String goConfig = currentConfig.toWgEndpointsUserspaceString(resolver); Log.w(TAG, "is default network, config:" + goConfig); - wgSetConfig(currentTunnelHandle, goConfig); + LibwgGrpc.LibwgBlockingStub stub = LibwgGrpc.newBlockingStub(channel); + TunnelHandle tunnel = TunnelHandle.newBuilder().setHandle(currentTunnelHandle).build(); + IpcSetRequest request = IpcSetRequest.newBuilder().setTunnel(tunnel).setConfig(goConfig).build(); + IpcSetResponse resp = stub.ipcSet(request); } } } |