Skip to content

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

*) Port Forwarding Feature does not detect broken connection properly. Therefor a test-request was added to the isConnected function to detect broken connections and to keep open connections alive

thelia812fb86cc76
diff --git a/htroot/yacy/hello.java b/htroot/yacy/hello.java
index b83004001..0678674f1 100644
--- a/htroot/yacy/hello.java
+++ b/htroot/yacy/hello.java
@@ -102,14 +102,18 @@ public class hello {
boolean isLocalIP = false;
if (serverCore.portForwardingEnabled) {
try {
- InetAddress clientAddress = InetAddress.getByName(clientip);
- InetAddress[] localAddress = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());
- for (int i=0; i<localAddress.length; i++) {
- if (localAddress[i].equals(clientAddress)) {
- isLocalIP = true;
- break;
- }
- }
+ InetAddress clientAddress = InetAddress.getByName(clientip);
+ if (clientAddress.isAnyLocalAddress() || clientAddress.isLoopbackAddress()) {
+ isLocalIP = true;
+ } else {
+ InetAddress[] localAddress = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());
+ for (int i=0; i<localAddress.length; i++) {
+ if (localAddress[i].equals(clientAddress)) {
+ isLocalIP = true;
+ break;
+ }
+ }
+ }
} catch (Exception e) {}
}
diff --git a/source/de/anomic/server/serverPortForwardingSch.java b/source/de/anomic/server/serverPortForwardingSch.java
index 6aba86044..877577f69 100644
--- a/source/de/anomic/server/serverPortForwardingSch.java
+++ b/source/de/anomic/server/serverPortForwardingSch.java
@@ -8,6 +8,8 @@ import com.jcraft.jsch.UIKeyboardInteractive;
import com.jcraft.jsch.UserInfo;
import de.anomic.server.logging.serverLog;
+import de.anomic.yacy.yacyClient;
+import de.anomic.yacy.yacyCore;
public class serverPortForwardingSch implements serverPortForwarding{
@@ -182,7 +184,9 @@ public class serverPortForwardingSch implements serverPortForwarding{
public synchronized boolean isConnected() {
if (session == null) return false;
- return session.isConnected();
+ if (!session.isConnected()) return false;
+ int urls = yacyClient.queryUrlCount(yacyCore.seedDB.mySeed);
+ return !(urls < 0);
}
class MyUserInfo
diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java
index bff7f6771..bb4f7233c 100644
--- a/source/de/anomic/yacy/yacyClient.java
+++ b/source/de/anomic/yacy/yacyClient.java
@@ -185,6 +185,8 @@ public class yacyClient {
}
}
}
+ } else {
+ yacyCore.log.logDebug("yacyClient.publishMySeed: Peer '" + ((otherPeer==null)?"unknown":otherPeer.getName()) + "' reported us as " + mytype + ".");
}
yacyCore.seedDB.mySeed.put(yacySeed.PEERTYPE, mytype);
}