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/android | |
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/android')
-rw-r--r-- | app/src/main/java/com/wireguard/android/backend/GoBackend.java | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/app/src/main/java/com/wireguard/android/backend/GoBackend.java b/app/src/main/java/com/wireguard/android/backend/GoBackend.java index 10d8d911..fbe9d8ea 100644 --- a/app/src/main/java/com/wireguard/android/backend/GoBackend.java +++ b/app/src/main/java/com/wireguard/android/backend/GoBackend.java @@ -21,7 +21,7 @@ import com.wireguard.android.model.Tunnel.Statistics; import com.wireguard.android.util.ExceptionLoggers; import com.wireguard.android.util.SharedLibraryLoader; import com.wireguard.config.Config; -import com.wireguard.config.IPCidr; +import com.wireguard.config.InetNetwork; import com.wireguard.config.Interface; import com.wireguard.config.Peer; import com.wireguard.crypto.KeyEncoding; @@ -156,7 +156,7 @@ public final class GoBackend implements Backend { fmt.format("endpoint=%s\n", peer.getResolvedEndpointString()); if (peer.getPersistentKeepalive() != 0) fmt.format("persistent_keepalive_interval=%d\n", peer.getPersistentKeepalive()); - for (final IPCidr addr : peer.getAllowedIPs()) { + for (final InetNetwork addr : peer.getAllowedIPs()) { fmt.format("allowed_ip=%s\n", addr.toString()); } } @@ -171,15 +171,15 @@ public final class GoBackend implements Backend { configureIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); builder.setConfigureIntent(PendingIntent.getActivity(context, 0, configureIntent, 0)); - for (final IPCidr addr : config.getInterface().getAddresses()) - builder.addAddress(addr.getAddress(), addr.getCidr()); + for (final InetNetwork addr : config.getInterface().getAddresses()) + builder.addAddress(addr.getAddress(), addr.getMask()); for (final InetAddress addr : config.getInterface().getDnses()) builder.addDnsServer(addr.getHostAddress()); for (final Peer peer : config.getPeers()) { - for (final IPCidr addr : peer.getAllowedIPs()) - builder.addRoute(addr.getAddress(), addr.getCidr()); + for (final InetNetwork addr : peer.getAllowedIPs()) + builder.addRoute(addr.getAddress(), addr.getMask()); } int mtu = config.getInterface().getMtu(); |