improved WhoIsParser
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package de.muehlencord.shared.network.whois;
|
||||
|
||||
import static de.muehlencord.shared.network.CidrTool.rangeToCidrList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -69,9 +70,9 @@ public class DefaultWhoisParser extends AbstractWhoisParser implements WhoisPars
|
||||
// FIXME add CDIR notation support
|
||||
String startIpAddress = ipAddresses[0];
|
||||
String endIPAddress = ipAddresses[2];
|
||||
whoisInformation.getNetwork().addAll(rangeToCidrList(startIpAddress, endIPAddress));
|
||||
whoisInformation.addNetwork(rangeToCidrList(startIpAddress, endIPAddress));
|
||||
} else {
|
||||
whoisInformation.getNetwork().add(inetnum);
|
||||
whoisInformation.addNetwork(inetnum);
|
||||
}
|
||||
|
||||
LOGGER.info("Network:" + whoisInformation.getNetwork().toString());
|
||||
@ -88,7 +89,7 @@ public class DefaultWhoisParser extends AbstractWhoisParser implements WhoisPars
|
||||
throw new WhoisException ("Error while reading route information: "+ex.getMessage(), ex);
|
||||
}
|
||||
*/
|
||||
whoisInformation.getRootNetwork().add(route);
|
||||
whoisInformation.addRootNetwork(route);
|
||||
LOGGER.info("Root network " + whoisInformation.getRootNetwork().toString());
|
||||
break;
|
||||
|
||||
@ -109,6 +110,7 @@ public class DefaultWhoisParser extends AbstractWhoisParser implements WhoisPars
|
||||
break;
|
||||
default:
|
||||
LOGGER.info("Unknown block found");
|
||||
LOGGER.error(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,11 +10,17 @@ import java.util.List;
|
||||
*/
|
||||
public class WhoisInformation {
|
||||
|
||||
/** network list in CIDR form the host belongs to */
|
||||
/**
|
||||
* network list in CIDR form the host belongs to
|
||||
*/
|
||||
private List<String> network;
|
||||
/** network list in CIDDR form network belongs to */
|
||||
/**
|
||||
* network list in CIDDR form network belongs to
|
||||
*/
|
||||
private List<String> rootNetwork;
|
||||
/** network information of host */
|
||||
/**
|
||||
* network information of host
|
||||
*/
|
||||
private NetworkInformation networkInformation;
|
||||
|
||||
public WhoisInformation() {
|
||||
@ -28,7 +34,11 @@ public class WhoisInformation {
|
||||
* @return the network
|
||||
*/
|
||||
public List<String> getNetwork() {
|
||||
return new ArrayList<>(network);
|
||||
return new ArrayList<>(network);
|
||||
}
|
||||
|
||||
public void addNetwork(List<String> network) {
|
||||
this.network.addAll(new ArrayList<>(network));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -38,11 +48,20 @@ public class WhoisInformation {
|
||||
this.network = new ArrayList<>(network);
|
||||
}
|
||||
|
||||
/**
|
||||
* add a new network to the list of existing networks
|
||||
*
|
||||
* @param network the new network to add
|
||||
*/
|
||||
public void addNetwork(String network) {
|
||||
this.network.add(network);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the rootNetwork
|
||||
*/
|
||||
public List<String> getRootNetwork() {
|
||||
return new ArrayList<>(rootNetwork);
|
||||
return new ArrayList<>(rootNetwork);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,6 +70,10 @@ public class WhoisInformation {
|
||||
public void setRootNetwork(List<String> rootNetwork) {
|
||||
this.rootNetwork = new ArrayList<>(rootNetwork);
|
||||
}
|
||||
|
||||
public void addRootNetwork (String rootNetwork) {
|
||||
this.rootNetwork.add (rootNetwork);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the networkInformation
|
||||
|
||||
Reference in New Issue
Block a user