Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

use tld heuristic to check if a domain is local or global

Michael Peter Christen898fa7c3f394
diff --git a/source/net/yacy/cora/protocol/Domains.java b/source/net/yacy/cora/protocol/Domains.java
index e236132e2..57d5f2b15 100644
--- a/source/net/yacy/cora/protocol/Domains.java
+++ b/source/net/yacy/cora/protocol/Domains.java
@@ -851,11 +851,12 @@ public class Domains {
}
public static int getDomainID(final String host, final InetAddress hostaddress) {
- if (host == null || host.isEmpty() || isLocal(host, hostaddress)) return TLD_Local_ID;
+ if (host == null || host.isEmpty()) return TLD_Local_ID;
final int p = host.lastIndexOf('.');
final String tld = (p > 0) ? host.substring(p + 1) : "";
final Integer i = TLDID.get(tld);
- return (i == null) ? TLD_Generic_ID : i.intValue();
+ if (i != null) return i.intValue();
+ return (isLocal(host, hostaddress)) ? TLD_Local_ID : TLD_Generic_ID;
}
/**
@@ -905,6 +906,12 @@ public class Domains {
return false;
}
+ // check simply if the tld in the host is a known tld
+ final int p = host.lastIndexOf('.');
+ final String tld = (p > 0) ? host.substring(p + 1) : "";
+ final Integer i = TLDID.get(tld);
+ if (i != null) return false;
+
// check dns lookup: may be a local address even if the domain name looks global
if (!recursive) return false;
if (hostaddress == null) hostaddress = dnsResolve(host);