*) Extending proxy autoconfig to avoid problems with multiple local network cards

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@816 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 19 years ago
parent 595e0c7e56
commit 1d1b8f699e

@ -44,29 +44,39 @@
//if the shell's current path is HTROOT //if the shell's current path is HTROOT
import de.anomic.http.httpHeader; import de.anomic.http.httpHeader;
import de.anomic.server.serverCore; import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects; import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch; import de.anomic.server.serverSwitch;
public class autoconfig { public class autoconfig {
/** /**
* Generates a proxy-autoconfig-file (application/x-ns-proxy-autoconfig) * Generates a proxy-autoconfig-file (application/x-ns-proxy-autoconfig)
* See: <a href="http://wp.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html">Proxy Auto-Config File Format</a> * See: <a href="http://wp.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html">Proxy Auto-Config File Format</a>
* @param header * @param header
* @param post * @param post
* @param env * @param env
* @return * @return
*/ */
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) { public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
serverObjects prop = new serverObjects(); serverObjects prop = new serverObjects();
plasmaSwitchboard sb = (plasmaSwitchboard)env;
prop.put("host", serverCore.publicLocalIP().getHostAddress()); // getting the http host header
prop.put("port", env.getConfig("port", "8080")); String hostSocket = (String) header.get(httpHeader.CONNECTION_PROP_HOST);
// return rewrite properties String host = hostSocket;
return prop; int port = 80, pos = hostSocket.indexOf(":");
} if (pos != -1) {
port = Integer.parseInt(hostSocket.substring(pos + 1));
host = hostSocket.substring(0, pos);
}
prop.put("host", host);
prop.put("port", Integer.toString(port));
return prop;
}
} }

@ -1,14 +1,10 @@
function FindProxyForURL(url,host) { function FindProxyForURL(url,host) {
if ((isPlainHostName(host))|| if ((isPlainHostName(host))||
(host=="127.0.0.1")) (host=="127.0.0.1")) {
{
return "DIRECT"; return "DIRECT";
} else if (url.substring(0, 4).toLowerCase() == "ftp:") {
} return "DIRECT";
else if (url.substring(0, 4) == "ftp:") { } else {
return "DIRECT";
}
else {
return "PROXY #[host]#:#[port]#, DIRECT"; return "PROXY #[host]#:#[port]#, DIRECT";
} }
} }
Loading…
Cancel
Save