2012年4月6日金曜日

PAC Functions Explained

isPlainHostName()

This function will return true if the hostname contains no dots, e.g. http://intranet
Useful when applying exceptions for internal websites, e.g. may not require resolution of a hostname to IP address to determine if local.

Example:

if (isPlainHostName(host)) return "DIRECT"; 


dnsDomainIs()

Evaluates hostnames and returns true if hostnames match. Used mainly to match and exception individual hostnames.

Example:

if (dnsDomainIs(host, ".google.com")) return "DIRECT"; 


localHostOrDomainIs()

Evaluates hostname and only returns true if exact hostname match is found.

Example:

if (localHostOrDomainIs(host, "www.google.com")) return "DIRECT"; 


isResolvable()

Attempts to resolve a hostname to an IP address and returns true if successful. WARNING - This may cause a browser to temporarily hang if a domain isn't resolvable.

Example:

if (isResolvable(host)) return "PROXY proxy1.example.com:8080"; 


isInNet()

This function evaluates the IP address of a hostname, and if within a specified subnet returns true. If a hostname is passed the function will resolve the hostname to an IP address.

Example:

if (isInNet(host, "172.16.0.0", "255.240.0.0")) return "DIRECT"; 


dnsResolve()

Resolves hostnames to an IP address. This function can be used to reduce the number of DNS lookups, e.g. below example.

Example:

var resolved_ip = dnsResolve(host);  if (isInNet(resolved_ip, "10.0.0.0", "255.0.0.0") || 	isInNet(resolved_ip, "172.16.0.0",  "255.240.0.0") || 	isInNet(resolved_ip, "192.168.0.0", "255.255.0.0") || 	isInNet(resolved_ip, "127.0.0.0", "255.255.255.0")) 	return "DIRECT"; 


myIpAddress()

Returns the IP address of the host machine.

Example:

if (isInNet(myIpAddress(), "10.10.1.0", "255.255.255.0")) return "DIRECT"; 


dnsDomainLevels()

This function returns the number of DNS domain levels (number of dots) in the hostname. Can be used to exception internal websites which use short DNS names, e.g. http://intranet

Example:

if (dnsDomainLevels(host) > 0) return "PROXY proxy1.example.com:8080"; 	else return "DIRECT"; 


shExpMatch()

Will attempt to match hostname or URL to a specified shell expression, and returns true if matched.

Example:

if (shExpMatch(url, "*vpn.domain.com*") || 	shExpMatch(url, "*abcdomain.com/folder/*")) return "DIRECT"; 


weekdayRange()

Can be used to specify different proxies for a specific day range. Note example would utilize 'proxy1.example.com' Monday through Friday.

Example:

if (weekdayRange("MON", "FRI")) return "PROXY proxy1.example.com:8080"; 	else return "DIRECT"; 


dateRange()

Can be used to specify different proxies for a specific date range. Note example would utilize 'proxy1.example.com' January through March.

Example:

if (dateRange("JAN", "MAR")) return "PROXY proxy1.example.com:8080"; 	else return "DIRECT"; 


timeRange()

Can be used to specify different proxies for a specific time range. Note example would utilize 'proxy1.example.com' 8am through to 6pm.

Example:

if (timeRange(8, 18)) return "PROXY proxy1.example.com:8080"; 	else return "DIRECT";
 

0 件のコメント:

コメントを投稿