whistle 2.10.8 → 2.10.10
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/assets/js/log.js +4 -0
- package/bin/api.js +85 -1
- package/bin/util.js +1 -1
- package/bin/whistle.js +1 -1
- package/biz/webui/cgi-bin/util.js +1 -1
- package/biz/webui/cgi-bin/values/add.js +15 -13
- package/biz/webui/htdocs/index.html +1 -1
- package/biz/webui/htdocs/js/index.js +38 -39
- package/biz/webui/lib/index.js +39 -30
- package/lib/config.js +11 -18
- package/lib/handlers/file-proxy.js +1 -1
- package/lib/https/ca.js +17 -16
- package/lib/https/h2.js +53 -34
- package/lib/https/index.js +11 -10
- package/lib/index.js +1 -1
- package/lib/inspectors/data.js +8 -4
- package/lib/inspectors/log.js +14 -33
- package/lib/inspectors/res.js +2 -2
- package/lib/inspectors/rules.js +11 -6
- package/lib/inspectors/weinre.js +1 -1
- package/lib/plugins/index.js +44 -53
- package/lib/plugins/load-plugin.js +31 -40
- package/lib/rules/dns.js +1 -1
- package/lib/rules/index.js +1 -0
- package/lib/rules/rules.js +1 -1
- package/lib/rules/util.js +2 -7
- package/lib/service/composer.js +7 -3
- package/lib/service/service.js +3 -5
- package/lib/socket-mgr.js +1 -1
- package/lib/util/common.js +56 -33
- package/lib/util/data-server.js +5 -1
- package/lib/util/drain.js +5 -6
- package/lib/util/file-mgr.js +1 -1
- package/lib/util/http-mgr.js +6 -2
- package/lib/util/index.js +32 -24
- package/lib/util/speed-transform.js +2 -2
- package/lib/util/transproto.js +4 -3
- package/lib/util/whistle-transform.js +2 -2
- package/lib/util/zlib.js +1 -1
- package/package.json +3 -3
package/lib/util/http-mgr.js
CHANGED
|
@@ -143,7 +143,11 @@ function sendReq(options, callback) {
|
|
|
143
143
|
|
|
144
144
|
var timer, client;
|
|
145
145
|
var handleCallback = function (err, res) {
|
|
146
|
+
if (timer == null) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
146
149
|
clearTimeout(timer);
|
|
150
|
+
timer = null;
|
|
147
151
|
if (httpModule) {
|
|
148
152
|
httpModule = null;
|
|
149
153
|
callback(err, res);
|
|
@@ -249,7 +253,7 @@ function request(options, callback) {
|
|
|
249
253
|
handleCallback(err, res, getBody(body, len));
|
|
250
254
|
}
|
|
251
255
|
});
|
|
252
|
-
res.
|
|
256
|
+
res.once('end', function() {
|
|
253
257
|
handleCallback(null, res, getBody(body, len));
|
|
254
258
|
});
|
|
255
259
|
};
|
|
@@ -325,7 +329,7 @@ function readFile(url, callback) {
|
|
|
325
329
|
}
|
|
326
330
|
});
|
|
327
331
|
stream.on('error', listener);
|
|
328
|
-
stream.
|
|
332
|
+
stream.once('end', listener);
|
|
329
333
|
});
|
|
330
334
|
}
|
|
331
335
|
|
package/lib/util/index.js
CHANGED
|
@@ -967,8 +967,6 @@ function getPath(url, noProtocol) {
|
|
|
967
967
|
return url;
|
|
968
968
|
}
|
|
969
969
|
|
|
970
|
-
exports.getPath = getPath;
|
|
971
|
-
|
|
972
970
|
function getFilename(url) {
|
|
973
971
|
if (typeof url == 'string' && (url = getPath(url).trim())) {
|
|
974
972
|
var index = url.lastIndexOf('/');
|
|
@@ -1478,57 +1476,58 @@ exports.getUrlValue = function(rule) {
|
|
|
1478
1476
|
};
|
|
1479
1477
|
|
|
1480
1478
|
function _getRawType(type) {
|
|
1481
|
-
return typeof type === 'string' ? type.split(';')[0].toLowerCase() : '';
|
|
1479
|
+
return typeof type === 'string' ? type.split(';')[0].trim().toLowerCase() : '';
|
|
1482
1480
|
}
|
|
1483
1481
|
|
|
1482
|
+
exports.trimType = _getRawType;
|
|
1483
|
+
|
|
1484
1484
|
function getRawType(data) {
|
|
1485
1485
|
return _getRawType(data.headers && data.headers['content-type']);
|
|
1486
1486
|
}
|
|
1487
1487
|
|
|
1488
1488
|
exports.getRawType = getRawType;
|
|
1489
1489
|
|
|
1490
|
-
function getContentType(
|
|
1491
|
-
if (
|
|
1492
|
-
|
|
1490
|
+
function getContentType(type) {
|
|
1491
|
+
if (type && typeof type != 'string') {
|
|
1492
|
+
type = type['content-type'] || type.contentType;
|
|
1493
1493
|
}
|
|
1494
|
-
|
|
1495
|
-
if (!
|
|
1494
|
+
type = _getRawType(type);
|
|
1495
|
+
if (!type) {
|
|
1496
1496
|
return;
|
|
1497
1497
|
}
|
|
1498
|
-
if (
|
|
1498
|
+
if (type.indexOf('image/') != -1) {
|
|
1499
|
+
return 'IMG';
|
|
1500
|
+
}
|
|
1501
|
+
if (type.indexOf('javascript') != -1) {
|
|
1499
1502
|
return 'JS';
|
|
1500
1503
|
}
|
|
1501
1504
|
|
|
1502
|
-
if (
|
|
1505
|
+
if (type.indexOf('css') != -1) {
|
|
1503
1506
|
return 'CSS';
|
|
1504
1507
|
}
|
|
1505
1508
|
|
|
1506
|
-
if (
|
|
1509
|
+
if (type.indexOf('html') != -1) {
|
|
1507
1510
|
return 'HTML';
|
|
1508
1511
|
}
|
|
1509
1512
|
|
|
1510
|
-
if (
|
|
1513
|
+
if (type.indexOf('json') != -1) {
|
|
1511
1514
|
return 'JSON';
|
|
1512
1515
|
}
|
|
1513
1516
|
|
|
1514
|
-
if (
|
|
1517
|
+
if (type.indexOf('xml') != -1) {
|
|
1515
1518
|
return 'XML';
|
|
1516
1519
|
}
|
|
1517
1520
|
|
|
1518
|
-
if (
|
|
1521
|
+
if (type.indexOf('text/') != -1) {
|
|
1519
1522
|
return 'TEXT';
|
|
1520
1523
|
}
|
|
1521
|
-
|
|
1522
|
-
if (contentType.indexOf('image/') != -1) {
|
|
1523
|
-
return 'IMG';
|
|
1524
|
-
}
|
|
1525
1524
|
}
|
|
1526
1525
|
|
|
1527
1526
|
exports.getContentType = getContentType;
|
|
1528
1527
|
|
|
1529
|
-
function isText(
|
|
1530
|
-
|
|
1531
|
-
return
|
|
1528
|
+
function isText(type) {
|
|
1529
|
+
type = type && getContentType(type);
|
|
1530
|
+
return type && type !== 'IMG';
|
|
1532
1531
|
}
|
|
1533
1532
|
|
|
1534
1533
|
exports.isText = isText;
|
|
@@ -1652,7 +1651,7 @@ function getPipeIconvStream(headers) {
|
|
|
1652
1651
|
};
|
|
1653
1652
|
|
|
1654
1653
|
res.on('data', resolveCharset);
|
|
1655
|
-
res
|
|
1654
|
+
onReadEnd(res, resolveCharset);
|
|
1656
1655
|
});
|
|
1657
1656
|
|
|
1658
1657
|
pipeStream.addTail(function (src, next) {
|
|
@@ -2647,7 +2646,10 @@ exports.getReqId = function (now) {
|
|
|
2647
2646
|
};
|
|
2648
2647
|
|
|
2649
2648
|
exports.onSocketEnd = common.onSocketEnd;
|
|
2650
|
-
|
|
2649
|
+
|
|
2650
|
+
var onReadEnd = common.onReadEnd;
|
|
2651
|
+
exports.onReadEnd = onReadEnd;
|
|
2652
|
+
exports.onWriteEnd = common.onWriteEnd;
|
|
2651
2653
|
|
|
2652
2654
|
exports.getEmptyRes = function getRes() {
|
|
2653
2655
|
var res = common.createTransform();
|
|
@@ -3621,7 +3623,7 @@ function readOneChunk(stream, callback, timeout) {
|
|
|
3621
3623
|
timer = setTimeout(handler, timeout);
|
|
3622
3624
|
}
|
|
3623
3625
|
stream.on('data', handler);
|
|
3624
|
-
stream
|
|
3626
|
+
onReadEnd(stream, handler);
|
|
3625
3627
|
}
|
|
3626
3628
|
|
|
3627
3629
|
exports.readOneChunk = readOneChunk;
|
|
@@ -4029,3 +4031,9 @@ exports.joinBuffer = function(buf, chunk) {
|
|
|
4029
4031
|
exports.formatBuffer = function(buf, len) {
|
|
4030
4032
|
return Array.isArray(buf) ? Buffer.concat(buf, len) : buf;
|
|
4031
4033
|
};
|
|
4034
|
+
|
|
4035
|
+
exports.endSocket = function (socket) {
|
|
4036
|
+
if (!socket.destroyed && !socket.writableEnded) {
|
|
4037
|
+
socket.end();
|
|
4038
|
+
}
|
|
4039
|
+
};
|
|
@@ -6,11 +6,11 @@ function SpeedTransform(options, req) {
|
|
|
6
6
|
Transform.call(this);
|
|
7
7
|
options = options || {};
|
|
8
8
|
this._req = req;
|
|
9
|
-
var value = parseInt((options.speed * 1000) / 8);
|
|
9
|
+
var value = parseInt((options.speed * 1000) / 8, 10);
|
|
10
10
|
if (value > 0) {
|
|
11
11
|
this._speed = value;
|
|
12
12
|
}
|
|
13
|
-
if ((value = parseInt(options.delay)) > 0) {
|
|
13
|
+
if ((value = parseInt(options.delay, 10)) > 0) {
|
|
14
14
|
this._delay = value;
|
|
15
15
|
}
|
|
16
16
|
}
|
package/lib/util/transproto.js
CHANGED
|
@@ -71,15 +71,15 @@ function Parser() {
|
|
|
71
71
|
}
|
|
72
72
|
var data = parseChunk();
|
|
73
73
|
if (data === false) {
|
|
74
|
-
return self.onEnd
|
|
74
|
+
return self.onEnd();
|
|
75
75
|
}
|
|
76
76
|
if (!data) {
|
|
77
77
|
if (chunk === false) {
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
|
-
return self.onContinue
|
|
80
|
+
return self.onContinue();
|
|
81
81
|
}
|
|
82
|
-
self.onData
|
|
82
|
+
self.onData(data);
|
|
83
83
|
self.write(false);
|
|
84
84
|
};
|
|
85
85
|
}
|
|
@@ -91,6 +91,7 @@ exports.getDecodeTransform = function () {
|
|
|
91
91
|
parser.onEnd = function () {
|
|
92
92
|
data && trans.push(data);
|
|
93
93
|
trans.push(null);
|
|
94
|
+
data = null;
|
|
94
95
|
};
|
|
95
96
|
parser.onContinue = function () {
|
|
96
97
|
if (transCb) {
|
|
@@ -9,11 +9,11 @@ var DOCTYPE = Buffer.from('<!DOCTYPE html>\r\n');
|
|
|
9
9
|
function WhistleTransform(options, req) {
|
|
10
10
|
Transform.call(this);
|
|
11
11
|
options = options || {};
|
|
12
|
-
var value = parseInt((options.speed * 1000) / 8);
|
|
12
|
+
var value = parseInt((options.speed * 1000) / 8, 10);
|
|
13
13
|
if (value > 0) {
|
|
14
14
|
this._speed = value;
|
|
15
15
|
}
|
|
16
|
-
if ((value = parseInt(options.delay)) > 0) {
|
|
16
|
+
if ((value = parseInt(options.delay, 10)) > 0) {
|
|
17
17
|
this._delay = value;
|
|
18
18
|
}
|
|
19
19
|
this._noDoctype = options.noDoctype;
|
package/lib/util/zlib.js
CHANGED
|
@@ -19,7 +19,7 @@ function zlibBuffer(engine, buffer, callback) {
|
|
|
19
19
|
engine.cb = callback;
|
|
20
20
|
engine.on('data', zlibBufferOnData);
|
|
21
21
|
engine.on('error', zlibBufferOnError);
|
|
22
|
-
engine.
|
|
22
|
+
engine.once('end', zlibBufferOnEnd);
|
|
23
23
|
engine.end(buffer);
|
|
24
24
|
}
|
|
25
25
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "whistle",
|
|
3
3
|
"description": "HTTP, HTTP2, HTTPS, Websocket debugging proxy",
|
|
4
|
-
"version": "2.10.
|
|
4
|
+
"version": "2.10.10",
|
|
5
5
|
"dataDirname": ".whistle",
|
|
6
6
|
"localUIHost": "local.whistlejs.com",
|
|
7
7
|
"port": 8899,
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"docs": "vitepress build docs"
|
|
76
76
|
},
|
|
77
77
|
"engines": {
|
|
78
|
-
"node": ">=
|
|
78
|
+
"node": ">= 14.0.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"babel-core": "^6.7.6",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"react": "^15.6.2",
|
|
103
103
|
"react-base16-styling": "^0.5.1",
|
|
104
104
|
"react-dom": "^15.6.2",
|
|
105
|
-
"react-virtualized": "
|
|
105
|
+
"react-virtualized": "~9.21.2",
|
|
106
106
|
"request": "^2.74.0",
|
|
107
107
|
"should": "^13.2.3",
|
|
108
108
|
"should-http": "^0.1.1",
|