The JavaScript functions used by the PAC file

Source: Internet
Author: User
Tags dns hostname local time string format

The following are the conditional functions that can be used in the body of the FindProxyForURL () function:

Host-Name-based functions:

    • isPlainHostName ()
    • dnsDomainIs ()
    • localHostOrDomainIs ()
    • Isresolvable ()
    • isInNet ()

Related Utility functions:

    • Dnsresolve ()
    • myIpAddress ()
    • dnsDomainLevels ()

Conditions based on url/host name:

    • shExpMatch ()

Time-based conditions:

    • Weekdayrange ()
    • DateRange ()
    • Timerange ()
    • isPlainHostName (host)

The host name in the URL, as described above, does not include the port number, and is not mentioned again. Returns true if the host name does not contain a domain name. Refer to the following:

    • isPlainHostName ("www") returns true.
    • isPlainHostName ("www.google.com") returns false.
    • dnsDomainIs (host, domain)

Domain that is used for comparison with hostname. Returns true if the hostname domain name matches the value of domain. Refer to the following:

    • dnsDomainIs ("www.google.com", ". Google.com") returns true.
    • dnsDomainIs ("www", ". Google.com") returns false.
    • dnsDomainIs ("www.apple.com", ". Google.com") returns false.
    • localHostOrDomainIs (host, Hostdom)

The hostdom is the specified host name to be matched. The function returns TRUE if hostname matches the specified hostdom, or if there is no part of the domain name specified in hostname to be matched. Refer to the following:

    • localHostOrDomainIs ("www. Google.com "," www. Google.com ") returns True (exact match).
    • localHostOrDomainIs ("www", "www.") Google.com ") returns True (hostname match, domain not specified).
    • localHostOrDomainIs ("www.apple.com", "www. Google.com ") returns False (domain name mismatch).
    • localHostOrDomainIs ("adc.apple.com", "www. Google.com ") returns FALSE (hostname mismatch).

Isresolvable (host)

Returns true if the host name is resolved successfully. Refer to the following:

    • Isresolvable ("www.google.com") returns True (unless DNS cannot be resolved due to firewalls or some other reason).
    • Isresolvable ("Bogus.domain.foobar") returns false.

isInNet (host, pattern, mask)

Host can be a DNS hostname, such as www.google.com, or an IP address. If the host name is passed, this function resolves it to an IP address. Pattern is the IP address pattern in point-delimited format.

Mask is an IP address pattern mask that determines which parts of an IP address should be matched. A value of 0 means ignore; 255 indicates a match. Returns true if the IP address of the host matches the specified IP address pattern. Refer to the following:

    • isInNet (Host, "198.95.249.79", "255.255.255.255") returns True if the IP address of host is 198.95.249.79.
    • isInNet (Host, "198.95.0.0", "255.255.0.0") returns True if the IP address of host is 198.95.*.*.

Dnsresolve (host)

Host is the hostname to resolve. Resolves the given DNS host name to an IP address and returns it as a string in a dotted-delimited format. Refer to the following:

Dnsresolve ("www.google.com") returns the IP address "64.233.189.104".

myIpAddress ()

This function returns the IP address of the computer that is running the browser in a dotted-delimited string format.

dnsDomainLevels (host)

Returns the number of DNS tiers (dots) in the URL host name. Refer to the following:

dnsDomainLevels ("www") returns 0

dnsDomainLevels ("www.google.com") returns 2

shExpMatch (str, SHEXP)

STR is any string to compare (for example, a URL or host name).

Shexp is the shell expression used for comparison. This expression is true if the string matches the specified shell expression. Refer to the following:

shExpMatch ("http://www.apple.com/downloads/macosx/index.html", "*/macosx/*") returns True.

shExpMatch ("http://www.apple.com/downloads/support/index.html", "*/macosx/*") returns false.

Weekdayrange (WD1, Wd2, GMT)

WD1 and Wd2 are any of the following one-week date strings: SUN MON TUE WED THU FRI SAT, GMT or string GMT or omitted, the former represents Greenwich Mean Time, which represents local time. Only the first parameter, WD1, is mandatory. Any or both of the Wd2, GMT, or both can be omitted. If there is only one argument, this function returns true for the Sunday period represented by the parameter. If you specify a string GMT as the second parameter, the GMT time is used, otherwise the time in the local time zone is used. If both WD1 and WD2 are defined, the condition is true when the current Sunday period is between the two-week date. The first and last dates are included. The order of the parameters is important; "Mon," "WED" means Monday to Wednesday, while "WED," "Mon" is from Wednesday to next week in Monday.

Weekdayrange ("MON", "FRI") is true from Monday to Friday (local time zone).

Weekdayrange ("MON", "FRI", "GMT") is true from Greenwich Mean Time Monday to Friday.

Weekdayrange ("SAT") local time Saturday is true.

Weekdayrange ("SAT", "GMT") Greenwich Standard Time Saturday is true.

Weekdayrange ("FRI", "MON") is true from Friday to next Monday (note that the order is important).

DateRange (Day)

DateRange (Day1, Day2)

DateRange (Mon)

DateRange (Month1, Month2)

DateRange (year)

DateRange (year1, YEAR2)

DateRange (Day1, Month1, Day2, Month2)

DateRange (Month1, year1, Month2, year2)

DateRange (Day1, Month1, Year1, Day2, Month2, year2)

DateRange (Day1, Month1, Year1, Day2, Month2, Year2, GMT)

Day (integer type) from 1 to 31st days per month.

Month is one of the following strings that represent the month: JAN FEB MAR APR may June JUL SEP OCT NOV DEC, Year is the full number representing the years, such as 1995 (not 95). The integer type.

GMT is either a string GMT, or left blank, which will be compared in Greenwich Mean Time, which assumes the time is in the local time zone. Although the function syntax represented above does not each contain a GMT parameter, you can actually specify the GMT parameter in any of the 9 call configuration files above, but it will always be the last parameter. If only a single value is specified (for each category: Day, month, year), this function returns true only on the days that match the specified value. If two values are specified, the result is truee from the specified first time to the second time specified. The first and last dates are included. Refer to the following:

DateRange (1) True for the first day of the month in the local time zone.

DateRange (1, "GMT") is true on the first day of the month of the GMT time.

DateRange (1, 15) is true for numbers 1th to 15th in the local time zone each month.

DateRange ("DEC") is true on December 24 of each year in the local time zone.

DateRange ("DEC", 1995) is true in the local time zone December 24, 1995.

DateRange ("JAN", "MAR") is true for the first quarter of each year in the local time zone (January to March).

DateRange (1, "June", "the") is true in the local time zone from June 1 to August 15 each year, including the first and last dates.

DateRange (1, "June", 1995, "1995") is true in the local time zone from June 1, 1995 to August 15, and the first end date is included.

DateRange ("OCT", 1995, "MAR", 1996) is true in the local time zone from October 1995 to March 1996.

DateRange (1995) in local time zone 1995 is true.

DateRange (1995, 1997) is true in the local time zone from January 1, 1995 to December 31, 1997 (beginning of 1995 to the end of 1997).

Timerange (Hour)

Timerange (Hour1, HOUR2)

Timerange (Hour1, Min1, HOUR2, min2)

Timerange (Hour1, Min1, SEC1, HOUR2, min2, SEC2)

Timerange (Hour1, Min1, SEC1, HOUR2, min2, Sec2, GMT)

Hour is one of the values for the hour at 0 (12 o'clock Midnight) to 23 (11 o'clock at night).

Min is a value that represents 0 to 59 of the minute.

The SEC is a value that represents 0 to 59 of a second.

GMT as described in the preceding article.

Timerange (12) is true between 12 o'clock to 1 o'clock in the afternoon noon.

Timerange (12, 13) the same example.

Timerange ("GMT") is true between 12 o'clock and 1 o'clock in the afternoon GMT.

Timerange (9, 17) is true between 9 o'clock in the morning and 5 o'clock in the afternoon.

Timerange (8, 30, 17, 00) is true between 8:30 A.M. and 5 o'clock in the afternoon.

Timerange (0, 0, 0, 0, 0, 30) is true from 0 o'clock midnight to 30 seconds thereafter.

The JavaScript functions used by the PAC file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.