*) fix for commit 4212

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4217 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
low012 17 years ago
parent 3491531cea
commit 383dc815d2

@ -1,7 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!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"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<base href="http://#[host]#:#[port]#" /> <base href="http://#[extAddress]#" />
<title>YaCy: Error Message</title> <title>YaCy: Error Message</title>
#%env/templates/metas.template%# #%env/templates/metas.template%#
</head> </head>

@ -1138,22 +1138,22 @@ public final class httpd implements serverHandler {
try { try {
urlString = (new yacyURL((method.equals(httpHeader.METHOD_CONNECT)?"https":"http"), host, port, (args == null) ? path : path + "?" + args)).toString(); urlString = (new yacyURL((method.equals(httpHeader.METHOD_CONNECT)?"https":"http"), host, port, (args == null) ? path : path + "?" + args)).toString();
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
urlString = "invalid URL"; urlString = "invalid URL";
} }
// set rewrite values // set rewrite values
serverObjects tp = new serverObjects(); serverObjects tp = new serverObjects();
// tp.put("host", serverCore.publicIP().getHostAddress()); // tp.put("host", serverCore.publicIP().getHostAddress());
// tp.put("port", switchboard.getConfig("port", "8080")); // tp.put("port", switchboard.getConfig("port", "8080"));
String clientIP = conProp.getProperty(httpHeader.CONNECTION_PROP_CLIENTIP,"127.0.0.1"); String clientIP = conProp.getProperty(httpHeader.CONNECTION_PROP_CLIENTIP,"127.0.0.1");
// check if ip is local ip address // check if ip is local ip address
InetAddress hostAddress = serverDomains.dnsResolve(clientIP); InetAddress hostAddress = serverDomains.dnsResolve(clientIP);
if (hostAddress == null) { if (hostAddress == null) {
tp.put("host", serverDomains.myPublicLocalIP().getHostAddress()); 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()) { } else if (hostAddress.isSiteLocalAddress() || hostAddress.isLoopbackAddress()) {
tp.put("host", serverDomains.myPublicLocalIP().getHostAddress()); tp.put("host", serverDomains.myPublicLocalIP().getHostAddress());
tp.put("port", serverCore.getPortNr(switchboard.getConfig("port", "8080"))); 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)) tp.put("port", (serverCore.portForwardingEnabled && (serverCore.portForwarding != null))
? Integer.toString(serverCore.portForwarding.getPort()) ? Integer.toString(serverCore.portForwarding.getPort())
: Integer.toString(serverCore.getPortNr(switchboard.getConfig("port", "8080")))); : 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("peerName", yacyCore.seedDB.mySeed().getName());
tp.put("errorMessageType", errorcase); tp.put("errorMessageType", errorcase);
tp.put("httpStatus", Integer.toString(httpStatusCode) + " " + httpStatusText); tp.put("httpStatus", Integer.toString(httpStatusCode) + " " + httpStatusText);
tp.put("requestMethod", conProp.getProperty(httpHeader.CONNECTION_PROP_METHOD)); tp.put("requestMethod", conProp.getProperty(httpHeader.CONNECTION_PROP_METHOD));
tp.put("requestURL", urlString); tp.put("requestURL", urlString);
switch (errorcase) { switch (errorcase) {
case ERRORCASE_MESSAGE: case ERRORCASE_MESSAGE:
tp.put("errorMessageType_detailedErrorMsg", (detailedErrorMsgText == null) ? "" : detailedErrorMsgText.replaceAll("\n", "<br />")); tp.put("errorMessageType_detailedErrorMsg", (detailedErrorMsgText == null) ? "" : detailedErrorMsgText.replaceAll("\n", "<br />"));

Loading…
Cancel
Save