mirror of
https://github.com/angryip/ipscan.git
synced 2025-10-26 11:18:17 +00:00
clarify method names and signatures
This commit is contained in:
parent
7e6b601c9d
commit
c1ec0e3741
@ -50,11 +50,11 @@ public class ScanningSubject {
|
||||
int adaptedPortTimeout = -1;
|
||||
|
||||
public ScanningSubject(InetAddress address) {
|
||||
this(address, InetAddressUtils.getInterface(address));
|
||||
this(address, InetAddressUtils.getInterfaceByLocalAddr(address));
|
||||
}
|
||||
|
||||
public ScanningSubject(InetAddress address, NetworkInterface netIf) {
|
||||
this(address, netIf, matchingAddress(netIf, address));
|
||||
this(address, netIf, matchingAddress(netIf, address.getClass()));
|
||||
}
|
||||
|
||||
public ScanningSubject(InetAddress address, NetworkInterface netIf, InterfaceAddress ifAddr) {
|
||||
|
||||
@ -53,8 +53,8 @@ public class RangeFeeder extends AbstractFeeder {
|
||||
try {
|
||||
this.startIP = this.currentIP = InetAddress.getByName(startIP);
|
||||
this.endIP = this.originalEndIP = InetAddress.getByName(endIP);
|
||||
this.netIf = getInterface(ifAddr != null ? ifAddr.getAddress() : this.startIP);
|
||||
this.ifAddr = ifAddr != null ? ifAddr : matchingAddress(netIf, this.startIP);
|
||||
this.netIf = ifAddr != null ? getInterfaceByLocalAddr(ifAddr.getAddress()) : null;
|
||||
this.ifAddr = ifAddr != null ? ifAddr : matchingAddress(netIf, this.startIP.getClass());
|
||||
this.isReverse = false;
|
||||
}
|
||||
catch (UnknownHostException e) {
|
||||
|
||||
@ -192,8 +192,9 @@ public class InetAddressUtils {
|
||||
return anyAddress;
|
||||
}
|
||||
|
||||
public static NetworkInterface getInterface(InetAddress address) {
|
||||
public static NetworkInterface getInterfaceByLocalAddr(InetAddress address) {
|
||||
try {
|
||||
if (address == null) return null;
|
||||
return NetworkInterface.getByInetAddress(address);
|
||||
}
|
||||
catch (SocketException e) {
|
||||
@ -201,9 +202,9 @@ public class InetAddressUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static InterfaceAddress matchingAddress(NetworkInterface netIf, InetAddress address) {
|
||||
public static InterfaceAddress matchingAddress(NetworkInterface netIf, Class<? extends InetAddress> addressClass) {
|
||||
if (netIf == null) return null;
|
||||
return netIf.getInterfaceAddresses().stream().filter(i -> i.getAddress().getClass() == address.getClass()).findFirst().orElse(null);
|
||||
return netIf.getInterfaceAddresses().stream().filter(i -> i.getAddress().getClass() == addressClass).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public static List<NetworkInterface> getNetworkInterfaces() throws SocketException {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user