Cisco Cisco Web Security Appliance S360 Guida Alla Risoluzione Dei Problemi

Pagina di 5
 }
See note on the isInNet function at the top of the page.
The isInNet(host, pattern, mask) function returns true if the host IP address matches the specified pattern. The
mask indicates which part of the IP address to match (255=match, 0=ignore).
Example 5: Determine connection type based on host domain
The following function specifies a direct connection if the host is local. If the host is not local, this function
determines which proxy to use based on the host domain. This is useful if the host domain name is one of the
criteria for proxy selection.
function FindProxyForURL(url, host)
 {
 if (isPlainHostName(host))
 return "DIRECT";
 else if (shExpMatch(host, "*.com"))
 return "PROXY comproxy:80";
 else if (shExpMatch(host, "*.edu"))
 return "PROXY eduproxy:80";
 else
 return "PROXY proxy";
 }
The shExpMatch(str, shexp) function returns true if str matches the shexp using shell expression patterns.
Example 6: Determine connection type based on protocol being used
The following function extracts the protocol being used and makes a proxy selection accordingly. If no match
is made on the protocol, then a direct connection is made. This is useful if the protocol being used is one of
the criteria for proxy selection.
function FindProxyForURL(url, host)
 {
 if (url.substring(0, 5) == "http:") {
 return "PROXY proxy:80";
 }
 else if (url.substring(0, 4) == "ftp:") {
 return "PROXY fproxy:80";
 }
 else if (url.substring(0, 7) == "gopher:") {
 return "PROXY gproxy";
 }
 else if (url.substring(0, 6) == "https:") {
 return "PROXY secproxy:8080";
 }
 else {
 return "DIRECT";
 }
 }
The substring function extracts the specified number of characters from a string.