From 3cadd94bb593eb38c271e9783b0111c7b2e50c4d Mon Sep 17 00:00:00 2001 From: Anton Keks Date: Tue, 27 Oct 2020 21:15:42 +0200 Subject: [PATCH] #129 list IPv4 addresses first, and then IPv6 --- src/net/azib/ipscan/gui/actions/FeederActions.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/net/azib/ipscan/gui/actions/FeederActions.java b/src/net/azib/ipscan/gui/actions/FeederActions.java index 19a0e72d..1539ee51 100644 --- a/src/net/azib/ipscan/gui/actions/FeederActions.java +++ b/src/net/azib/ipscan/gui/actions/FeederActions.java @@ -10,9 +10,11 @@ import org.eclipse.swt.events.TraverseListener; import org.eclipse.swt.widgets.*; import java.net.*; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; +import static java.util.Comparator.comparing; import static net.azib.ipscan.util.InetAddressUtils.getNetworkInterfaces; /** @@ -84,7 +86,9 @@ public class FeederActions { }; for (NetworkInterface networkInterface : getNetworkInterfaces()) { - for (InterfaceAddress ifaddr : networkInterface.getInterfaceAddresses()) { + List addresses = networkInterface.getInterfaceAddresses(); + addresses.sort(comparing(i -> i.getAddress().getAddress().length)); + for (InterfaceAddress ifaddr : addresses) { if (ifaddr == null) continue; InetAddress address = ifaddr.getAddress(); if (!address.isLoopbackAddress()) {