function FindProxyForURL(url, host) { /* Normalize the URL for pattern matching */ url = url.toLowerCase(); host = host.toLowerCase(); var proxyHostnames = ["proxy-rc-cr.menlosecurity.com"]; var numProxiesAvailable = 1; var numFailoverProxies = 0; var httpPort = 3129; var buildProxyString = function(proxyIndices) { var finalProxies = []; for (var i = 0; i < proxyIndices.length; i++) { var currProxyString = 'PROXY ' + proxyHostnames[proxyIndices[i]] + ':' + httpPort; finalProxies.push(currProxyString); } return finalProxies.join('; ') + '; DIRECT'; }; var hashCode = function(inputString) { var hash = 0, i, chr, len; len = inputString.length; if (len === 0) return hash; for (i = 0; i < len; i++) { chr = inputString.charCodeAt(i); hash = ((hash << 5) - hash) + chr; hash |= 0; } if (hash < 0) {return -hash;} else {return hash;} }; var getProxyString = function() { var hash = hashCode(myIpAddress()); var proxiesToUse = []; var proxiesUsed = {}; while (proxiesToUse.length < numFailoverProxies + 1) { var key = hash % numProxiesAvailable; hash++; hash = hashCode(hash.toString()); if (proxiesUsed[key]) {continue;} proxiesToUse.push(key); proxiesUsed[key] = true; } return buildProxyString(proxiesToUse); } /* Don't proxy local hostnames */ if (isPlainHostName(host)) { return 'DIRECT'; } /* All other menlosecurity traffic goes through proxy */ if ( dnsDomainIs(host, "menlosecurity.com") ) { return getProxyString(); } /* List all default domains */ if ( shExpMatch(host, "google.??") || shExpMatch(host, "google.com") || shExpMatch(host, "google.com.??") || shExpMatch(host, "google.co.??") || shExpMatch(host, "*.google.??") || shExpMatch(host, "*.google.com") || shExpMatch(host, "*.google.com.??") || shExpMatch(host, "*.google.co.??")) { return 'DIRECT'; } if ( dnsDomainIs(host, ".windowsupdate.microsoft.com") || dnsDomainIs(host, ".update.microsoft.com") || dnsDomainIs(host, ".download.microsoft.com") || dnsDomainIs(host, ".ntservicepack.microsoft.com") || dnsDomainIs(host, ".cdm.microsoft.com") || dnsDomainIs(host, ".wustat.windows.com") || dnsDomainIs(host, "store-images.s-microsoft.com") || dnsDomainIs(host, "musicimage.xboxlive.com") || dnsDomainIs(host, "store-images.microsoft.com") || dnsDomainIs(host, "mediadiscovery.microsoft.com") || dnsDomainIs(host, "media-assetcatalog.microsoft.com") || dnsDomainIs(host, "mp.microsoft.com")) { return 'DIRECT'; } if ( dnsDomainIs(host, ".itunes.apple.com") || dnsDomainIs(host, ".swcdn.apple.com") || dnsDomainIs(host, ".swdownload.apple.com") || dnsDomainIs(host, ".swquery.apple.com") || dnsDomainIs(host, ".swscan.apple.com") || dnsDomainIs(host, "xp.apple.com") || dnsDomainIs(host, "gsa.apple.com")) { return 'DIRECT'; } if ( dnsDomainIs(host, ".webex.com") || dnsDomainIs(host, ".ciscowebex.com") || dnsDomainIs(host, "gotomeeting.com") || dnsDomainIs(host, "gotowebinar.com") || dnsDomainIs(host, "gototraining.com") || dnsDomainIs(host, "gotomypc.com") || dnsDomainIs(host, "gotoassist.com") || dnsDomainIs(host, "skype.com") || dnsDomainIs(host, "freeconferencecall.com") || dnsDomainIs(host, "join.me") || dnsDomainIs(host, "anymeeting.com") || dnsDomainIs(host, "clickwebinar.com") || dnsDomainIs(host, "readytalk.com") || dnsDomainIs(host, "omnovia.com") || dnsDomainIs(host, "on24.com")) { return 'DIRECT'; } if ( dnsDomainIs(host, ".dropbox.com")) { return 'DIRECT'; } if ( dnsDomainIs(host, ".netflix.com") || dnsDomainIs(host, ".netflix.net") || dnsDomainIs(host, ".nflximg.com") || dnsDomainIs(host, ".nflximg.net") || dnsDomainIs(host, ".nflxvideo.net") || dnsDomainIs(host, ".nflxext.com") || dnsDomainIs(host, ".nflximg.com.edgesuite.net") || dnsDomainIs(host, ".vo.llnwd.net") || isInNet(host, "216.21.170.128","255.255.255.240") || isInNet(host, "192.173.64.0","255.255.192.0") || isInNet(host, "198.45.48.0","255.255.240.0") || isInNet(host, "216.21.170.96","255.255.255.240") || isInNet(host, "108.175.32.0","255.255.240.0") || isInNet(host, "198.38.96.0","255.255.224.0") || isInNet(host, "192.119.16.224","255.255.255.240") || isInNet(host, "216.21.170.144","255.255.255.240") || isInNet(host, "23.246.0.0","255.255.192.0") || isInNet(host, "37.77.184.0","255.255.255.0") || isInNet(host, "37.77.185.0","255.255.255.0") || isInNet(host, "37.77.188.0","255.255.255.0") || isInNet(host, "37.77.189.0","255.255.255.0") || isInNet(host, "37.77.190.0","255.255.255.0") || isInNet(host, "37.77.191.0","255.255.255.0") || isInNet(host, "69.53.229.0","255.255.255.0") || isInNet(host, "185.2.220.0","255.255.255.0") || isInNet(host, "185.2.221.0","255.255.255.0") || isInNet(host, "185.2.222.0","255.255.255.0") || isInNet(host, "185.2.223.0","255.255.255.0") || isInNet(host, "185.9.188.0","255.255.255.0") || isInNet(host, "192.173.80.0","255.255.192.0") || isInNet(host, "192.173.96.0","255.255.192.0")) { return 'DIRECT'; } if ( dnsDomainIs(host, "lululemon.com") || dnsDomainIs(host, "ticketmaster.com") || dnsDomainIs(host, "ticketmaster.co.uk") || dnsDomainIs(host, "wayfair.com")) { return 'DIRECT'; } if (dnsDomainIs(host, "menlosecurity.com")) { return 'DIRECT'; } /* Don't check IPv6 addresses */ if (isResolvable(host)) { var hostIP = dnsResolve(host); if (!shExpMatch(hostIP, "*:*")) { /* Don't proxy non-routable addresses (RFC 3330) */ if (isInNet(hostIP, '0.0.0.0', '255.0.0.0') || isInNet(hostIP, '10.0.0.0', '255.0.0.0') || isInNet(hostIP, '127.0.0.0', '255.0.0.0') || isInNet(hostIP, '169.254.0.0', '255.255.0.0') || isInNet(hostIP, '172.16.0.0', '255.240.0.0') || isInNet(hostIP, '192.0.2.0', '255.255.255.0') || isInNet(hostIP, '192.88.99.0', '255.255.255.0') || isInNet(hostIP, '192.168.0.0', '255.255.0.0') || isInNet(hostIP, '198.18.0.0', '255.254.0.0') || isInNet(hostIP, '224.0.0.0', '240.0.0.0') || isInNet(hostIP, '240.0.0.0', '240.0.0.0')) { return 'DIRECT'; } } } /* Don't send Encrypted traffic to Proxy */ if ( url.substring(0, 6) == 'https:' ) { return 'DIRECT'; } if ( url.substring(0, 5) == 'http:' ) { return getProxyString(); } return 'DIRECT'; }