improved whois
This commit is contained in:
@ -19,7 +19,6 @@ import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public abstract class AbstractWhoisParser implements WhoisParser {
|
||||
@ -29,6 +28,7 @@ public abstract class AbstractWhoisParser implements WhoisParser {
|
||||
|
||||
String[] lines = blockString.split("\n");
|
||||
for (String line : lines) {
|
||||
if (!line.startsWith("%")) {
|
||||
String key;
|
||||
String value;
|
||||
if (line.indexOf(" ") == -1) {
|
||||
@ -39,9 +39,9 @@ public abstract class AbstractWhoisParser implements WhoisParser {
|
||||
value = line.substring(line.indexOf(" "));
|
||||
value = value.trim();
|
||||
}
|
||||
|
||||
returnMap.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
@ -49,6 +49,10 @@ public class ArinWhoisParser extends AbstractWhoisParser implements WhoisParser
|
||||
// if re-allocated just return empty whoisInformation because this RIR is not responsible
|
||||
if (whoisString.contains("Allocated to LACNIC")) {
|
||||
throw new WhoisException("Allocated to LACNIC");
|
||||
} else if (whoisString.contains ("NON-RIPE-NCC-MANAGED-ADDRESS-BLOCK")) {
|
||||
throw new WhoisException("Not managed by RIPE");
|
||||
} else if (whoisString.contains ("This network range is not allocated to APNIC")) {
|
||||
throw new WhoisException("Not allocated to APNIC");
|
||||
}
|
||||
|
||||
whoisInformation.setResponseString(whoisString);
|
||||
|
||||
@ -18,6 +18,7 @@ package de.muehlencord.shared.network.whois;
|
||||
import static de.muehlencord.shared.network.CidrTool.rangeToCidrList;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -40,16 +41,18 @@ public class DefaultWhoisParser extends AbstractWhoisParser implements WhoisPars
|
||||
// if re-allocated just return empty whoisInformation because this RIR is not responsible
|
||||
if (whoisString.contains("Allocated to LACNIC")) {
|
||||
throw new WhoisException("Allocated to LACNIC");
|
||||
} else if (whoisString.contains ("NON-RIPE-NCC-MANAGED-ADDRESS-BLOCK")) {
|
||||
throw new WhoisException("Not managed by RIPE");
|
||||
} else if (whoisString.contains ("This network range is not allocated to APNIC")) {
|
||||
throw new WhoisException("Not allocated to APNIC");
|
||||
}
|
||||
|
||||
whoisInformation = new WhoisInformation();
|
||||
whoisInformation.setResponseString(whoisString);
|
||||
// split by blank lines to identify blocks
|
||||
String[] blocks;
|
||||
if (whoisString.contains("\r\n")) {
|
||||
blocks = whoisString.split("\r\n\r\n");
|
||||
} else {
|
||||
blocks = whoisString.split("\n\n");
|
||||
String[] blocks = whoisString.split ("\\R\\R");
|
||||
if (blocks.length == 1) {
|
||||
blocks = whoisString.lines().collect(Collectors.toList()).toArray(new String[0]);
|
||||
}
|
||||
for (String block : blocks) {
|
||||
analyseBlock(block);
|
||||
@ -81,7 +84,13 @@ public class DefaultWhoisParser extends AbstractWhoisParser implements WhoisPars
|
||||
case "inetnum:":
|
||||
String inetnum = getValue("inetnum:", valueMap);
|
||||
String country = getValue("country:", valueMap);
|
||||
if (country == null && block.contains (".br")) {
|
||||
country = "BR";
|
||||
}
|
||||
String netname = getValue("netname:", valueMap);
|
||||
if (netname == null) {
|
||||
netname = getValue ("owner:", valueMap);
|
||||
}
|
||||
String descr = getValue("descr:", valueMap);
|
||||
|
||||
if ((inetnum == null) || (country == null)) {
|
||||
|
||||
@ -88,8 +88,12 @@ public class WhoisTest extends BaseTest {
|
||||
// whoIsClient.execute("whois.ripe.net", "213.55.95.62"); // Transferred to Afrinic
|
||||
// whoIsClient.execute("whois.afrinic.net", "213.55.95.62");
|
||||
// whoIsClient.execute("whois.arin.net", "32.64.68.229");
|
||||
|
||||
// WhoisInformation info = whoIsClient.execute("whois.lacnic.net", "179.43.168.126");
|
||||
WhoisInformation info = whoIsClient.execute("179.43.168.126");
|
||||
// WhoisInformation info = whoIsClient.execute("143.198.77.103");
|
||||
// WhoisInformation info = whoIsClient.execute("179.43.168.126");
|
||||
WhoisInformation info = whoIsClient.execute("187.50.136.210");
|
||||
|
||||
System.out.println (info);
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
% Copyright (c) Nic.br
|
||||
% The use of the data below is only permitted as described in
|
||||
% full by the terms of use at https://registro.br/termo/en.html ,
|
||||
% being prohibited its distribution, commercialization or
|
||||
% reproduction, in particular, to use it for advertising or
|
||||
% any similar purpose.
|
||||
% 2022-03-01T03:33:15-03:00 - IP: 88.198.54.68
|
||||
|
||||
inetnum: 187.50.0.0/15
|
||||
aut-num: AS10429
|
||||
abuse-c: CSTBR
|
||||
owner: TELEF<45>NICA BRASIL S.A
|
||||
ownerid: 02.558.157/0001-62
|
||||
responsible: Diretoria de Planejamento e Tecnologia
|
||||
owner-c: ARITE
|
||||
tech-c: GRP95
|
||||
inetrev: 187.50.136.0/24
|
||||
nserver: te-br-spo-tic-dns1.tdatabrasil.net.br
|
||||
nsstat: 20220227 AA
|
||||
nslastaa: 20220227
|
||||
nserver: te-br-spo-ib-dns2.tdatabrasil.net.br
|
||||
nsstat: 20220227 AA
|
||||
nslastaa: 20220227
|
||||
created: 20090313
|
||||
changed: 20190410
|
||||
|
||||
nic-hdl-br: ARITE
|
||||
person: Administra<72><61>o Rede IP Telesp
|
||||
created: 20080407
|
||||
changed: 20220104
|
||||
|
||||
nic-hdl-br: CSTBR
|
||||
person: CSIRT TELEFONICA BR
|
||||
created: 20180713
|
||||
changed: 20180713
|
||||
|
||||
nic-hdl-br: GRP95
|
||||
person: Grupo Provisionamento
|
||||
created: 20031027
|
||||
changed: 20060809
|
||||
|
||||
% Security and mail abuse issues should also be addressed to
|
||||
% cert.br, http://www.cert.br/ , respectivelly to cert@cert.br
|
||||
% and mail-abuse@cert.br
|
||||
%
|
||||
% whois.registro.br accepts only direct match queries. Types
|
||||
% of queries are: domain (.br), registrant (tax ID), ticket,
|
||||
% provider, CIDR block, IP and ASN.^M
|
||||
Reference in New Issue
Block a user