Config: Handle multiple address or dns in config file
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
44698bb000
commit
74eae55c87
@ -90,9 +90,9 @@ public class Interface extends BaseObservable implements Parcelable {
|
|||||||
public void parse(final String line) {
|
public void parse(final String line) {
|
||||||
final Attribute key = Attribute.match(line);
|
final Attribute key = Attribute.match(line);
|
||||||
if (key == Attribute.ADDRESS)
|
if (key == Attribute.ADDRESS)
|
||||||
setAddress(key.parse(line));
|
addAddress(key.parse(line));
|
||||||
else if (key == Attribute.DNS)
|
else if (key == Attribute.DNS)
|
||||||
setDns(key.parse(line));
|
addDns(key.parse(line));
|
||||||
else if (key == Attribute.LISTEN_PORT)
|
else if (key == Attribute.LISTEN_PORT)
|
||||||
setListenPort(key.parse(line));
|
setListenPort(key.parse(line));
|
||||||
else if (key == Attribute.MTU)
|
else if (key == Attribute.MTU)
|
||||||
@ -103,6 +103,13 @@ public class Interface extends BaseObservable implements Parcelable {
|
|||||||
throw new IllegalArgumentException(line);
|
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) {
|
public void setAddress(String address) {
|
||||||
if (address != null && address.isEmpty())
|
if (address != null && address.isEmpty())
|
||||||
address = null;
|
address = null;
|
||||||
@ -110,6 +117,13 @@ public class Interface extends BaseObservable implements Parcelable {
|
|||||||
notifyPropertyChanged(BR.address);
|
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) {
|
public void setDns(String dns) {
|
||||||
if (dns != null && dns.isEmpty())
|
if (dns != null && dns.isEmpty())
|
||||||
dns = null;
|
dns = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user