From dbda6e1e85cfead1f885211af2b8e7e14c243000 Mon Sep 17 00:00:00 2001
From: orbiter
Date: Thu, 16 Jun 2005 11:40:36 +0000
Subject: [PATCH] corrections to port forwarding
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@286 6c8d7289-2bf4-0310-a012-ef5d649a1542
---
htroot/Settings_p.html | 15 ++++++++++-----
htroot/yacy/hello.java | 27 +++++++++++++--------------
source/de/anomic/yacy/yacyClient.java | 2 ++
3 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/htroot/Settings_p.html b/htroot/Settings_p.html
index 51ced2d05..7305d22a7 100644
--- a/htroot/Settings_p.html
+++ b/htroot/Settings_p.html
@@ -60,18 +60,23 @@ delete the file 'DATA/SETTINGS/httpProxy.conf' in the YaCy application root fold
-Proxy Access Restrictions
You can restrict the access to this proxy using a two-stage security barrier:
+
Server Access Restrictions
You can restrict the access to this proxy/server using a two-stage security barrier:
- define an access domain with a list of granted client IP-numbers or with wildcards
- define an user account with an user:password - pair
diff --git a/htroot/yacy/hello.java b/htroot/yacy/hello.java
index f08718de5..c69a58af6 100644
--- a/htroot/yacy/hello.java
+++ b/htroot/yacy/hello.java
@@ -82,23 +82,22 @@ public class hello {
//System.out.println("YACYHELLO: YOUR IP=" + yourip);
prop.put("yourip", yourip);
+ // now let's check if the calling peer can be reached and answers
int urls = -1;
- /*
- * Needed for port forwarding support ....
- *
- * If the peer has reported an other address as it has connected
- * to us, we try to use the reported address first ...
- *
- * @see serverCore#portForwardingEnabled
- */
- if ((!remoteSeed.get("IP","").equalsIgnoreCase(yourip)) &&
- ((urls = yacyClient.queryUrlCount(remoteSeed)) == -1)) {
- remoteSeed.put("IP", yourip);
+ String reportedip = remoteSeed.get("IP", "");
+ remoteSeed.put("IP", yourip);
+ urls = yacyClient.queryUrlCount(remoteSeed);
+
+ // if this was not successful, we try to use the reported ip
+ if ((urls < 0) &&
+ (!remoteSeed.get("IP","").equalsIgnoreCase(yourip))) {
+ // the other peer does not respond under the ip it reported
+ // we try again using the ip we got from the http header
+ remoteSeed.put("IP", reportedip);
urls = yacyClient.queryUrlCount(remoteSeed);
}
- // now let's check if the calling peer can be reached and answers
- int port = Integer.parseInt(remoteSeed.get("Port", "8080"));
+ // assign status
if (urls >= 0) {
if (remoteSeed.get("PeerType", "senior") == null) {
prop.put("yourtype", "senior");
@@ -116,7 +115,7 @@ public class hello {
remoteSeed.put("LastSeen", yacyCore.universalDateShortString());
yacyCore.peerActions.juniorConnects++; // update statistics
remoteSeed.put("PeerType", "junior");
- yacyCore.log.logInfo("hello: responded remote junior peer '" + remoteSeed.getName() + "' from " + yourip + ":" + port);
+ yacyCore.log.logInfo("hello: responded remote junior peer '" + remoteSeed.getName() + "' from " + yourip + ":" + remoteSeed.get("Port", "8080"));
// no connection here, instead store junior in connection cache
if ((remoteSeed.hash != null) && (remoteSeed.isProper())) yacyCore.peerActions.peerPing(remoteSeed);
}
diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java
index c10cf24b8..899a6d1d7 100644
--- a/source/de/anomic/yacy/yacyClient.java
+++ b/source/de/anomic/yacy/yacyClient.java
@@ -134,6 +134,8 @@ public class yacyClient {
// set my own seed according to new information
yacySeed mySeedBkp = (yacySeed) yacyCore.seedDB.mySeed.clone();
+
+ // we overwrite our own IP number only, if we do not portForwarding
if (!serverCore.portForwardingEnabled) {
yacyCore.seedDB.mySeed.put("IP", (String) result.get("yourip"));
}