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;