Post Reply 
block all sites except preselected with pac file.
Feb. 06, 2006, 08:47 PM
Post: #2
 
Hi Dj FM.AM

If I understand correctly, you are not using proxo and you are trying to setup a pacfile to allow access to websites that have been "whitelisted" in the pacfile while blocking all other sites.

The pacfile from http://www.schooner.com/~loverso/no-ads/ is essentially a blocking file. Basically, it allows everything that is not listed for blocking. While there is a lot of good info on that site, you would probably be better off creating your own pacfile instead of trying to use his.

Something like this should do the trick:

Code:
// My "Automatic proxy configuration URL"
// file:///e:/Apps/Proxomitron/ProxN45/html/z12_htm/z12_b1.pac


// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//
// For info on the Proxy Client Autoconfig File Format, see
// http://wp.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html
//
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//
// Define connection string variables
//
   var strBlackHole = "PROXY 127.0.0.1:8082";
   var strProxy = "PROXY 127.0.0.1:8080";
   var strDirect = "DIRECT";

//
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//
// Main function, this function must be defined, do not change its name
//

   function FindProxyForURL(url, host){
    
     if (CheckWhiteList(host,url))return strDirect;
     return strBlackHole;

   }

//
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//
// Whitelist
   function CheckWhiteList(h,u){

     // write alert to Firefox's javascript console
     // alert("url= " + u + " host= "+h);
    
     if(0
       || h.search(/(^|\.)microsoft\.com$/i)!=-1
       || h.search(/(^|\.)w3\.org$/i)!=-1
       || h.search(/^www\.wilderssecurity\.com$/i)!=-1
      )return 1;
    
     return 0;
   }

//
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

The CheckWhiteList function uses the string search method with regular expressions as an alternative to shExpMatch(str, shexp) which is limited to shell expressions, not regular expressions. Also if you need to check the whole url, you can use u.search instead of h.search.

Of course you can still use the special pacfile javascript functions that are described in the "Proxy Client Autoconfig File Format" in your whitelist.

HTH
Mike
Add Thank You Quote this message in a reply
Post Reply 


Messages In This Thread
block all sites except preselected with pac file. - Dj FM.AM - Jan. 18, 2006, 02:21 AM
[] - z12 - Feb. 06, 2006 08:47 PM

Forum Jump: