whistle 2.9.4 → 2.9.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/use.js CHANGED
@@ -10,7 +10,7 @@ var error = util.error;
10
10
  var warn = util.warn;
11
11
  var info = util.info;
12
12
  var readConfig = util.readConfig;
13
- var MAX_RULES_LEN = 1024 * 16;
13
+ var MAX_RULES_LEN = 1024 * 256;
14
14
  var DEFAULT_OPTIONS = { host: '127.0.0.1', port: 8899 };
15
15
  var options;
16
16
 
@@ -142,7 +142,7 @@ module.exports = function(filepath, storage, force) {
142
142
  }
143
143
  var rules = getString(result.rules);
144
144
  if (rules.length > MAX_RULES_LEN) {
145
- error('The rules cannot be empty and the size cannot exceed 16k.');
145
+ error('The rules cannot be empty and the size cannot exceed 256k.');
146
146
  return;
147
147
  }
148
148
  var setRules = function() {
@@ -1,15 +1,21 @@
1
1
  var Zip = require('node-native-zip2');
2
2
  var Buffer = require('safe-buffer').Buffer;
3
- var createCertificate = require('../../../lib/https/ca').createCertificate;
3
+ var qs = require('querystring');
4
+ var ca = require('../../../lib/https/ca');
4
5
 
5
- var URL_RE = /^(?:(?:[\w.-]+:)?\/\/)?([\w.-]+)/i;
6
+ var URL_RE = /^(?:([\w.-]+:)?\/\/)?([\w.=&!~*'()%-]+)/i;
7
+ var ILLEGAL_CHARS_RE = /[=&!~*'()%]/;
6
8
 
7
9
  function parseDomain(domain) {
8
10
  domain = domain && typeof domain === 'string' && domain.trim();
9
- if (!domain || domain.length > 64 || !URL_RE.test(domain)) {
11
+ if (!domain || domain.length > 256 || !URL_RE.test(domain)) {
10
12
  return;
11
13
  }
12
- return RegExp.$1.toLowerCase();
14
+ domain = RegExp.$2.toLowerCase();
15
+ if (RegExp.$1 === 'root:') {
16
+ return qs.parse(domain);
17
+ }
18
+ return ILLEGAL_CHARS_RE.test(domain) ? null : domain;
13
19
  }
14
20
 
15
21
  module.exports = function(req, res) {
@@ -17,8 +23,10 @@ module.exports = function(req, res) {
17
23
  if (!domain) {
18
24
  return res.status(400).end('Bad Request');
19
25
  }
20
- var cert = createCertificate(domain);
26
+ var isStr = typeof domain == 'string';
27
+ var cert = isStr ? ca.createCertificate(domain) : ca.createRootCA(domain);
21
28
  var zip = new Zip();
29
+ domain = isStr ? domain : 'root';
22
30
  var dir = domain + '/' + domain;
23
31
  zip.add(dir + '.crt', Buffer.from(cert.cert));
24
32
  zip.add(dir + '.key', Buffer(cert.key));
@@ -28,6 +28,7 @@ exports.getServerInfo = function(req) {
28
28
  dcc: config.disableCustomCerts,
29
29
  dns: dnsOverHttps || config.dnsServer,
30
30
  doh: doh,
31
+ bip: config.host,
31
32
  df: config.dnsOptional,
32
33
  r6: config.resolve6,
33
34
  version: config.version,
@@ -8,6 +8,6 @@
8
8
  </head>
9
9
  <body style="overscroll-behavior-x: none;">
10
10
  <div id="container" class="main"></div>
11
- <script src="js/index.js?v=2.9.4"></script>
11
+ <script src="js/index.js?v=2.9.7"></script>
12
12
  </body>
13
13
  </html>