From 05eb2d3d4de5be9159270c5742a5e0c0a5a8591c Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Mon, 22 May 2023 00:28:14 +0200 Subject: WIP IPv4/IPv6 fixes --- tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java | 8 ++++---- tunnel/src/main/java/com/wireguard/util/Resolver.java | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'tunnel/src/main/java/com/wireguard') 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 481ef8ae..23ea0e1e 100644 --- a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java +++ b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java @@ -323,10 +323,10 @@ public final class GoBackend implements Backend { Log.w(TAG, "Wg user string: " + goConfig); LibwgGrpc.LibwgBlockingStub stub = LibwgGrpc.newBlockingStub(channel); - TunnelHandle handle = TunnelHandle.newBuilder().setHandle(currentTunnelHandle).build(); + // TunnelHandle handle = TunnelHandle.newBuilder().setHandle(currentTunnelHandle).build(); // IpcSetRequest request = IpcSetRequest.newBuilder().setTunnel(handle).setConfig(goConfig).build(); // IpcSetResponse resp = stub.ipcSet(request); - wgSetConfig(handle, request); + wgSetConfig(currentTunnelHandle, goConfig); } private static String downloadPacFile(Network network, Uri pacFileUrl) { @@ -877,10 +877,10 @@ public final class GoBackend implements Backend { Log.w(TAG, "is default network, config:" + goConfig); LibwgGrpc.LibwgBlockingStub stub = LibwgGrpc.newBlockingStub(channel); - TunnelHandle tunnel = TunnelHandle.newBuilder().setHandle(currentTunnelHandle).build(); + // TunnelHandle tunnel = TunnelHandle.newBuilder().setHandle(currentTunnelHandle).build(); // IpcSetRequest request = IpcSetRequest.newBuilder().setTunnel(tunnel).setConfig(goConfig).build(); // IpcSetResponse resp = stub.ipcSet(request); - wgSetConfig(handle, request); + wgSetConfig(currentTunnelHandle, goConfig); } } } diff --git a/tunnel/src/main/java/com/wireguard/util/Resolver.java b/tunnel/src/main/java/com/wireguard/util/Resolver.java index 654e01f5..24f5ab88 100644 --- a/tunnel/src/main/java/com/wireguard/util/Resolver.java +++ b/tunnel/src/main/java/com/wireguard/util/Resolver.java @@ -111,6 +111,7 @@ public class Resolver { if (sock.getLocalAddress().isAnyLocalAddress()) { // Connect didn't find a local address. Log.w(TAG, "No local address"); + sock.close(); continue; } @@ -119,6 +120,7 @@ public class Resolver { if (candidate instanceof Inet4Address) { // Accept IPv4 as preferred address. address = candidate; + sock.close(); break; } -- cgit v1.2.3