From b701cab7d8245039286b905e7011b396571edbe3 Mon Sep 17 00:00:00 2001 From: Banana Date: Wed, 11 Nov 2015 11:13:29 +0100 Subject: [PATCH] proxy.pac file example. Readme update --- README | 2 ++ proxy/README | 1 + proxy/proxy.pac | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 proxy/README create mode 100644 proxy/proxy.pac diff --git a/README b/README index 12ece98..6bf93de 100644 --- a/README +++ b/README @@ -1 +1,3 @@ A bag full of things + +Use the file browse function to see what is inside. diff --git a/proxy/README b/proxy/README new file mode 100644 index 0000000..635c338 --- /dev/null +++ b/proxy/README @@ -0,0 +1 @@ +This is an example proxy.pac file which can be used as the proxy configuration by URL diff --git a/proxy/proxy.pac b/proxy/proxy.pac new file mode 100644 index 0000000..1f4310f --- /dev/null +++ b/proxy/proxy.pac @@ -0,0 +1,40 @@ +// file syntax is javascript + +// this is the return value if we do not use the proxy +var direct = "DIRECT"; +// this is the return value if we use the proxy. +// this returns multiple proxyies +var proxy = "PROXY 10.0.1.12:80; PROXY 10.0.1.10:80; PROXY 10.0.1.11:80"; + +function FindProxyForURL(url, host) { + + var lhost = host.toLowerCase(); + var resolved_ip = dnsResolve(host); + host = lhost; + + var lurl = url.toLowerCase(); + url = lurl; + + if(isPlainHostName(host)) { + return direct; + } + + // local networks do not use a proxy + if( + (isInNet(resolved_ip, "10.0.0.0", "255.0.0.0")) || + (isInNet(resolved_ip, "192.168.0.0", "255.255.0.0")) || + (isInNet(resolved_ip, "127.0.0.1", "255.255.255.255")) + ) { + return direct; + } + + // the local network uses some special tlds + if( + (host == "some.special.tld") || + (host == "some.special.interne.tld") + ) { + return direct; + } + + return proxy; +} -- 2.39.5