OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_PROXY_PROXY_RESOLVER_SCRIPT_H_ |
| 6 #define NET_PROXY_PROXY_RESOLVER_SCRIPT_H_ |
| 7 |
1 /* ***** BEGIN LICENSE BLOCK ***** | 8 /* ***** BEGIN LICENSE BLOCK ***** |
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 9 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
3 * | 10 * |
4 * The contents of this file are subject to the Mozilla Public License Version | 11 * The contents of this file are subject to the Mozilla Public License Version |
5 * 1.1 (the "License"); you may not use this file except in compliance with | 12 * 1.1 (the "License"); you may not use this file except in compliance with |
6 * the License. You may obtain a copy of the License at | 13 * the License. You may obtain a copy of the License at |
7 * http://www.mozilla.org/MPL/ | 14 * http://www.mozilla.org/MPL/ |
8 * | 15 * |
9 * Software distributed under the License is distributed on an "AS IS" basis, | 16 * Software distributed under the License is distributed on an "AS IS" basis, |
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | 17 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
(...skipping 19 matching lines...) Expand all Loading... |
30 * of those above. If you wish to allow use of your version of this file only | 37 * of those above. If you wish to allow use of your version of this file only |
31 * under the terms of either the GPL or the LGPL, and not to allow others to | 38 * under the terms of either the GPL or the LGPL, and not to allow others to |
32 * use your version of this file under the terms of the MPL, indicate your | 39 * use your version of this file under the terms of the MPL, indicate your |
33 * decision by deleting the provisions above and replace them with the notice | 40 * decision by deleting the provisions above and replace them with the notice |
34 * and other provisions required by the GPL or the LGPL. If you do not delete | 41 * and other provisions required by the GPL or the LGPL. If you do not delete |
35 * the provisions above, a recipient may use your version of this file under | 42 * the provisions above, a recipient may use your version of this file under |
36 * the terms of any one of the MPL, the GPL or the LGPL. | 43 * the terms of any one of the MPL, the GPL or the LGPL. |
37 * | 44 * |
38 * ***** END LICENSE BLOCK ***** */ | 45 * ***** END LICENSE BLOCK ***** */ |
39 | 46 |
40 #ifndef NET_PROXY_PROXY_RESOLVER_SCRIPT_H_ | |
41 #define NET_PROXY_PROXY_RESOLVER_SCRIPT_H_ | |
42 | |
43 // The following code was formatted from: | 47 // The following code was formatted from: |
44 // 'mozilla/netwerk/base/src/nsProxyAutoConfig.js' (1.55) | 48 // 'mozilla/netwerk/base/src/nsProxyAutoConfig.js' (1.55) |
45 // | 49 // |
46 // Using the command: | 50 // Using the command: |
47 // $ cat nsProxyAutoConfig.js | | 51 // $ cat nsProxyAutoConfig.js | |
48 // awk '/var pacUtils/,/EOF/' | | 52 // awk '/var pacUtils/,/EOF/' | |
49 // sed -e 's/^\s*$/""/g' | | 53 // sed -e 's/^\s*$/""/g' | |
50 // sed -e 's/"\s*[+]\s*$/"/g' | | 54 // sed -e 's/"\s*[+]\s*$/"/g' | |
51 // sed -e 's/"$/" \\/g' | | 55 // sed -e 's/"$/" \\/g' | |
52 // sed -e 's/\/(ipaddr);/\/.exec(ipaddr);/g' | | 56 // sed -e 's/\/(ipaddr);/\/.exec(ipaddr);/g' | |
53 // grep -v '^var pacUtils =' | 57 // grep -v '^var pacUtils =' |
| 58 // |
| 59 // isPlainHost() was removed. |
54 #define PROXY_RESOLVER_SCRIPT \ | 60 #define PROXY_RESOLVER_SCRIPT \ |
55 "function dnsDomainIs(host, domain) {\n" \ | 61 "function dnsDomainIs(host, domain) {\n" \ |
56 " return (host.length >= domain.length &&\n" \ | 62 " return (host.length >= domain.length &&\n" \ |
57 " host.substring(host.length - domain.length) == domain);\n" \ | 63 " host.substring(host.length - domain.length) == domain);\n" \ |
58 "}\n" \ | 64 "}\n" \ |
59 "" \ | 65 "" \ |
60 "function dnsDomainLevels(host) {\n" \ | 66 "function dnsDomainLevels(host) {\n" \ |
61 " return host.split('.').length-1;\n" \ | 67 " return host.split('.').length-1;\n" \ |
62 "}\n" \ | 68 "}\n" \ |
63 "" \ | 69 "" \ |
(...skipping 16 matching lines...) Expand all Loading... |
80 " test[3] > 255 || test[4] > 255) {\n" \ | 86 " test[3] > 255 || test[4] > 255) {\n" \ |
81 " return false; // not an IP address\n" \ | 87 " return false; // not an IP address\n" \ |
82 " }\n" \ | 88 " }\n" \ |
83 " var host = convert_addr(ipaddr);\n" \ | 89 " var host = convert_addr(ipaddr);\n" \ |
84 " var pat = convert_addr(pattern);\n" \ | 90 " var pat = convert_addr(pattern);\n" \ |
85 " var mask = convert_addr(maskstr);\n" \ | 91 " var mask = convert_addr(maskstr);\n" \ |
86 " return ((host & mask) == (pat & mask));\n" \ | 92 " return ((host & mask) == (pat & mask));\n" \ |
87 " \n" \ | 93 " \n" \ |
88 "}\n" \ | 94 "}\n" \ |
89 "" \ | 95 "" \ |
90 "function isPlainHostName(host) {\n" \ | |
91 " return (host.search('\\\\.') == -1);\n" \ | |
92 "}\n" \ | |
93 "" \ | |
94 "function isResolvable(host) {\n" \ | 96 "function isResolvable(host) {\n" \ |
95 " var ip = dnsResolve(host);\n" \ | 97 " var ip = dnsResolve(host);\n" \ |
96 " return (ip != null);\n" \ | 98 " return (ip != null);\n" \ |
97 "}\n" \ | 99 "}\n" \ |
98 "" \ | 100 "" \ |
99 "function localHostOrDomainIs(host, hostdom) {\n" \ | 101 "function localHostOrDomainIs(host, hostdom) {\n" \ |
100 " return (host == hostdom) ||\n" \ | 102 " return (host == hostdom) ||\n" \ |
101 " (hostdom.lastIndexOf(host + '.', 0) == 0);\n" \ | 103 " (hostdom.lastIndexOf(host + '.', 0) == 0);\n" \ |
102 "}\n" \ | 104 "}\n" \ |
103 "" \ | 105 "" \ |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 | 269 |
268 // This is a Microsoft extension to PAC for IPv6, see: | 270 // This is a Microsoft extension to PAC for IPv6, see: |
269 // http://blogs.msdn.com/b/wndp/archive/2006/07/13/ipv6-pac-extensions-v0-9.aspx | 271 // http://blogs.msdn.com/b/wndp/archive/2006/07/13/ipv6-pac-extensions-v0-9.aspx |
270 #define PROXY_RESOLVER_SCRIPT_EX \ | 272 #define PROXY_RESOLVER_SCRIPT_EX \ |
271 "function isResolvableEx(host) {\n" \ | 273 "function isResolvableEx(host) {\n" \ |
272 " var ipList = dnsResolveEx(host);\n" \ | 274 " var ipList = dnsResolveEx(host);\n" \ |
273 " return (ipList != '');\n" \ | 275 " return (ipList != '');\n" \ |
274 "}\n" | 276 "}\n" |
275 | 277 |
276 #endif // NET_PROXY_PROXY_RESOLVER_SCRIPT_H_ | 278 #endif // NET_PROXY_PROXY_RESOLVER_SCRIPT_H_ |
OLD | NEW |