summaryrefslogtreecommitdiffhomepage
path: root/tunnel/src/main/java/com/wireguard/android
diff options
context:
space:
mode:
Diffstat (limited to 'tunnel/src/main/java/com/wireguard/android')
-rw-r--r--tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java14
1 files changed, 13 insertions, 1 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 32e3572a..1d900db0 100644
--- a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java
+++ b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java
@@ -384,8 +384,20 @@ public final class GoBackend implements Backend {
private void Dhcp(VpnService service) throws Exception{
obtainDhcpLease = false;
+ // Heuristics: Use first ULA address as client address
+ com.wireguard.android.backend.gen.InetAddress source = null;
+
+ for (final InetNetwork net : currentConfig.getInterface().getAddresses()) {
+ InetAddress addr = net.getAddress();
+ if (addr instanceof Inet6Address) {
+ if (Resolver.isULA((Inet6Address)addr)) {
+ source = com.wireguard.android.backend.gen.InetAddress.newBuilder().setAddress(ByteString.copyFrom(addr.getAddress())).build();
+ }
+ }
+ }
+
LibwgGrpc.LibwgBlockingStub stub = LibwgGrpc.newBlockingStub(channel);
- DhcpRequest request = DhcpRequest.newBuilder().build();
+ DhcpRequest request = DhcpRequest.newBuilder().setSource(source).build();
DhcpResponse resp = stub.dhcp(request);
Log.i(TAG, "Dhcp: " + resp.getError().getMessage());