diff options
author | Aurélien Chabot <aurelien@chabot.fr> | 2018-03-05 23:47:07 +1100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-04-17 02:15:24 +0200 |
commit | 74eae55c878e031fa25971378abf0cadee7bbaaa (patch) | |
tree | 4d3adb16e99f78b2faffa4eecaaf1e0fcb34b352 /app | |
parent | 44698bb00096749522abe5a8280893025a9e6a64 (diff) |
Config: Handle multiple address or dns in config file
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/com/wireguard/config/Interface.java | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/app/src/main/java/com/wireguard/config/Interface.java b/app/src/main/java/com/wireguard/config/Interface.java index 431f0e31..b13f78a0 100644 --- a/app/src/main/java/com/wireguard/config/Interface.java +++ b/app/src/main/java/com/wireguard/config/Interface.java @@ -90,9 +90,9 @@ public class Interface extends BaseObservable implements Parcelable { public void parse(final String line) { final Attribute key = Attribute.match(line); if (key == Attribute.ADDRESS) - setAddress(key.parse(line)); + addAddress(key.parse(line)); else if (key == Attribute.DNS) - setDns(key.parse(line)); + addDns(key.parse(line)); else if (key == Attribute.LISTEN_PORT) setListenPort(key.parse(line)); else if (key == Attribute.MTU) @@ -103,6 +103,13 @@ public class Interface extends BaseObservable implements Parcelable { throw new IllegalArgumentException(line); } + public void addAddress(String address) { + if (address != null && address.isEmpty()) + address = null; + setAddress((this.address == null) ? address + : this.address + ", " + address); + } + public void setAddress(String address) { if (address != null && address.isEmpty()) address = null; @@ -110,6 +117,13 @@ public class Interface extends BaseObservable implements Parcelable { notifyPropertyChanged(BR.address); } + public void addDns(String dns) { + if (dns != null && dns.isEmpty()) + dns = null; + setDns((this.dns == null) ? dns + : this.dns + ", " + dns); + } + public void setDns(String dns) { if (dns != null && dns.isEmpty()) dns = null; |