From 61d9e131b44cb3973d0a365d015f6292ceb360aa Mon Sep 17 00:00:00 2001 From: lotus Date: Tue, 2 Jun 2009 12:18:29 +0000 Subject: [PATCH] better/new proxy auto config git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6010 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/autoconfig.java | 1 + htroot/autoconfig.pac | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/htroot/autoconfig.java b/htroot/autoconfig.java index 86a30a406..bfdf7a7e1 100644 --- a/htroot/autoconfig.java +++ b/htroot/autoconfig.java @@ -30,6 +30,7 @@ import de.anomic.server.serverSwitch; public class autoconfig { + // http://web.archive.org/web/20071011034022/http://wp.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html /** * Generates a proxy-autoconfig-file (application/x-ns-proxy-autoconfig) * See: Proxy Auto-Config File Format diff --git a/htroot/autoconfig.pac b/htroot/autoconfig.pac index adb138b3d..5ed509536 100644 --- a/htroot/autoconfig.pac +++ b/htroot/autoconfig.pac @@ -1,10 +1,18 @@ function FindProxyForURL(url,host) { - if ((isPlainHostName(host))|| - (host=="127.0.0.1")) { - return "DIRECT"; - } else if (url.substring(0, 4).toLowerCase() == "ftp:") { + // http only + if (!(url.substring(0, 5).toLowerCase() == "http:")) { return "DIRECT"; - } else { - return "PROXY #[host]#:#[port]#, DIRECT"; - } + } + + // no local adresses + ip = dnsResolve(host); + if ( isInNet(ip, "127.0.0.0", "255.0.0.0") + || isInNet(ip, "192.168.0.0", "255.255.0.0") + || isInNet(ip, "10.0.0.0", "255.0.0.0") + || isInNet(ip, "172.16.0.0", "255.240.0.0") ) { + return "DIRECT"; + } + + // then + return "PROXY #[host]#:#[port]#, DIRECT"; } \ No newline at end of file