diff options
author | Samuel Holland <samuel@sholland.org> | 2018-06-19 00:43:49 -0500 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2018-06-19 21:59:44 -0500 |
commit | b9991e4229b49e08beebbae5519cfed5de99c051 (patch) | |
tree | 4a233404b0b910539b149fbbda97f689ec31d6bc /app/src/main/java/com/wireguard/config/Interface.java | |
parent | 4acee49d4b0da6273cd9ffef1573185f955b5774 (diff) |
config: Refactor IPCidr and use of InetAddress
Use a canonically-named utility class to tack on methods to the existing
InetAddress class. Rename IPCidr to InetNetwork so it better matches
InetAddress and is more pronouceable :) While here, simplify the
constructor and toString() functions, and properly implement hashCode().
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com/wireguard/config/Interface.java')
-rw-r--r-- | app/src/main/java/com/wireguard/config/Interface.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/app/src/main/java/com/wireguard/config/Interface.java b/app/src/main/java/com/wireguard/config/Interface.java index e9423518..824bb122 100644 --- a/app/src/main/java/com/wireguard/config/Interface.java +++ b/app/src/main/java/com/wireguard/config/Interface.java @@ -23,7 +23,7 @@ import java.util.List; */ public class Interface { - private final List<IPCidr> addressList; + private final List<InetNetwork> addressList; private final List<InetAddress> dnsList; private Keypair keypair; private int listenPort; @@ -39,7 +39,7 @@ public class Interface { for (final String addr : addresses) { if (addr.isEmpty()) throw new IllegalArgumentException("Address is empty"); - addressList.add(new IPCidr(addr)); + addressList.add(new InetNetwork(addr)); } } } @@ -47,7 +47,7 @@ public class Interface { private void addDnses(final String[] dnses) { if (dnses != null && dnses.length > 0) { for (final String dns : dnses) { - dnsList.add(Attribute.parseIPString(dns)); + dnsList.add(InetAddresses.parse(dns)); } } } @@ -58,8 +58,8 @@ public class Interface { return Attribute.iterableToString(addressList); } - public IPCidr[] getAddresses() { - return addressList.toArray(new IPCidr[addressList.size()]); + public InetNetwork[] getAddresses() { + return addressList.toArray(new InetNetwork[addressList.size()]); } private String getDnsString() { |