From b9991e4229b49e08beebbae5519cfed5de99c051 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Tue, 19 Jun 2018 00:43:49 -0500 Subject: 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 --- app/src/main/java/com/wireguard/config/Interface.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'app/src/main/java/com/wireguard/config/Interface.java') 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 addressList; + private final List addressList; private final List 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() { -- cgit v1.2.3