diff options
author | Aurélien Chabot <aurelien@chabot.fr> | 2018-03-05 21:18:43 +1100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-04-17 02:15:24 +0200 |
commit | 44698bb00096749522abe5a8280893025a9e6a64 (patch) | |
tree | bf3055e53897c01e01062502d346882884aa60f8 /app | |
parent | 175f7e16ddedba8472fd0362cec4dc8e0480564d (diff) |
GoBackend: Add support for multiple address and dns as a comma separated list
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/com/wireguard/android/backend/GoBackend.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/app/src/main/java/com/wireguard/android/backend/GoBackend.java b/app/src/main/java/com/wireguard/android/backend/GoBackend.java index a8d5fc08..a8ee6e53 100644 --- a/app/src/main/java/com/wireguard/android/backend/GoBackend.java +++ b/app/src/main/java/com/wireguard/android/backend/GoBackend.java @@ -217,10 +217,17 @@ public final class GoBackend implements Backend { // Create the vpn tunnel with android API VpnService.Builder builder = vpnService.getBuilder(); builder.setSession(tunnel.getName()); - InetAddress address = InetAddress.getByName(config.getInterface().getAddress()); - builder.addAddress(address.getHostAddress(), (address instanceof Inet4Address) ? 32 : 128); - if (config.getInterface().getDns() != null) - builder.addDnsServer(InetAddress.getByName(config.getInterface().getDns()).getHostAddress()); + + for (final String addressString : config.getInterface().getAddress().split(" *, *")) { + InetAddress address = InetAddress.getByName(addressString); + builder.addAddress(address.getHostAddress(), (address instanceof Inet4Address) ? 32 : 128); + } + + if (config.getInterface().getDns() != null) { + for (final String dnsString : config.getInterface().getDns().split(" *, *")) { + builder.addDnsServer(InetAddress.getByName(dnsString).getHostAddress()); + } + } for (final Peer peer : config.getPeers()) { if (peer.getAllowedIPs() != null) { |