Skip to content

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

Security Hot-Fix: for transparent proxy.

reger8cbc1c970ae1
diff --git a/source/net/yacy/http/AbstractRemoteHandler.java b/source/net/yacy/http/AbstractRemoteHandler.java
index e660759bb..932571774 100644
--- a/source/net/yacy/http/AbstractRemoteHandler.java
+++ b/source/net/yacy/http/AbstractRemoteHandler.java
@@ -82,6 +82,9 @@ abstract public class AbstractRemoteHandler extends AbstractHandler implements H
HttpServletResponse response) throws IOException, ServletException {
String host = request.getHeader("Host");
if (host == null) return; // no proxy request, continue processing by handlers
+
+ if (!Switchboard.getSwitchboard().getConfigBool("isTransparentProxy", false)) return;
+
int hostSplitPos = host.indexOf(':');
String hostOnly = hostSplitPos < 0 ? host : host.substring(0, hostSplitPos);
@@ -91,7 +94,13 @@ abstract public class AbstractRemoteHandler extends AbstractHandler implements H
localVirtualHostNames.add(sb.peers.myIP()); // not available on init, add it now for quickcheck
return;
}
+
+ String remoteHost = request.getRemoteHost();
+ InetAddress remoteIP = Domains.dnsResolve(remoteHost);
+ if (!remoteIP.isAnyLocalAddress()) return;
+
handleRemote(target, baseRequest, request, response);
+
}
}