no need for a separate MACFetcher is CommentFetcher - MACFetcher will be activated by the PingerRegistry now for local networks (to do ARP ping)

This commit is contained in:
Anton Keks 2022-01-21 19:02:31 +02:00
parent 339533c22f
commit 78e18f9b74
3 changed files with 5 additions and 12 deletions

View File

@ -178,11 +178,10 @@ public class ScanningSubject {
}
public boolean isLocal() {
return address.isSiteLocalAddress() || address.isLinkLocalAddress();
return ifAddr != null;
}
@Override
public String toString() {
@Override public String toString() {
StringBuilder sb = new StringBuilder(address.getHostAddress());
if (requestedPorts != null) {
sb.append(':');

View File

@ -16,10 +16,8 @@ public class CommentFetcher extends AbstractFetcher {
public static final String ID = "fetcher.comment";
private CommentsConfig commentsConfig;
private MACFetcher macFetcher;
public CommentFetcher(MACFetcher macFetcher, CommentsConfig commentsConfig) {
this.macFetcher = macFetcher;
public CommentFetcher(CommentsConfig commentsConfig) {
this.commentsConfig = commentsConfig;
}
@ -29,10 +27,6 @@ public class CommentFetcher extends AbstractFetcher {
public Object scan(ScanningSubject subject) {
String mac = (String) subject.getParameter(MACFetcher.ID);
if (mac == null && subject.isLocal()) {
macFetcher.scan(subject);
mac = (String) subject.getParameter(MACFetcher.ID);
}
return commentsConfig.getComment(subject.getAddress(), mac);
}
}

View File

@ -34,7 +34,7 @@ public class FetcherRegistryTest {
ipFetcher = new IPFetcher();
pingFetcher = new PingFetcher(null, null);
hostnameFetcher = new HostnameFetcher();
commentFetcher = new CommentFetcher(null, null);
commentFetcher = new CommentFetcher(null);
portsFetcher = new PortsFetcher(null);
fetcherRegistry = new FetcherRegistry(asList(ipFetcher, pingFetcher, hostnameFetcher, commentFetcher, portsFetcher), preferences, null);
}