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>
This commit is contained in:
@@ -28,7 +28,7 @@ import java.util.Locale;
|
||||
*/
|
||||
|
||||
public class Peer {
|
||||
private final List<IPCidr> allowedIPsList;
|
||||
private final List<InetNetwork> allowedIPsList;
|
||||
private InetSocketAddress endpoint;
|
||||
private int persistentKeepalive;
|
||||
private String preSharedKey;
|
||||
@@ -41,13 +41,13 @@ public class Peer {
|
||||
private void addAllowedIPs(final String[] allowedIPs) {
|
||||
if (allowedIPs != null && allowedIPs.length > 0) {
|
||||
for (final String allowedIP : allowedIPs) {
|
||||
allowedIPsList.add(new IPCidr(allowedIP));
|
||||
allowedIPsList.add(new InetNetwork(allowedIP));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IPCidr[] getAllowedIPs() {
|
||||
return allowedIPsList.toArray(new IPCidr[allowedIPsList.size()]);
|
||||
public InetNetwork[] getAllowedIPs() {
|
||||
return allowedIPsList.toArray(new InetNetwork[allowedIPsList.size()]);
|
||||
}
|
||||
|
||||
private String getAllowedIPsString() {
|
||||
|
||||
Reference in New Issue
Block a user