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 +2 -2
- package/biz/webui/cgi-bin/create-cert.js +13 -5
- package/biz/webui/cgi-bin/util.js +1 -0
- package/biz/webui/htdocs/index.html +1 -1
- package/biz/webui/htdocs/js/index.js +33 -33
- package/lib/handlers/file-proxy.js +6 -6
- package/lib/https/ca.js +15 -7
- package/lib/https/index.js +2 -1
- package/lib/inspectors/res.js +1 -1
- package/lib/plugins/index.js +17 -8
- package/lib/plugins/load-plugin.js +691 -708
- package/lib/plugins/proxy.js +10 -2
- package/lib/rules/index.js +3 -1
- package/lib/rules/rules.js +6 -3
- package/lib/rules/util.js +2 -2
- package/lib/socket-mgr.js +24 -22
- package/lib/tunnel.js +2 -5
- package/lib/util/index.js +10 -2
- package/package.json +4 -4
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 *
|
|
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
|
|
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
|
|
3
|
+
var qs = require('querystring');
|
|
4
|
+
var ca = require('../../../lib/https/ca');
|
|
4
5
|
|
|
5
|
-
var URL_RE = /^(?:(
|
|
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 >
|
|
11
|
+
if (!domain || domain.length > 256 || !URL_RE.test(domain)) {
|
|
10
12
|
return;
|
|
11
13
|
}
|
|
12
|
-
|
|
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
|
|
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));
|