+ Post New Thread
Results 1 to 11 of 11
Wireless Networks Thread, Stupid proxy pac in Technical; Im having a strange issue whereby when a client connects to an internal resource, it is completely ignoring the "use ...
  1. #1
    Oops_my_bad's Avatar
    Join Date
    Jan 2007
    Location
    Man chest hair
    Posts
    1,738
    Thank Post
    438
    Thanked 53 Times in 50 Posts
    Rep Power
    31

    Angry Stupid proxy pac

    Im having a strange issue whereby when a client connects to an internal resource, it is completely ignoring the "use direct bit" and going via the proxy. I can tell this from running a wireshark capture. The issue is more prevalent recently as when the LEA internet connection goes, clients are unable to access internal services such as webmail or our vle (both hosted internally).

    Here is the content of my pac file:

    Code:
    {
        if (
            dnsDomainIs(host, "webmail.domain.internal") ||
            dnsDomainIs(host, "vle.domain.internal") ||
            dnsDomainIs(host, "xenapp.domain.internal") ||
            isInNet(host, "127.0.0.1", "255.255.255.255") ||
            isInNet(host, "172.31.1.1","255.255.255.255")
           ) 
            return "DIRECT";
        else
            return "PROXY xx.xx.xx.xx:8881";
    }
    Now, the proxy pac is being served up fine, and happens across both IE7 and Firefox. So perhaps it is just a logic issue?? But it looks fine to me! Anyone shed any light?

    **edit** to correct paste errors
    Last edited by Oops_my_bad; 20th March 2009 at 03:20 PM.

  2. #2

    teejay's Avatar
    Join Date
    Apr 2008
    Posts
    3,259
    Thank Post
    289
    Thanked 796 Times in 605 Posts
    Rep Power
    348
    On final isInNet line remove the ||

  3. Thanks to teejay from:

    Oops_my_bad (20th March 2009)

  4. #3
    k-strider's Avatar
    Join Date
    Oct 2006
    Location
    Gloucester
    Posts
    358
    Thank Post
    7
    Thanked 40 Times in 30 Posts
    Rep Power
    24
    should there be a || after the last logical test before the Return direct ?

  5. Thanks to k-strider from:

    Oops_my_bad (20th March 2009)

  6. #4


    tom_newton's Avatar
    Join Date
    Sep 2006
    Location
    Leeds
    Posts
    4,507
    Thank Post
    871
    Thanked 862 Times in 681 Posts
    Rep Power
    199
    The above answers are correct - in fact, if my memory of javascript's internal workings serves, you will only return "DIRECT" in cases where it is *not* any of those hosts.

  7. Thanks to tom_newton from:

    Oops_my_bad (20th March 2009)

  8. #5
    Oops_my_bad's Avatar
    Join Date
    Jan 2007
    Location
    Man chest hair
    Posts
    1,738
    Thank Post
    438
    Thanked 53 Times in 50 Posts
    Rep Power
    31
    Jeez, was that all it was then? I feel like a noob

    So my revised pac file should go something like:

    Code:
    {
        if (
            dnsDomainIs(host, "webmail.domain.internal") ||
            dnsDomainIs(host, "vle.domain.internal") ||
            dnsDomainIs(host, "xenapp.domain.internal") ||
            isInNet(host, "127.0.0.1", "255.255.255.255") ||
            isInNet(host, "172.31.1.1","255.255.255.255")
           ) 
            return "DIRECT";
        else
            return "PROXY xx.xx.xx.xx:8881";
    }
    Yas?
    Last edited by Oops_my_bad; 20th March 2009 at 03:21 PM.

  9. #6
    Oops_my_bad's Avatar
    Join Date
    Jan 2007
    Location
    Man chest hair
    Posts
    1,738
    Thank Post
    438
    Thanked 53 Times in 50 Posts
    Rep Power
    31
    Actually I've just checked our original pac and it hadnt pasted over to here properly, our pac is exactly as above with the OR operator omitted before the use direct

  10. #7
    contink's Avatar
    Join Date
    Jul 2006
    Location
    South Yorkshire
    Posts
    3,791
    Thank Post
    303
    Thanked 327 Times in 233 Posts
    Rep Power
    119
    Pardon me if this sounds a bit obvious but there seems to be some brackets missing.
    Code:
    {
        if (
            dnsDomainIs(host, "webmail.domain.internal") ||
            dnsDomainIs(host, "vle.domain.internal") ||
            dnsDomainIs(host, "xenapp.domain.internal") ||
            isInNet(host, "127.0.0.1", "255.255.255.255") ||
            isInNet(host, "172.31.1.1","255.255.255.255")
           ) {
            return "DIRECT";
        }
        else {
            return "PROXY xx.xx.xx.xx:8881";
        }
    }

  11. Thanks to contink from:

    Oops_my_bad (20th March 2009)

  12. #8
    Oops_my_bad's Avatar
    Join Date
    Jan 2007
    Location
    Man chest hair
    Posts
    1,738
    Thank Post
    438
    Thanked 53 Times in 50 Posts
    Rep Power
    31
    Thanks!

    Here's what we have so far.. it is working but I wont really know unless the connection goes down!

    Code:
    function FindProxyForURL(url, host)
    {
        if (
    	dnsDomainIs(host, "webmail.domain.internal") ||
    	dnsDomainIs(host, "vle.domain.internal") ||
    	dnsDomainIs(host, "xenapp.domain.internal") ||
    	isInNet(host, "127.0.0.1", "255.255.255.255") ||
                 isInNet(host, "172.31.1.1","255.255.255.255")
           ) 
    	{
    	      return "DIRECT";
    	}
        else
    	{
            	      return "PROXY xx.xx.xx.xx:8881";
    	}
    }
    Apologies for the poor formatting of code on here.. but looks good yes?
    Last edited by Oops_my_bad; 20th March 2009 at 04:05 PM.

  13. #9

    teejay's Avatar
    Join Date
    Apr 2008
    Posts
    3,259
    Thank Post
    289
    Thanked 796 Times in 605 Posts
    Rep Power
    348
    Looks fine to me! The mis-alligned brackets are so naughty

  14. #10
    AlexB's Avatar
    Join Date
    Jul 2006
    Location
    Warwickshire
    Posts
    417
    Thank Post
    40
    Thanked 51 Times in 43 Posts
    Rep Power
    26
    isInNet(host, "172.31.1.1","255.255.255.255")


    looks to be a problem to me, should this not be 255.255.255.0 or whatever your subnet mask is?

  15. #11
    AlexB's Avatar
    Join Date
    Jul 2006
    Location
    Warwickshire
    Posts
    417
    Thank Post
    40
    Thanked 51 Times in 43 Posts
    Rep Power
    26
    This is what I use, it is a bit of a mess, but does what I need...

    I find having the proxy defs at the top helps if I need to change them.

    And yes I know a lot of these could be grouped together, but I prefer the readability of separate checks.

    Code:
    function FindProxyForURL(url, host)
    {
    	// Proxy definitions
    	var proxy_main = "PROXY xxxx:80; ";
    	var proxy_SVEN_SECURE = "PROXY xxxxx:8080; ";
    	var proxy_fallback = "PROXY xxxx:80; ";
    	var proxy_no = "DIRECT";
    
    	// Proxy if on Admin LAN - no proxy
    	if (isInNet(myIpAddress(), "xxxxx", "255.255.255.0"))
    	{
    		return proxy_no;
    	}
    	// else if looking at  proxy (probably blocked page) - no proxy
    	else if (shExpMatch(url, "http://xxxx*") ||
    			 shExpMatch(url, "http://xxxx*")
    			)
    	{
    		return proxy_no;
    	}
    	// else if looking at a machine on the curric network - no proxy
    	else if (isInNet(host, "xxxx", "255.255.248.0"))
    	{
    		return proxy_no;
    	}
    	// else if looking at a machine on the admin network - no proxy
    	else if (isInNet(host, "xxxx", "255.255.255.0"))
    	{
    		return proxy_no;
    	}
    	// else if looking at a machine on the SVEN network - no proxy
    	else if (isInNet(host, "xxxx", "255.255.255.0"))
    	{
    		return proxy_no;
    	}
    	// else if certain sites - force proxy
    	else if (//shExpMatch(url, "*xxxx*") ||
    			 0
    			)
    	{
    		return proxy_main + proxy_fallback;
    	}
    	// else if certain sites - no proxy
    	else if (shExpMatch(url, "*.xxx*") ||
    			 shExpMatch(url, "*.xxx*") ||
    			 shExpMatch(url, "*xxx*") ||
    			 shExpMatch(url, "*xxx*") ||
    			 0
    			)
    	{
    		return proxy_no;
    	}
    	// else if a secure site - alternative proxy for secure sites
    	else if (shExpMatch(url, "https://*"))
    	{
    		return proxy_SVEN_SECURE;
    	}
    	// else use normal proxy and fallback proxy as backup
    	else
    	{
    		return proxy_main + proxy_fallback;
    	}
    }



SHARE:
+ Post New Thread

Similar Threads

  1. .pac files
    By jamiet147 in forum Coding
    Replies: 3
    Last Post: 26th November 2008, 09:51 AM
  2. [Video] Pac Man the Movie
    By Dos_Box in forum Jokes/Interweb Things
    Replies: 0
    Last Post: 9th September 2008, 03:31 PM
  3. 2 pac and 50 cent!!
    By bishopsgarthstockton in forum General Chat
    Replies: 20
    Last Post: 17th July 2007, 12:32 AM
  4. Creating a PAC file
    By u8dmtm in forum Coding
    Replies: 4
    Last Post: 2nd March 2006, 04:49 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •