Jump to content

Recommended Posts

Posted

Hi all! :)

 

our internet is filtered externally and we are given a list of proxies to use such as...

 

proxy.server.com:6671 - for educational sites (basicaly blocks myspace, youtube)

proxy.server.com:6672 - for most web sites (blocks google images and inappropriate content)

proxy.server.com:6673 - very strict filtering for images but let you on to google images and yahoo images mainly

proxy.server.com:6674 - library filter (lets you on wiki and thats about it)

 

and i've been doing some experimenting with .pac files and trying to get different web sites to use different proxies but so far i've been unsuccessful.

 

Just wondering if anyone has tried something like this before or has any advice?

 

heres the .pac file i've been using

 

 

function FindProxyForURL(url, host)
{
if (isPlainHostName(url, host))
return "DIRECT";
else if (shExpMatch(url, "*.facebook.com/*")) return "PROXY proxy.server.com:6672";
else if (shExpMatch(url, "*.myspace.com/*")) return "PROXY proxy.server.com:6672";
else if (shExpMatch(url, "*.google.co.uk/*")) return "PROXY proxy.server.com:6673";
else if (shExpMatch(url, "*.google.com/*")) return "PROXY proxy.server.com:6673";
else

return "PROXY proxy.server.com:6671";
}

 

With this pac code whatever the first site/proxy is it will use that one.

 

Thanks in advance!

Jamie

Posted

Ok, first test for the most specific thing, so test for your urls first, then your generic 'direct' test, then an else.

 

Also do your shExpMatch on host, not url, so that you need less wildcards. I think that's why it is returning too soon, try shExpMatch(host, '*facebook.com').

 

(if this doesn't make much sense, that's because it's tomorrow already...)

Posted

OK... first you don't need any elseifs - i hate em anyway, messy construct. "return" is going to halt execution on match. We're going to explicitly brace our statements as well, for the sake of readablity. Finally, we'll check against host, not url where host is all we need.

 

soo...

 

var proxy1 = proxy.server.com:6672;

var proxy2 = proxy.server.com:6673;

 

var defaultproxy = proxy2;

 

function FindProxyForURL(url, host)

{

if (isPlainHostName(url, host))

{

return "DIRECT";

}

if (shExpMatch(host,"*facebook.com"))

{

return proxy1;

}

if (shExpMatch(host,"*google*))

{

return proxy2;

}

return defaultproxy;

}

 

If that works (problem may lie with 2 ports on one proxy... should work tho) would move on to perhaps use regex matching rather than shexp, so you can match (facebook|fbcdn|..)

 

This does seem a dangerous way to work, though, given that lots of sites have more than one domain.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...