From 1a525710c1e383cad26bc67d6df28bfcd07ae8fe Mon Sep 17 00:00:00 2001 From: rramthun Date: Sun, 17 Dec 2006 13:21:17 +0000 Subject: [PATCH] =?UTF-8?q?*)=20cursor=20jumps=20now=20to=20searchbox=20on?= =?UTF-8?q?=20searchpages=20again=20*)=20added=20missing=20private=20IP-ra?= =?UTF-8?q?nges=20for=20APIPA/Zeroconf=20and=20172.16.0.0=E2=80=93172.31.2?= =?UTF-8?q?55.255=20*)=20Changed=20some=20seed-download-errors=20to=20warn?= =?UTF-8?q?ings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3086 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/DetailedSearch.html | 2 +- htroot/index.html | 2 +- source/de/anomic/server/serverCore.java | 34 ++++++++++++++-------- source/de/anomic/yacy/yacyPeerActions.java | 8 +++-- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/htroot/DetailedSearch.html b/htroot/DetailedSearch.html index 9645a4d61..fcee802ea 100644 --- a/htroot/DetailedSearch.html +++ b/htroot/DetailedSearch.html @@ -26,7 +26,7 @@

Detailed Search

- +
diff --git a/htroot/index.html b/htroot/index.html index 2fffd0b97..6d2c95624 100644 --- a/htroot/index.html +++ b/htroot/index.html @@ -19,7 +19,7 @@
- +
Text   diff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.java index d585a94d8..8ca8471e9 100644 --- a/source/de/anomic/server/serverCore.java +++ b/source/de/anomic/server/serverCore.java @@ -411,22 +411,31 @@ public final class serverCore extends serverAbstractThread implements serverThre return isNotLocal(url.getHost()); } - public static boolean isNotLocal(String ip) { - // generate ip address if ip is given by host - assert (ip != null); + /** + * Checks if a given address (hostname or IP) is *not* a local address + * + * @param address Address to check + * @return boolean, true if address is public, false if address is private + */ + public static boolean isNotLocal(String address) { + + assert (address != null); // check local ip addresses - if ((ip.equals("localhost")) || - (ip.startsWith("127")) || - (ip.startsWith("192.168")) || - (ip.startsWith("10.")) + if ((address.equals("localhost")) || + (address.startsWith("127")) || + (address.startsWith("192.168")) || + (address.startsWith("10.")) || + (address.startsWith("169.254")) || + //172.16.0.0–172.31.255.255 (I think this is faster than a regex) + (address.startsWith("172.16")) || (address.startsWith("172.17")) || (address.startsWith("172.18")) || (address.startsWith("172.19")) || (address.startsWith("172.20")) || (address.startsWith("172.21")) || (address.startsWith("172.22")) || (address.startsWith("172.23")) || (address.startsWith("172.24")) || (address.startsWith("172.25")) || (address.startsWith("172.26")) || (address.startsWith("172.27")) || (address.startsWith("172.28")) || (address.startsWith("172.29")) || (address.startsWith("172.30")) || (address.startsWith("172.31")) ) return false; - // make a dns resolve - final InetAddress clientAddress = httpc.dnsResolve(ip); + // make a dns resolve if a hostname is given and check again + final InetAddress clientAddress = httpc.dnsResolve(address); if (clientAddress != null) { if ((clientAddress.isAnyLocalAddress()) || (clientAddress.isLoopbackAddress())) return false; - if (ip.charAt(0) > '9') ip = clientAddress.getHostAddress(); + if (address.charAt(0) > '9') address = clientAddress.getHostAddress(); } // finally check if there are other local IP adresses that are not in the standard IP range @@ -434,7 +443,7 @@ public final class serverCore extends serverAbstractThread implements serverThre if (localAddresses[i].equals(clientAddress)) return false; } - // the address must be a gloabl IP address + // the address must be a global address return true; } @@ -526,7 +535,8 @@ public final class serverCore extends serverAbstractThread implements serverThre } public void freemem() { - // do nothing; FIXME: can we something here to flush memory? + // FIXME: can we something here to flush memory? Idea: Reduce the size of some of our various caches. + System.gc(); } // class body diff --git a/source/de/anomic/yacy/yacyPeerActions.java b/source/de/anomic/yacy/yacyPeerActions.java index b6f42eae2..1038713b0 100644 --- a/source/de/anomic/yacy/yacyPeerActions.java +++ b/source/de/anomic/yacy/yacyPeerActions.java @@ -193,7 +193,7 @@ public class yacyPeerActions { url = new URL(seedListFileURL); header = httpc.whead(url, url.getHost(), this.bootstrapLoadTimeout, null, null, this.sb.remoteProxyConfig,reqHeader); if ((header == null) || (header.lastModified() == null)) { - yacyCore.log.logInfo("BOOTSTRAP: seed-list URL " + seedListFileURL + " not available"); + yacyCore.log.logWarning("BOOTSTRAP: seed-list URL " + seedListFileURL + " not available"); } else if ((header.age() > 86400000) && (ssc > 0)) { yacyCore.log.logInfo("BOOTSTRAP: seed-list URL " + seedListFileURL + " too old (" + (header.age() / 86400000) + " days)"); } else { @@ -214,10 +214,12 @@ public class yacyPeerActions { yacyCore.log.logInfo("BOOTSTRAP: " + lc + " seeds from seed-list URL " + seedListFileURL + ", AGE=" + (header.age() / 3600000) + "h"); } + } catch (IOException e) { + // this is when wget fails, commonly because of timeout + yacyCore.log.logWarning("BOOTSTRAP: failed to load seeds from seed-list URL " + seedListFileURL + ": " + e.getMessage()); } catch (Exception e) { // this is when wget fails; may be because of missing internet connection - // we do nothing here and go silently over it - yacyCore.log.logSevere("BOOTSTRAP: failed to load seeds from seed-list URL " + seedListFileURL); + yacyCore.log.logSevere("BOOTSTRAP: failed to load seeds from seed-list URL " + seedListFileURL + ": " + e.getMessage()); } } }