Skip to content

Instantly share code, notes, and snippets.

@wen-long
Created December 8, 2013 15:27
Show Gist options
  • Save wen-long/7859005 to your computer and use it in GitHub Desktop.
Save wen-long/7859005 to your computer and use it in GitHub Desktop.
function FindProxyForURL(url, host) {
debugPAC ="";
debugPAC +="IP: " + myIpAddress();
debugPAC +=", Hostname: " + host;
if (isResolvable(host)) {resolvableHost = "True"} else {resolvableHost = "False"};
debugPAC +=", Host Resolvable: " + resolvableHost;
debugPAC +=", Hostname IP: " + dnsResolve(host);
if (isPlainHostName(host)) {plainHost = "True"} else {plainHost = "False"};
debugPAC +=", Plain Hostname: " + plainHost;
debugPAC +=", Domain Levels: " + dnsDomainLevels(host);
debugPAC +=", URL: " + url;
debugPAC = "start" + debugPAC;
// Protocol can only be determined by reading the entire URL.
if (url.substring(0,5)=="http:") {protocol="HTTP";} else
if (url.substring(0,6)=="https:") {protocol="HTTPS";} else
if (url.substring(0,4)=="ftp:") {protocol="FTP";}
else {protocol="Unknown";}
debugPAC +="Protocol: " + protocol;
// Reduce volume of alerts to a useable level, e.g. only alert on static text pages.
if (!shExpMatch(url,"*.(js|xml|ico|gif|png|jpg|jpeg|css|swf)*")) {alert(debugPAC);}
return "DIRECT";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment