Skip to content

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

*) fix for commit 4212

low012383dc815d29f
diff --git a/htroot/proxymsg/error.html b/htroot/proxymsg/error.html
index 60b4930c2..3dfee954b 100644
--- a/htroot/proxymsg/error.html
+++ b/htroot/proxymsg/error.html
@@ -1,7 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <base href="http://#[host]#:#[port]#" />
+ <base href="http://#[extAddress]#" />
<title>YaCy: Error Message</title>
#%env/templates/metas.template%#
</head>
diff --git a/source/de/anomic/http/httpd.java b/source/de/anomic/http/httpd.java
index 855e401f7..5d828851b 100644
--- a/source/de/anomic/http/httpd.java
+++ b/source/de/anomic/http/httpd.java
@@ -1138,22 +1138,22 @@ public final class httpd implements serverHandler {
try {
urlString = (new yacyURL((method.equals(httpHeader.METHOD_CONNECT)?"https":"http"), host, port, (args == null) ? path : path + "?" + args)).toString();
} catch (MalformedURLException e) {
- urlString = "invalid URL";
- }
-
+ urlString = "invalid URL";
+ }
+
// set rewrite values
serverObjects tp = new serverObjects();
-
+
// tp.put("host", serverCore.publicIP().getHostAddress());
// tp.put("port", switchboard.getConfig("port", "8080"));
-
+
String clientIP = conProp.getProperty(httpHeader.CONNECTION_PROP_CLIENTIP,"127.0.0.1");
-
+
// check if ip is local ip address
InetAddress hostAddress = serverDomains.dnsResolve(clientIP);
if (hostAddress == null) {
tp.put("host", serverDomains.myPublicLocalIP().getHostAddress());
- tp.put("port", serverCore.getPortNr(switchboard.getConfig("port", "8080")));
+ tp.put("port", serverCore.getPortNr(switchboard.getConfig("port", "8080")));
} else if (hostAddress.isSiteLocalAddress() || hostAddress.isLoopbackAddress()) {
tp.put("host", serverDomains.myPublicLocalIP().getHostAddress());
tp.put("port", serverCore.getPortNr(switchboard.getConfig("port", "8080")));
@@ -1162,14 +1162,23 @@ public final class httpd implements serverHandler {
tp.put("port", (serverCore.portForwardingEnabled && (serverCore.portForwarding != null))
? Integer.toString(serverCore.portForwarding.getPort())
: Integer.toString(serverCore.getPortNr(switchboard.getConfig("port", "8080"))));
- }
+ }
+
+ // if peer has public address it will be used
+ if (yacyCore.seedDB.mySeed().getPublicAddress() != null) {
+ tp.put("extAddress", yacyCore.seedDB.mySeed().getPublicAddress());
+ }
+ // otherwise the local ip address will be used
+ else {
+ tp.put("extAddress", tp.get("host", "127.0.0.1") + ":" + tp.get("port", "8080"));
+ }
tp.put("peerName", yacyCore.seedDB.mySeed().getName());
- tp.put("errorMessageType", errorcase);
+ tp.put("errorMessageType", errorcase);
tp.put("httpStatus", Integer.toString(httpStatusCode) + " " + httpStatusText);
tp.put("requestMethod", conProp.getProperty(httpHeader.CONNECTION_PROP_METHOD));
tp.put("requestURL", urlString);
-
+
switch (errorcase) {
case ERRORCASE_MESSAGE:
tp.put("errorMessageType_detailedErrorMsg", (detailedErrorMsgText == null) ? "" : detailedErrorMsgText.replaceAll("\n", "<br />"));