PageRenderTime 24ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/proxy_vole/src/com/btr/proxy/selector/pac/ScriptMethods.java

http://proxy-vole.googlecode.com/
Java | 256 lines | 22 code | 37 blank | 197 comment | 0 complexity | 84612081c090e4ac56cccdabc2277163 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception
  1. package com.btr.proxy.selector.pac;
  2. /***************************************************************************
  3. * Defines the public interface for PAC scripts.
  4. *
  5. * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009
  6. ***************************************************************************/
  7. public interface ScriptMethods {
  8. public boolean isPlainHostName(String host);
  9. /*************************************************************************
  10. * Tests if an URL is in a given domain.
  11. *
  12. * @param host
  13. * is the host name from the URL.
  14. * @param domain
  15. * is the domain name to test the host name against.
  16. * @return true if the domain of host name matches.
  17. ************************************************************************/
  18. public boolean dnsDomainIs(String host, String domain);
  19. /*************************************************************************
  20. * Is true if the host name matches exactly the specified host name, or if
  21. * there is no domain name part in the host name, but the unqualified host
  22. * name matches.
  23. *
  24. * @param host
  25. * the host name from the URL.
  26. * @param domain
  27. * fully qualified host name with domain to match against.
  28. * @return true if matches else false.
  29. ************************************************************************/
  30. public boolean localHostOrDomainIs(String host, String domain);
  31. /*************************************************************************
  32. * Tries to resolve the host name. Returns true if succeeds.
  33. *
  34. * @param host
  35. * is the host name from the URL.
  36. * @return true if resolvable else false.
  37. ************************************************************************/
  38. public boolean isResolvable(String host);
  39. /*************************************************************************
  40. * Tries to resolve the host name. Returns true if succeeds to resolve
  41. * the host to an IPv4 or IPv6 address.
  42. *
  43. * @param host
  44. * is the host name from the URL.
  45. * @return true if resolvable else false.
  46. ************************************************************************/
  47. public boolean isResolvableEx(String host);
  48. /*************************************************************************
  49. * Returns true if the IP address of the host matches the specified IP
  50. * address pattern. Pattern and mask specification is done the same way as
  51. * for SOCKS configuration.
  52. *
  53. * Example: isInNet(host, "198.95.0.0", "255.255.0.0") is true if the IP
  54. * address of the host matches 198.95.*.*.
  55. *
  56. * @param host
  57. * a DNS host name, or IP address. If a host name is passed, it
  58. * will be resolved into an IP address by this function.
  59. * @param pattern
  60. * an IP address pattern in the dot-separated format.
  61. * @param mask
  62. * mask for the IP address pattern informing which parts of the
  63. * IP address should be matched against. 0 means ignore, 255
  64. * means match.
  65. * @return true if it matches else false.
  66. ************************************************************************/
  67. public boolean isInNet(String host, String pattern, String mask);
  68. /*************************************************************************
  69. * Extension of the isInNet method to support IPv6.
  70. * @param ipAddress an IP4 or IP6 address
  71. * @param ipPrefix A string containing colon delimited IP prefix
  72. * with top n bits specified in the bit field
  73. * (i.e. 3ffe:8311:ffff::/48 or 123.112.0.0/16).
  74. * @return true if the host is in the given subnet, else false.
  75. ************************************************************************/
  76. public boolean isInNetEx(String ipAddress, String ipPrefix);
  77. /*************************************************************************
  78. * Resolves the given DNS host name into an IP address, and returns it in
  79. * the dot separated format as a string.
  80. *
  81. * @param host
  82. * the host to resolve.
  83. * @return the resolved IP, empty string if not resolvable.
  84. ************************************************************************/
  85. public String dnsResolve(String host);
  86. /*************************************************************************
  87. * @param host the host to resolve
  88. * @return a semicolon separated list of IP6 and IP4 addresses the host
  89. * name resolves to, empty string if not resolvable.
  90. ************************************************************************/
  91. public String dnsResolveEx(String host);
  92. /*************************************************************************
  93. * Returns the IP address of the host that the process is running on, as a
  94. * string in the dot-separated integer format.
  95. *
  96. * @return an IP as string.
  97. ************************************************************************/
  98. public String myIpAddress();
  99. /*************************************************************************
  100. * Returns a list of IP4 and IP6 addresses of the host that the process
  101. * is running on. The list is separated with semicolons.
  102. * @return the list, empty string if not available.
  103. ************************************************************************/
  104. public String myIpAddressEx();
  105. /*************************************************************************
  106. * Returns the number of DNS domain levels (number of dots) in the host
  107. * name.
  108. *
  109. * @param host
  110. * is the host name from the URL.
  111. * @return number of DNS domain levels.
  112. ************************************************************************/
  113. public int dnsDomainLevels(String host);
  114. /*************************************************************************
  115. * Returns true if the string matches the specified shell expression.
  116. * Actually, currently the patterns are shell expressions, not regular
  117. * expressions.
  118. *
  119. * @param str
  120. * is any string to compare (e.g. the URL, or the host name).
  121. * @param shexp
  122. * is a shell expression to compare against.
  123. * @return true if the string matches, else false.
  124. ************************************************************************/
  125. public boolean shExpMatch(String str, String shexp);
  126. /*************************************************************************
  127. * Only the first parameter is mandatory. Either the second, the third, or
  128. * both may be left out. If only one parameter is present, the function
  129. * yields a true value on the weekday that the parameter represents. If the
  130. * string "GMT" is specified as a second parameter, times are taken to be in
  131. * GMT, otherwise in local time zone. If both wd1 and wd2 are defined, the
  132. * condition is true if the current weekday is in between those two
  133. * weekdays. Bounds are inclusive. If the "GMT" parameter is specified,
  134. * times are taken to be in GMT, otherwise the local time zone is used.
  135. *
  136. * @param wd1
  137. * weekday 1 is one of SUN MON TUE WED THU FRI SAT
  138. * @param wd2
  139. * weekday 2 is one of SUN MON TUE WED THU FRI SAT
  140. * @param gmt
  141. * "GMT" for gmt time format else "undefined"
  142. * @return true if current day matches the criteria.
  143. ************************************************************************/
  144. public boolean weekdayRange(String wd1, String wd2, String gmt);
  145. /*************************************************************************
  146. * Only the first parameter is mandatory. All other parameters can be left
  147. * out therefore the meaning of the parameters changes. The method
  148. * definition shows the version with the most possible parameters filled.
  149. * The real meaning of the parameters is guessed from it's value. If "from"
  150. * and "to" are specified then the bounds are inclusive. If the "GMT"
  151. * parameter is specified, times are taken to be in GMT, otherwise the local
  152. * time zone is used.
  153. *
  154. * @param day1
  155. * is the day of month between 1 and 31 (as an integer).
  156. * @param month1
  157. * one of JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
  158. * @param year1
  159. * is the full year number, for example 1995 (but not 95).
  160. * Integer.
  161. * @param day2
  162. * is the day of month between 1 and 31 (as an integer).
  163. * @param month2
  164. * one of JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
  165. * @param year2
  166. * is the full year number, for example 1995 (but not 95).
  167. * Integer.
  168. * @param gmt
  169. * "GMT" for gmt time format else "undefined"
  170. * @return true if the current date matches the given range.
  171. ************************************************************************/
  172. public boolean dateRange(Object day1, Object month1, Object year1, Object day2, Object month2, Object year2,
  173. Object gmt);
  174. /*************************************************************************
  175. * Some parameters can be left out therefore the meaning of the parameters
  176. * changes. The method definition shows the version with the most possible
  177. * parameters filled. The real meaning of the parameters is guessed from
  178. * it's value. If "from" and "to" are specified then the bounds are
  179. * inclusive. If the "GMT" parameter is specified, times are taken to be in
  180. * GMT, otherwise the local time zone is used.<br/>
  181. *
  182. * <pre>
  183. * timeRange(hour)
  184. * timeRange(hour1, hour2)
  185. * timeRange(hour1, min1, hour2, min2)
  186. * timeRange(hour1, min1, sec1, hour2, min2, sec2)
  187. * timeRange(hour1, min1, sec1, hour2, min2, sec2, gmt)
  188. * </pre>
  189. *
  190. * @param hour1
  191. * is the hour from 0 to 23. (0 is midnight, 23 is 11 pm.)
  192. * @param min1
  193. * minutes from 0 to 59.
  194. * @param sec1
  195. * seconds from 0 to 59.
  196. * @param hour2
  197. * is the hour from 0 to 23. (0 is midnight, 23 is 11 pm.)
  198. * @param min2
  199. * minutes from 0 to 59.
  200. * @param sec2
  201. * seconds from 0 to 59.
  202. * @param gmt
  203. * "GMT" for gmt time format else "undefined"
  204. * @return true if the current time matches the given range.
  205. ************************************************************************/
  206. public boolean timeRange(Object hour1, Object min1, Object sec1, Object hour2, Object min2, Object sec2, Object gmt);
  207. /*************************************************************************
  208. * Sorts a list of IP4 and IP6 addresses. Separated by semicolon.
  209. * Dual addresses first, then IPv6 and last IPv4.
  210. * @param ipAddressList the address list.
  211. * @return the sorted list, empty string if sort is not possible
  212. ************************************************************************/
  213. public String sortIpAddressList(String ipAddressList);
  214. /*************************************************************************
  215. * Gets the version of the PAC extension that is available.
  216. * @return the extension version, currently 1.0
  217. ************************************************************************/
  218. public String getClientVersion();
  219. }