whistle 2.10.10 → 2.10.11
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/api.js +1 -83
- package/bin/whistle.js +5 -0
- package/biz/webui/cgi-bin/get-data.js +0 -1
- package/biz/webui/cgi-bin/init.js +0 -1
- package/biz/webui/cgi-bin/status.js +2 -1
- package/biz/webui/htdocs/index.html +1 -1
- package/biz/webui/htdocs/js/index.js +48 -48
- package/index.js +10 -12
- package/lib/config.js +15 -66
- package/lib/https/ca.js +1 -1
- package/lib/https/h2.js +1 -1
- package/lib/https/index.js +113 -97
- package/lib/inspectors/data.js +2 -0
- package/lib/inspectors/req.js +3 -6
- package/lib/inspectors/res.js +0 -3
- package/lib/plugins/index.js +1 -1
- package/lib/rules/index.js +2 -1
- package/lib/rules/protocols.js +2 -4
- package/lib/rules/rules.js +2 -4
- package/lib/service/compose-data.js +2 -1
- package/lib/service/composer.js +5 -7
- package/lib/socket-mgr.js +4 -1
- package/lib/tunnel.js +9 -5
- package/lib/util/common.js +142 -12
- package/lib/util/index.js +19 -46
- package/package.json +3 -3
package/bin/api.js
CHANGED
|
@@ -527,90 +527,8 @@ function getTimings(session) {
|
|
|
527
527
|
};
|
|
528
528
|
}
|
|
529
529
|
|
|
530
|
-
var PATTERN_FIELDS = ['url', 'm', 'method', 'reqH', 'reqHeader', 'reqHeaders',
|
|
531
|
-
'b', 'body', 'reqBody', 's', 'statusCode', 'status', 'resH', 'resHeader', 'resHeaders'];
|
|
532
|
-
|
|
533
|
-
function getHeaderKey(key) {
|
|
534
|
-
return !key || typeof key !== 'string' || /[^\w!#$%&'*+.^`|~-]/.test(key) ? '' : key.toLowerCase();
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
function createFilter(item, name, key) {
|
|
538
|
-
var protocol = (item.exclude ? 'ex' : 'in') + 'cludeFilter://';
|
|
539
|
-
name = name ? name + (key ? '.' : ':') : '';
|
|
540
|
-
key = key ? key + ':' : '';
|
|
541
|
-
return protocol + name + key + item.value;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
function createPattern(list) {
|
|
545
|
-
if (!list) {
|
|
546
|
-
return '';
|
|
547
|
-
}
|
|
548
|
-
if (!Array.isArray(list)) {
|
|
549
|
-
list = [list];
|
|
550
|
-
}
|
|
551
|
-
var len = list.length;
|
|
552
|
-
if (!len) {
|
|
553
|
-
return '';
|
|
554
|
-
}
|
|
555
|
-
var result = [];
|
|
556
|
-
var urlPattern;
|
|
557
|
-
var key;
|
|
558
|
-
var add = function(item, name, key) {
|
|
559
|
-
var p = createFilter(item, name, key);
|
|
560
|
-
if (result.indexOf(p) === -1) {
|
|
561
|
-
result.push(p);
|
|
562
|
-
}
|
|
563
|
-
};
|
|
564
|
-
list.forEach(function(item) {
|
|
565
|
-
if (!item || !item.value || PATTERN_FIELDS.indexOf(item.name) === -1) {
|
|
566
|
-
return;
|
|
567
|
-
}
|
|
568
|
-
var value = item.value;
|
|
569
|
-
if (typeof value !== 'string') {
|
|
570
|
-
value = String(value);
|
|
571
|
-
}
|
|
572
|
-
if (/\s/.test(item.value)) {
|
|
573
|
-
return;
|
|
574
|
-
}
|
|
575
|
-
switch(item.name) {
|
|
576
|
-
case 'url':
|
|
577
|
-
if (urlPattern) {
|
|
578
|
-
add(item);
|
|
579
|
-
} else {
|
|
580
|
-
urlPattern = item.value;
|
|
581
|
-
}
|
|
582
|
-
return;
|
|
583
|
-
case 'm':
|
|
584
|
-
case 'method':
|
|
585
|
-
return add(item, 'm');
|
|
586
|
-
case 'reqH':
|
|
587
|
-
case 'reqHeader':
|
|
588
|
-
case 'reqHeaders':
|
|
589
|
-
key = getHeaderKey(item.key);
|
|
590
|
-
return key && add(item, 'reqH', key);
|
|
591
|
-
case 'b':
|
|
592
|
-
case 'body':
|
|
593
|
-
case 'reqBody':
|
|
594
|
-
return add(item, 'b');
|
|
595
|
-
case 's':
|
|
596
|
-
case 'statusCode':
|
|
597
|
-
case 'status':
|
|
598
|
-
return add(item, 's');
|
|
599
|
-
case 'resH':
|
|
600
|
-
case 'resHeader':
|
|
601
|
-
case 'resHeaders':
|
|
602
|
-
key = getHeaderKey(item.key);
|
|
603
|
-
return key && add(item, 'resH', key);
|
|
604
|
-
}
|
|
605
|
-
});
|
|
606
|
-
if (urlPattern || result.length) {
|
|
607
|
-
result.unshift(urlPattern || '*');
|
|
608
|
-
}
|
|
609
|
-
return result.join(' ');
|
|
610
|
-
}
|
|
611
|
-
|
|
612
530
|
exports.utils = {
|
|
613
|
-
createPattern: createPattern,
|
|
531
|
+
createPattern: common.createPattern,
|
|
614
532
|
isUtf8: isUtf8,
|
|
615
533
|
getText: getText,
|
|
616
534
|
getUtf8Buf: getUtf8Buf,
|
package/bin/whistle.js
CHANGED
|
@@ -15,6 +15,11 @@ var colors = require('colors');
|
|
|
15
15
|
var error = util.error;
|
|
16
16
|
var info = util.info;
|
|
17
17
|
var OPTIONS = util.DEFAULT_OPTIONS;
|
|
18
|
+
var version = process.version;
|
|
19
|
+
|
|
20
|
+
if (+version.substring(1).split('.')[0] < 16) {
|
|
21
|
+
error('[!] Node.js@' + version + ' is too old, please upgrade to v16 or above: https://nodejs.org/');
|
|
22
|
+
}
|
|
18
23
|
|
|
19
24
|
function getLatestVersion(options, cb, index) {
|
|
20
25
|
var done;
|
|
@@ -36,7 +36,6 @@ module.exports = function(req, res) {
|
|
|
36
36
|
custom2: properties.get('Custom2'),
|
|
37
37
|
custom1Key: properties.get('Custom1Key'),
|
|
38
38
|
custom2Key: properties.get('Custom2Key'),
|
|
39
|
-
supportH2: config.enableH2,
|
|
40
39
|
hasInvalidCerts: ca.hasInvalidCerts,
|
|
41
40
|
clientIp: clientIp,
|
|
42
41
|
mrulesClientId: config.mrulesClientId,
|
|
@@ -21,7 +21,6 @@ module.exports = function(req, res) {
|
|
|
21
21
|
custom1: properties.get('Custom1'),
|
|
22
22
|
custom2: properties.get('Custom2'),
|
|
23
23
|
hasInvalidCerts: ca.hasInvalidCerts,
|
|
24
|
-
supportH2: config.enableH2,
|
|
25
24
|
lastSvrLogId: lastSvrLog && lastSvrLog.id,
|
|
26
25
|
lastDataId: proxy.getLastDataId(),
|
|
27
26
|
clientId: util.getClientId(),
|
|
@@ -2,9 +2,10 @@ var config = require('../../../lib/config');
|
|
|
2
2
|
|
|
3
3
|
module.exports = function(_, res) {
|
|
4
4
|
res.json({
|
|
5
|
+
whistlePath: config.WHISTLE_PATH,
|
|
6
|
+
whistleName: config.whistleName,
|
|
5
7
|
storage: config.storage || '',
|
|
6
8
|
client: config.client,
|
|
7
|
-
whistleName: config.whistleName,
|
|
8
9
|
name: config.name,
|
|
9
10
|
version: config.version
|
|
10
11
|
});
|