feat: Exposes a method to retrieve a list of allowed local InetAddress-es.

This commit is contained in:
Boris Grozev 2016-11-16 13:40:51 -06:00
parent a08c77a3c1
commit 256176dde6

View File

@ -85,6 +85,21 @@ public abstract class AbstractUdpListener
public static List<TransportAddress> getAllowedAddresses(int port) public static List<TransportAddress> getAllowedAddresses(int port)
{ {
List<TransportAddress> addresses = new LinkedList<>(); List<TransportAddress> addresses = new LinkedList<>();
for (InetAddress address : getAllowedInetAddresses())
{
addresses.add(new TransportAddress(address, port, Transport.UDP));
}
return addresses;
}
/**
* @return the list of all local IP addresses from all allowed network
* interfaces, which are allowed addresses.
*/
public static List<InetAddress> getAllowedInetAddresses()
{
List<InetAddress> addresses = new LinkedList<>();
boolean isIPv6Disabled = StackProperties.getBoolean( boolean isIPv6Disabled = StackProperties.getBoolean(
StackProperties.DISABLE_IPv6, StackProperties.DISABLE_IPv6,
false); false);
@ -120,8 +135,7 @@ public abstract class AbstractUdpListener
&& address.isLinkLocalAddress()) && address.isLinkLocalAddress())
continue; continue;
addresses.add( addresses.add(address);
new TransportAddress(address, port, Transport.UDP));
} }
} }
} }