Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
*) Adding new connection tracking page (currently only for incoming connections) *) Displaying statistic for incoming connections on status page *) Bugfix for Loop-Access Bug when trying to access the yacy page while yacy is configured as proxy See: http://www.yacy-forum.de/viewtopic.php?p=6826 *) Bugfix for Referer Bug See: http://www.yacy-forum.de/viewtopic.php?p=11098#11098 *) Adding reverse Name lookup for yacy-domain names (used by the connection tracking page)
thelic8a35a013077
diff --git a/htroot/Connections_p.html b/htroot/Connections_p.htmlnew file mode 100644index 000000000..c3941206f--- /dev/null+++ b/htroot/Connections_p.html@@ -0,0 +1,37 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">+<html>+<head>+<title>YaCy '#[clientname]#': Connection Tracking</title>+#[metas]#+</head>+<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">+#[header]#+<p><h2>Connection Tracking</h2></p>+<p><h3>Incoming Connections</h3></p>+<p>Showing #[numActiveRunning]# active connections, #[numActivePending]# pending connections from a max. of #[numMax]# allowed incoming connections.<br>+<table border="0" cellpadding="2" cellspacing="1">+<tr class="TableHeader" valign="bottom">+ <td class="small">Protocol</td>+ <td class="small">Duration</td>+ <td class="small">Source IP[:Port]</td>+ <td class="small">Dest. IP[:Port]</td>+ <td class="small">Command</td>+ <td class="small">Used</td>+</tr>+#{list}#+<tr class="TableCell#(dark)#Light::Dark::Summary#(/dark)#" title="#[sessionName]#">+ <td class="small">#[proto]#</td>+ <td class="small">#(ms)##[duration]#::#[duration]# ms#(/ms)#</td>+ <td class="small">#[source]#</td>+ <td class="small">#[dest]#</td>+ <td class="small">#(running)#Waiting for new request nr. # #[reqNr]#::#[command]##(/running)#</td>+ <td class="small">#[used]#</td>+</tr>+#{/list}#+</table>+</p>++#[footer]#++</body>+</html>\ No newline at end of filediff --git a/htroot/Connections_p.java b/htroot/Connections_p.javanew file mode 100644index 000000000..5805a2f40--- /dev/null+++ b/htroot/Connections_p.java@@ -0,0 +1,167 @@+//PerformaceQueues_p.java+//-----------------------+//part of YaCy+//(C) by Michael Peter Christen; [email protected]+//first published on http://www.anomic.de+//Frankfurt, Germany, 2004, 2005+//last major change: 16.02.2005+//+//This program is free software; you can redistribute it and/or modify+//it under the terms of the GNU General Public License as published by+//the Free Software Foundation; either version 2 of the License, or+//(at your option) any later version.+//+//This program is distributed in the hope that it will be useful,+//but WITHOUT ANY WARRANTY; without even the implied warranty of+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+//GNU General Public License for more details.+//+//You should have received a copy of the GNU General Public License+//along with this program; if not, write to the Free Software+//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+//+//Using this software in any meaning (reading, learning, copying, compiling,+//running) means that you agree that the Author(s) is (are) not responsible+//for cost, loss of data or any harm that may be caused directly or indirectly+//by usage of this softare or this documentation. The usage of this software+//is on your own risk. The installation and usage (starting/running) of this+//software may allow other people or application to access your computer and+//any attached devices and is highly dependent on the configuration of the+//software which must be done by the user of the software; the author(s) is+//(are) also not responsible for proper configuration and usage of the+//software, even if provoked by documentation provided together with+//the software.+//+//Any changes to this file according to the GPL as documented in the file+//gpl.txt aside this file in the shipment you received can be done to the+//lines that follows this copyright notice here, but changes must not be+//done inside the copyright notive above. A re-distribution must contain+//the intact and unchanged copyright notice.+//Contributions and changes to the program code must be marked as such.++//You must compile this file with+//javac -classpath .:../classes Network.java+//if the shell's current path is HTROOT++import java.net.InetAddress;+import java.util.Properties;++import org.apache.commons.pool.impl.GenericObjectPool;++import de.anomic.http.httpHeader;+import de.anomic.http.httpd;+import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.server.serverCore;+import de.anomic.server.serverDate;+import de.anomic.server.serverHandler;+import de.anomic.server.serverObjects;+import de.anomic.server.serverSwitch;+import de.anomic.server.serverThread;+import de.anomic.server.serverCore.Session;+import de.anomic.yacy.yacyCore;+import de.anomic.yacy.yacySeed;+import de.anomic.yacy.yacySeedDB;++public class Connections_p {++ public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch sb) {+ // return variable that accumulates replacements+ plasmaSwitchboard switchboard = (plasmaSwitchboard) sb;+ serverObjects prop = new serverObjects();++ String virtualHost = switchboard.getConfig("fileHost","localhost");++ serverThread httpd = switchboard.getThread("10_httpd");+ ThreadGroup httpSessions = ((serverCore)httpd).getSessionThreadGroup();++ GenericObjectPool.Config httpdPoolConfig = ((serverCore)httpd).getPoolConfig();++ /* waiting for all threads to finish */+ int threadCount = httpSessions.activeCount();+ Thread[] threadList = new Thread[httpdPoolConfig.maxActive];+ threadCount = httpSessions.enumerate(threadList);++ int idx = 0, numActiveRunning = 0, numActivePending = 0, numMax = ((serverCore)httpd).getMaxSessionCount();+ boolean dark = true;+ for ( int currentThreadIdx = 0; currentThreadIdx < threadCount; currentThreadIdx++ ) {+ Thread currentThread = threadList[currentThreadIdx];+ if ((currentThread != null) && (currentThread instanceof serverCore.Session) && (currentThread.isAlive())) {+ // getting the session object+ Session currentSession = ((Session)currentThread);++ // getting the session runtime+ long sessionTime = currentSession.getTime();++ // getting the request command line+ boolean blockingRequest = false;+ String commandLine = currentSession.getCommandLine();+ if (commandLine == null) blockingRequest = true;+ int commandCount = currentSession.getCommandCount();++ // getting the source ip address and port+ InetAddress userAddress = currentSession.getUserAddress();+ int userPort = currentSession.getUserPort();+ if (userAddress == null) continue;++ serverHandler cmdObj = currentSession.getCommandObj();+ if (cmdObj instanceof httpd) {++ // getting the http command object+ httpd currentHttpd = (httpd)cmdObj;++ // getting the connection properties of this session+ Properties conProp = (Properties) currentHttpd.getConProp().clone();++ // getting the destination host+ String dest = conProp.getProperty(httpHeader.CONNECTION_PROP_HOST);+ if (dest==null)continue;+ if (dest.equals(virtualHost)) dest = yacyCore.seedDB.mySeed.getName() + ".yacy";++++ // determining if the source is a yacy host+ yacySeed seed = yacyCore.seedDB.lookupByIP(userAddress,true,true,true);+ if (seed != null) {+ if ((seed.hash == yacyCore.seedDB.mySeed.hash) &&+ (!seed.get("Port","").equals(Integer.toString(userPort)))) {+ seed = null;+ }+ }++ prop.put("list_" + idx + "_dark", ((dark) ? 1 : 0) ); dark=!dark;+ prop.put("list_" + idx + "_sessionName",currentSession.getName());+ prop.put("list_" + idx + "_proto","http");+ if (sessionTime > 1000*60) {+ prop.put("list_" + idx + "_ms",0);+ prop.put("list_" + idx + "_ms_duration",serverDate.intervalToString(sessionTime));+ } else {+ prop.put("list_" + idx + "_ms",1);+ prop.put("list_" + idx + "_ms_duration",Long.toString(sessionTime));+ }+ prop.put("list_" + idx + "_source",(seed!=null)?seed.getName()+".yacy":userAddress.getHostAddress()+":"+userPort);+ prop.put("list_" + idx + "_dest",dest);+ if (blockingRequest) {+ prop.put("list_" + idx + "_running",0);+ prop.put("list_" + idx + "_running_reqNr",Integer.toString(commandCount+1));+ numActivePending++;+ } else {+ prop.put("list_" + idx + "_running",1);+ prop.put("list_" + idx + "_running_command",commandLine);+ numActiveRunning++;+ }+ prop.put("list_" + idx + "_used",Integer.toString(commandCount));++ idx++;+ }+ }+ }+ prop.put("list",idx);++ prop.put("numMax",Integer.toString(numMax));+ prop.put("numActiveRunning",Integer.toString(numActiveRunning));+ prop.put("numActivePending",Integer.toString(numActivePending));++ // return rewrite values for templates+ return prop;+ }+}diff --git a/htroot/Status.java b/htroot/Status.javaindex 012fa9369..7c44c6705 100644--- a/htroot/Status.java+++ b/htroot/Status.java@@ -58,6 +58,7 @@ import de.anomic.server.serverCore;import de.anomic.server.serverDate;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;+import de.anomic.server.serverThread;import de.anomic.yacy.yacyCore;import de.anomic.yacy.yacySeed;@@ -227,6 +228,15 @@ public class Status {prop.put("trafficIn",bytesToString(httpdByteCountInputStream.getGlobalCount()));prop.put("trafficOut",bytesToString(httpdByteCountOutputStream.getGlobalCount()));+ // connection information+ serverCore httpd = (serverCore) env.getThread("10_httpd");+ int activeSessionCount = httpd.getActiveSessionCount();+ int idleSessionCount = httpd.getIdleSessionCount();+ int maxSessionCount = httpd.getMaxSessionCount();+ prop.put("connectionsActive",Integer.toString(activeSessionCount));+ prop.put("connectionsMax",Integer.toString(maxSessionCount));+ prop.put("connectionsIdle",Integer.toString(idleSessionCount));+// Queue informationfinal plasmaSwitchboard sb = (plasmaSwitchboard)env;prop.put("indexingQueueSize", Integer.toString(sb.getThread("80_indexing").getJobCount()+sb.indexingTasksInProcess.size()));diff --git a/htroot/Status_p.inc b/htroot/Status_p.incindex abd4ca54f..3268dbb28 100644--- a/htroot/Status_p.inc+++ b/htroot/Status_p.inc@@ -1,38 +1,88 @@<table border="0" cellpadding="2" cellspacing="1" width="100%">-<tr class="TableHeader"><td colspan="2"><b>Private System Properties</b></td></tr>-<tr class="TableCellDark"><td width="150">Protection</td><td>-#(protection)#-<b>Your settings are _not_ protected!</b> Please go to the <a href="Settings_p.html#admin">settings</a> page <b>immediately</b> and set an administration password.-::-Your settings are protected by a password.-#(/protection)#-</td></tr>-<tr class="TableCellLight"><td>Proxy host</td><td>#[host]#:#[port]#</td></tr>-<tr class="TableCellDark"><td>Port forwarding host</td><td>#(portForwarding)#not used::#[host]#:#[port]# (#(status)#broken::connected#(/status)#)#(/portForwarding)#</td></tr>-<tr class="TableCellLight"><td>Remote proxy</td><td>#(remoteProxy)#not used::#[host]#:#[port]##(/remoteProxy)#</td></tr>-<tr class="TableCellDark"><td>Auto-popup on start-up</td><td>-#(popup)#-Disabled. To enable this again please use the <a href="Settings_p.html#SystemBehaviour">Settings</a> page-::-Enabled. To disable this please use the <a href="Settings_p.html#SystemBehaviour">Settings</a> page-#(/popup)#-</td></tr>-<tr class="TableCellLight"><td>Memory Usage</td><td>-<!---<form action="Status.html" method="get">free: #[freeMemory]# | total: #[totalMemory]# | max: #[maxMemory]# | <input type="submit" name="gc" value="Do Garbage-Collect now"></form>--->-free: #[freeMemory]# | total: #[totalMemory]# | max: #[maxMemory]#-</td></tr>-<tr class="TableCellDark"><td>Traffic</td><td>-Out: #[trafficIn]# | In: #[trafficOut]#-</td></tr>-<tr class="TableCellLight"><td>System Resources</td><td>-Processors: #[processors]#-</td></tr>-<tr class="TableCellDark"><td>Indexing Queue</td><td>#[indexingQueueSize]# | #[indexingQueueMax]#</td></tr>-<tr class="TableCellLight"><td>Loader Queue</td><td>#[loaderQueueSize]# | #[loaderQueueMax]# #(loaderPaused)#::(paused)#(/loaderPaused)#</td></tr>-<tr class="TableCellDark"><td>Local Crawler Queue</td><td>Enqueued: #[localCrawlQueueSize]# | Pending: #[stackCrawlQueueSize]#</td></tr>-<tr class="TableCellLight"><td>Remote Crawler Queue</td><td>#[remoteCrawlQueueSize]#</td></tr>+<tr class="TableHeader">+ <td colspan="3"><b>Private System Properties</b></td>+</tr>+<tr class="TableCellLight">+ <td>System Resources</td>+ <td>Processors: #[processors]#</td>+ <td width="50"> </td>+</tr>+<tr class="TableCellDark">+ <td width="150">Protection</td>+ <td>+ #(protection)#+ <b>Your settings are _not_ protected!</b> Please go to the <a href="Settings_p.html#admin">settings</a> page <b>immediately</b> and set an administration password.+ ::+ Your settings are protected by a password.+ #(/protection)#+ </td>+ <td> </td>+</tr>+<tr class="TableCellLight">+ <td>Proxy host</td>+ <td>#[host]#:#[port]#</td>+ <td> </td>+</tr>+<tr class="TableCellDark">+ <td>Port forwarding host</td>+ <td>#(portForwarding)#not used::#[host]#:#[port]# (#(status)#broken::connected#(/status)#)#(/portForwarding)#</td>+ <td> </td>+</tr>+<tr class="TableCellLight">+ <td>Remote proxy</td>+ <td>#(remoteProxy)#not used::#[host]#:#[port]##(/remoteProxy)#</td>+ <td> </td>+</tr>+<tr class="TableCellDark">+ <td>Auto-popup on start-up</td>+ <td>+ #(popup)#+ Disabled. To enable this again please use the <a href="Settings_p.html#SystemBehaviour">Settings</a> page+ ::+ Enabled. To disable this please use the <a href="Settings_p.html#SystemBehaviour">Settings</a> page+ #(/popup)#+ </td>+ <td> </td>+</tr>+<tr class="TableCellLight">+ <td>Memory Usage</td><td>+ <!--+ <form action="Status.html" method="get">free: #[freeMemory]# | total: #[totalMemory]# | max: #[maxMemory]# | <input type="submit" name="gc" value="Do Garbage-Collect now"></form>+ -->+ free: #[freeMemory]# | total: #[totalMemory]# | max: #[maxMemory]#+ </td>+ <td> </td>+</tr>+<tr class="TableCellDark">+ <td>Traffic</td>+ <td>Out: #[trafficIn]# | In: #[trafficOut]#</td>+ <td> </td>+</tr>+<tr class="TableCellLight">+ <td>Connections Incoming</td>+ <td>Active: #[connectionsActive]# | Idle: #[connectionsIdle]# | Max: #[connectionsMax]#</td>+ <td>[<a href="Connections_p.html">Details</a>]</td>+</tr>+<tr class="TableCellDark">+ <td>Indexing Queue</td>+ <td>#[indexingQueueSize]# | #[indexingQueueMax]#</td>+ <td>[<a href="IndexCreateIndexingQueue_p.html">Details</a>]</td>+</tr>+<tr class="TableCellLight">+ <td>Loader Queue</td>+ <td>#[loaderQueueSize]# | #[loaderQueueMax]# #(loaderPaused)#::(paused)#(/loaderPaused)#</td>+ <td>[<a href="IndexCreateLoaderQueue_p.html">Details</a>]</td>+</tr>+<tr class="TableCellDark">+ <td>Local Crawler Queue</td>+ <td>Enqueued: #[localCrawlQueueSize]# | Pending: #[stackCrawlQueueSize]#</td>+ <td>[<a href="IndexCreateWWWLocalQueue_p.html">Details</a>]</td>+</tr>+<tr class="TableCellLight">+ <td>Remote Crawler Queue</td>+ <td>#[remoteCrawlQueueSize]#</td>+ <td>[<a href="IndexCreateWWWGlobalQueue_p.html">Details</a>]</td>+</tr></table>\ No newline at end of filediff --git a/source/de/anomic/http/httpHeader.java b/source/de/anomic/http/httpHeader.javaindex d086c6915..e45d0c533 100644--- a/source/de/anomic/http/httpHeader.java+++ b/source/de/anomic/http/httpHeader.java@@ -541,7 +541,8 @@ public final class httpHeader extends TreeMap implements Map {} else {// THIS IS THE "GOOD" CASE// a perfect formulated url- prop.setProperty(httpHeader.CONNECTION_PROP_HOST, args.substring(0, sep));+ String dstHostSocket = args.substring(0, sep);+ prop.setProperty(httpHeader.CONNECTION_PROP_HOST, (httpd.isThisHostName(dstHostSocket)?virtualHost:dstHostSocket));prop.setProperty(httpHeader.CONNECTION_PROP_PATH, args.substring(sep)); // yes, including beginning "/"}} else {@@ -699,29 +700,11 @@ public final class httpHeader extends TreeMap implements Map {// if the transparent proxy support was disabled, we have nothing todo here ...if (!(isTransparentProxy && header.containsKey(HOST))) return;- try {- String dstHost, dstHostSocket = (String) header.get(HOST);-- int idx = dstHostSocket.indexOf(":");- dstHost = (idx != -1) ? dstHostSocket.substring(0,idx).trim() : dstHostSocket.trim();- Integer dstPort = (idx != -1) ? Integer.valueOf(dstHostSocket.substring(idx+1)) : new Integer(80);-- if (dstPort.intValue() == 80) {- if (dstHost.endsWith(".yacy")) {- // if this peer is accessed via its yacy domain name we need to set the- // host property to virtualHost to redirect the request to the yacy server- if (dstHost.endsWith(yacyCore.seedDB.mySeed.getName()+".yacy")) {- prop.setProperty(CONNECTION_PROP_HOST,virtualHost);- } else {- prop.setProperty(CONNECTION_PROP_HOST,dstHostSocket);- }- } else {- InetAddress dstHostAddress = InetAddress.getByName(dstHost);- if (!(dstHostAddress.isAnyLocalAddress() || dstHostAddress.isLoopbackAddress())) {- prop.setProperty(CONNECTION_PROP_HOST,dstHostSocket);- }- }- }- } catch (Exception e) {}+ // we only need to do the transparent proxy support if the request URL didn't contain the hostname+ // and therefor was set to virtualHost by function parseQuery()+ if (!prop.getProperty(CONNECTION_PROP_HOST).equals(virtualHost)) return;++ String dstHostSocket = (String) header.get(httpHeader.HOST);+ prop.setProperty(CONNECTION_PROP_HOST,(httpd.isThisHostName(dstHostSocket)?virtualHost:dstHostSocket));}}\ No newline at end of filediff --git a/source/de/anomic/http/httpd.java b/source/de/anomic/http/httpd.javaindex 0aab9bc74..c629f7a63 100644--- a/source/de/anomic/http/httpd.java+++ b/source/de/anomic/http/httpd.java@@ -148,6 +148,10 @@ public final class httpd implements serverHandler {keepAliveSupport = Boolean.valueOf(switchboard.getConfig("connectionKeepAliveSupport","false")).booleanValue();}+ public Properties getConProp() {+ return this.prop;+ }+/*** Can be used to reset this {@link serverHandler} oject so that* it can be reused for further connections@@ -782,7 +786,7 @@ public final class httpd implements serverHandler {}// parsing post request bodies which are gzip content-encoded} else {- ByteArrayOutputStream bout = new ByteArrayOutputStream();+ serverByteBuffer bout = new serverByteBuffer();serverFileUtils.copy(in,bout);buffer = bout.toByteArray();bout.close(); bout = null;@@ -1310,6 +1314,85 @@ public final class httpd implements serverHandler {// httpHeader.CONNECTION_PROP_PROXY_RESPOND_STATUS}+ public static boolean isThisHostPortForwardingIP(String hostName) {+ if ((hostName == null) || (hostName.length() == 0)) return false;+ if ((!serverCore.portForwardingEnabled) || (serverCore.portForwarding == null)) return false;++ boolean isThisHostIP = false;+ try {+ InetAddress hostAddress = InetAddress.getByName(hostName);+ InetAddress forwardingAddress = InetAddress.getByName(serverCore.portForwarding.getHost());++ if (hostAddress.equals(forwardingAddress)) return true;+ } catch (Exception e) {}+ return isThisHostIP;+ }++ public static boolean isThisHostIP(String hostName) {+ if ((hostName == null) || (hostName.length() == 0)) return false;++ boolean isThisHostIP = false;+ try {+ final InetAddress clientAddress = InetAddress.getByName(hostName);+ if (clientAddress.isAnyLocalAddress() || clientAddress.isLoopbackAddress()) return true;++ final InetAddress[] localAddress = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());+ for (int i=0; i<localAddress.length; i++) {+ if (localAddress[i].equals(clientAddress)) {+ isThisHostIP = true;+ break;+ }+ }+ } catch (Exception e) {}+ return isThisHostIP;+ }++ public static boolean isThisHostIP(InetAddress clientAddress) {+ if (clientAddress == null) return false;++ boolean isThisHostIP = false;+ try {+ if (clientAddress.isAnyLocalAddress() || clientAddress.isLoopbackAddress()) return true;++ final InetAddress[] localAddress = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());+ for (int i=0; i<localAddress.length; i++) {+ if (localAddress[i].equals(clientAddress)) {+ isThisHostIP = true;+ break;+ }+ }+ } catch (Exception e) {}+ return isThisHostIP;+ }++ public static boolean isThisHostName(String hostName) {+ if ((hostName == null) || (hostName.length() == 0)) return false;++ try {+ final int idx = hostName.indexOf(":");+ final String dstHost = (idx != -1) ? hostName.substring(0,idx).trim() : hostName.trim();+ final Integer dstPort = (idx != -1) ? Integer.valueOf(hostName.substring(idx+1).trim()) : new Integer(80);++ // if the hostname endswith thisPeerName.yacy ...+ if (dstHost.endsWith(yacyCore.seedDB.mySeed.getName() + ".yacy")) {+ return true;+ /*+ * If the port number is equal to the yacy port and the IP address is an address of this host ...+ * Please note that yacy is listening to all interfaces of this host+ */+ } else if (dstPort.equals(Integer.valueOf(switchboard.getConfig("port", "8080"))) &&+ isThisHostIP(dstHost)) {+ return true;+ } else if ((serverCore.portForwardingEnabled) &&+ (serverCore.portForwarding != null) &&+ (dstPort.intValue() == serverCore.portForwarding.getPort()) &&+ isThisHostPortForwardingIP(dstHost)) {+ return true;+ }+ } catch (Exception e) {}+ return false;+ }+// public static boolean isTextMime(String mime, Set whitelist) {// if (whitelist.contains(mime)) return true;diff --git a/source/de/anomic/plasma/plasmaCrawlStacker.java b/source/de/anomic/plasma/plasmaCrawlStacker.javaindex 0c863e375..b22502845 100644--- a/source/de/anomic/plasma/plasmaCrawlStacker.java+++ b/source/de/anomic/plasma/plasmaCrawlStacker.java@@ -784,10 +784,10 @@ public final class plasmaCrawlStacker {} finally {reset();- if (!this.stopped && !this.isInterrupted() && !theWorkerPool.isClosed) {+ if (!this.stopped && !this.isInterrupted() && !plasmaCrawlStacker.this.theWorkerPool.isClosed) {try {this.setName("stackCrawlThread_inPool");- theWorkerPool.returnObject(this);+ plasmaCrawlStacker.this.theWorkerPool.returnObject(this);} catch (Exception e1) {// e1.printStackTrace();this.stopped = true;@@ -798,12 +798,12 @@ public final class plasmaCrawlStacker {}}- private void execute() throws InterruptedException {+ private void execute() {try {String rejectReason = dequeue(this.theMsg);if (rejectReason != null) {- sb.urlPool.errorURL.newEntry(+ plasmaCrawlStacker.this.sb.urlPool.errorURL.newEntry(new URL(this.theMsg.url()),this.theMsg.referrerHash(),this.theMsg.initiatorHash(),diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.javaindex 06d651a83..46a1c6cf7 100644--- a/source/de/anomic/plasma/plasmaSwitchboard.java+++ b/source/de/anomic/plasma/plasmaSwitchboard.java@@ -1091,7 +1091,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements sere = (Map.Entry) i.next();nexturlstring = (String) e.getKey();- sbStackCrawlThread.enqueue(nexturlstring, entry.normalizedURLString(), initiatorHash, (String) e.getValue(), loadDate, entry.depth() + 1, entry.profile());+ sbStackCrawlThread.enqueue(nexturlstring, entry.url().toString(), initiatorHash, (String) e.getValue(), loadDate, entry.depth() + 1, entry.profile());// rejectReason = stackCrawl(nexturlstring, entry.normalizedURLString(), initiatorHash, (String) e.getValue(), loadDate, entry.depth() + 1, entry.profile());// if (rejectReason == null) {@@ -1284,7 +1284,13 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serlog.logInfo(stats + ": urlEntry=null");return;}- cacheLoader.loadParallel(urlEntry.url(), urlEntry.name(), urlEntry.referrerHash(), urlEntry.initiator(), urlEntry.depth(), profile);++ URL refererURL = null;+ String refererHash = urlEntry.referrerHash();+ if ((refererHash != null) && (!refererHash.equals(plasmaURL.dummyHash))) {+ refererURL = this.urlPool.getURL(refererHash);+ }+ cacheLoader.loadParallel(urlEntry.url(), urlEntry.name(), (refererURL!=null)?refererURL.toString():null, urlEntry.initiator(), urlEntry.depth(), profile);log.logInfo(stats + ": enqueued for load " + urlEntry.url() + " [" + urlEntry.hash() + "]");return;}diff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.javaindex d8118246e..ce1e044d9 100644--- a/source/de/anomic/server/serverCore.java+++ b/source/de/anomic/server/serverCore.java@@ -112,6 +112,10 @@ public final class serverCore extends serverAbstractThread implements serverThrefinal ThreadGroup theSessionThreadGroup = new ThreadGroup("sessionThreadGroup");private Config cralwerPoolConfig = null;+ public ThreadGroup getSessionThreadGroup() {+ return this.theSessionThreadGroup;+ }+private static ServerSocketFactory getServerSocketFactory(boolean dflt, File keyfile, String passphrase) {// see doc's at// http://java.sun.com/developer/technicalArticles/Security/secureinternet/@@ -463,6 +467,18 @@ public final class serverCore extends serverAbstractThread implements serverThrereturn this.theSessionPool.getNumActive();}+ public int getActiveSessionCount() {+ return this.theSessionPool.getNumActive();+ }++ public int getIdleSessionCount() {+ return this.theSessionPool.getNumIdle();+ }++ public int getMaxSessionCount() {+ return this.theSessionPool.getMaxActive();+ }+// idle sensor: the thread is idle if there are no sessions runningpublic boolean idle() {// idleThreadCheck();@@ -651,6 +667,7 @@ public final class serverCore extends serverAbstractThread implements serverThrepublic Socket controlSocket; // dialog socketpublic InetAddress userAddress; // the address of the client+ public int userPort; // the ip port used by the clientpublic PushbackInputStream in; // on control input streampublic OutputStream out; // on control output stream, autoflushprivate int socketTimeout;@@ -660,11 +677,28 @@ public final class serverCore extends serverAbstractThread implements serverThrepublic Session(ThreadGroup theThreadGroup) {super(theThreadGroup,"Session");-- // setting the session startup time- this.start = System.currentTimeMillis();}+ public int getCommandCount() {+ return this.commandCounter;+ }++ public String getCommandLine() {+ return this.request;+ }++ public serverHandler getCommandObj() {+ return this.commandObj;+ }++ public InetAddress getUserAddress() {+ return this.userAddress;+ }++ public int getUserPort() {+ return this.userPort;+ }+public void setStopped(boolean stopped) {this.stopped = stopped;}@@ -759,9 +793,17 @@ public final class serverCore extends serverAbstractThread implements serverThrethis.done = true;this.syncObject = null;this.readLineBuffer.reset();- this.commandObj.reset();+ if (this.commandObj !=null) this.commandObj.reset();+ this.userAddress = null;+ this.userPort = 0;+ this.controlSocket = null;+ this.request = null;}+ private void shortReset() {+ this.request = null;+ }+/****@@ -813,11 +855,15 @@ public final class serverCore extends serverAbstractThread implements serverThreprivate void execute() throws InterruptedException {try {+ // setting the session startup time+ this.start = System.currentTimeMillis();+// settin the session identitythis.identity = "-";// getting some client informationthis.userAddress = this.controlSocket.getInetAddress();+ this.userPort = this.controlSocket.getPort();this.setName("Session_" + this.userAddress.getHostAddress() + ":" + this.controlSocket.getPort());// TODO: check if we want to allow this socket to connect us@@ -993,7 +1039,10 @@ public final class serverCore extends serverAbstractThread implements serverThreSystem.out.println("ERROR E " + this.userAddress.getHostAddress());// whatever happens: the thread has to survive!writeLine("UNKNOWN REASON:" + this.commandObj.error(e));- }+ }++ shortReset();+} // end of while} catch (java.lang.ClassNotFoundException e) {System.out.println("Internal error: Wrapper class not found: " + e.getMessage());diff --git a/source/de/anomic/yacy/yacyPeerActions.java b/source/de/anomic/yacy/yacyPeerActions.javaindex a42d3772e..2211c4976 100644--- a/source/de/anomic/yacy/yacyPeerActions.java+++ b/source/de/anomic/yacy/yacyPeerActions.java@@ -336,6 +336,11 @@ public class yacyPeerActions {yacyCore.log.logFine("connect: rejecting old info about peer '" + seed.getName() + "'");return false;}++ if (connectedSeed.getName() != seed.getName()) {+ // TODO: update seed name lookup cache+ }+} catch (java.text.ParseException e) {}yacyCore.log.logFine("connect: updated KNOWN " + ((direct) ? "direct " : "") + peerType + " peer '" + seed.getName() + "' from " + seed.getAddress());seedDB.addConnected(seed);diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.javaindex 4b9401340..a790e2b80 100644--- a/source/de/anomic/yacy/yacySeedDB.java+++ b/source/de/anomic/yacy/yacySeedDB.java@@ -45,7 +45,10 @@ import java.io.File;import java.io.FileWriter;import java.io.IOException;import java.io.PrintWriter;+import java.lang.ref.SoftReference;+import java.net.InetAddress;import java.net.URL;+import java.net.UnknownHostException;import java.util.ArrayList;import java.util.Enumeration;import java.util.HashSet;@@ -54,6 +57,7 @@ import java.util.Iterator;import java.util.Map;import de.anomic.http.httpc;+import de.anomic.http.httpd;import de.anomic.kelondro.kelondroDyn;import de.anomic.kelondro.kelondroException;import de.anomic.kelondro.kelondroMScoreCluster;@@ -89,6 +93,7 @@ public final class yacySeedDB {public yacySeed mySeed; // my own seedpublic final File myOwnSeedFile;private final Hashtable nameLookupCache;+ private final Hashtable ipLookupCache;public yacySeedDB(plasmaSwitchboard sb,@@ -134,6 +139,9 @@ public final class yacySeedDB {// start our virtual DNS service for yacy peers with empty cachenameLookupCache = new Hashtable();+ // cache for reverse name lookup+ ipLookupCache = new Hashtable();+// check if we are in the seedCaches: this can happen if someone else published our seedremoveMySeed();@@ -508,6 +516,105 @@ public final class yacySeedDB {return null;}+ public yacySeed lookupByIP(+ InetAddress peerIP,+ boolean lookupConnected,+ boolean lookupDisconnected,+ boolean lookupPotential+ ) {++ yacySeed seed = null;++ // local peer?+ if (httpd.isThisHostIP(peerIP)) return mySeed;++ // then try to use the cache+ SoftReference ref = (SoftReference) ipLookupCache.get(peerIP);+ if (ref != null) {+ seed = (yacySeed) ref.get();+ if (seed != null) return seed;+ }++ int pos = -1;+ String addressStr = null;+ InetAddress seedIPAddress = null;++ if (lookupConnected) {+ // enumerate the cache and simultanous insert values+ Enumeration e = seedsConnected(true, false, null);++ while (e.hasMoreElements()) {+ try {+ seed = (yacySeed) e.nextElement();+ if (seed != null) {+ addressStr = seed.getAddress();+ if ((pos = addressStr.indexOf(":"))!= -1) {+ addressStr = addressStr.substring(0,pos);+ }+ seedIPAddress = InetAddress.getByName(addressStr);+ if (seed.isProper() == null) ipLookupCache.put(seedIPAddress, new SoftReference(seed));+ if (seedIPAddress.equals(peerIP)) return seed;+ }+ } catch (UnknownHostException ex) {}+ }+ }++ if (lookupDisconnected) {+ // enumerate the cache and simultanous insert values+ Enumeration e = seedsDisconnected(true, false, null);++ while (e.hasMoreElements()) {+ try {+ seed = (yacySeed) e.nextElement();+ if (seed != null) {+ addressStr = seed.getAddress();+ if ((pos = addressStr.indexOf(":"))!= -1) {+ addressStr = addressStr.substring(0,pos);+ }+ seedIPAddress = InetAddress.getByName(addressStr);+ if (seed.isProper() == null) ipLookupCache.put(seedIPAddress, new SoftReference(seed));+ if (seedIPAddress.equals(peerIP)) return seed;+ }+ } catch (UnknownHostException ex) {}+ }+ }++ if (lookupPotential) {+ // enumerate the cache and simultanous insert values+ Enumeration e = seedsPotential(true, false, null);++ while (e.hasMoreElements()) {+ try {+ seed = (yacySeed) e.nextElement();+ if (seed != null) {+ addressStr = seed.getAddress();+ if ((pos = addressStr.indexOf(":"))!= -1) {+ addressStr = addressStr.substring(0,pos);+ }+ seedIPAddress = InetAddress.getByName(addressStr);+ if (seed.isProper() == null) ipLookupCache.put(seedIPAddress, new SoftReference(seed));+ if (seedIPAddress.equals(peerIP)) return seed;+ }+ } catch (UnknownHostException ex) {}+ }+ }++ try {+ // check local seed+ addressStr = mySeed.getAddress();+ if ((pos = addressStr.indexOf(":"))!= -1) {+ addressStr = addressStr.substring(0,pos);+ }+ seedIPAddress = InetAddress.getByName(addressStr);+ if (mySeed.isProper() == null) ipLookupCache.put(seedIPAddress, new SoftReference(mySeed));+ if (seedIPAddress.equals(peerIP)) return mySeed;+ // nothing found+ return null;+ } catch (UnknownHostException e2) {+ return null;+ }+ }+public ArrayList storeCache(File seedFile) throws IOException {return storeCache(seedFile, false);}