whistle 2.10.9 → 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/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 +50 -51
- package/biz/webui/lib/index.js +39 -30
- package/lib/config.js +10 -13
- 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/inspectors/data.js +7 -3
- 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 +29 -23
- 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('/');
|
|
@@ -1489,48 +1487,47 @@ function getRawType(data) {
|
|
|
1489
1487
|
|
|
1490
1488
|
exports.getRawType = getRawType;
|
|
1491
1489
|
|
|
1492
|
-
function getContentType(
|
|
1493
|
-
if (
|
|
1494
|
-
|
|
1490
|
+
function getContentType(type) {
|
|
1491
|
+
if (type && typeof type != 'string') {
|
|
1492
|
+
type = type['content-type'] || type.contentType;
|
|
1495
1493
|
}
|
|
1496
|
-
|
|
1497
|
-
if (!
|
|
1494
|
+
type = _getRawType(type);
|
|
1495
|
+
if (!type) {
|
|
1498
1496
|
return;
|
|
1499
1497
|
}
|
|
1500
|
-
if (
|
|
1498
|
+
if (type.indexOf('image/') != -1) {
|
|
1499
|
+
return 'IMG';
|
|
1500
|
+
}
|
|
1501
|
+
if (type.indexOf('javascript') != -1) {
|
|
1501
1502
|
return 'JS';
|
|
1502
1503
|
}
|
|
1503
1504
|
|
|
1504
|
-
if (
|
|
1505
|
+
if (type.indexOf('css') != -1) {
|
|
1505
1506
|
return 'CSS';
|
|
1506
1507
|
}
|
|
1507
1508
|
|
|
1508
|
-
if (
|
|
1509
|
+
if (type.indexOf('html') != -1) {
|
|
1509
1510
|
return 'HTML';
|
|
1510
1511
|
}
|
|
1511
1512
|
|
|
1512
|
-
if (
|
|
1513
|
+
if (type.indexOf('json') != -1) {
|
|
1513
1514
|
return 'JSON';
|
|
1514
1515
|
}
|
|
1515
1516
|
|
|
1516
|
-
if (
|
|
1517
|
+
if (type.indexOf('xml') != -1) {
|
|
1517
1518
|
return 'XML';
|
|
1518
1519
|
}
|
|
1519
1520
|
|
|
1520
|
-
if (
|
|
1521
|
+
if (type.indexOf('text/') != -1) {
|
|
1521
1522
|
return 'TEXT';
|
|
1522
1523
|
}
|
|
1523
|
-
|
|
1524
|
-
if (contentType.indexOf('image/') != -1) {
|
|
1525
|
-
return 'IMG';
|
|
1526
|
-
}
|
|
1527
1524
|
}
|
|
1528
1525
|
|
|
1529
1526
|
exports.getContentType = getContentType;
|
|
1530
1527
|
|
|
1531
|
-
function isText(
|
|
1532
|
-
|
|
1533
|
-
return
|
|
1528
|
+
function isText(type) {
|
|
1529
|
+
type = type && getContentType(type);
|
|
1530
|
+
return type && type !== 'IMG';
|
|
1534
1531
|
}
|
|
1535
1532
|
|
|
1536
1533
|
exports.isText = isText;
|
|
@@ -1654,7 +1651,7 @@ function getPipeIconvStream(headers) {
|
|
|
1654
1651
|
};
|
|
1655
1652
|
|
|
1656
1653
|
res.on('data', resolveCharset);
|
|
1657
|
-
res
|
|
1654
|
+
onReadEnd(res, resolveCharset);
|
|
1658
1655
|
});
|
|
1659
1656
|
|
|
1660
1657
|
pipeStream.addTail(function (src, next) {
|
|
@@ -2649,7 +2646,10 @@ exports.getReqId = function (now) {
|
|
|
2649
2646
|
};
|
|
2650
2647
|
|
|
2651
2648
|
exports.onSocketEnd = common.onSocketEnd;
|
|
2652
|
-
|
|
2649
|
+
|
|
2650
|
+
var onReadEnd = common.onReadEnd;
|
|
2651
|
+
exports.onReadEnd = onReadEnd;
|
|
2652
|
+
exports.onWriteEnd = common.onWriteEnd;
|
|
2653
2653
|
|
|
2654
2654
|
exports.getEmptyRes = function getRes() {
|
|
2655
2655
|
var res = common.createTransform();
|
|
@@ -3623,7 +3623,7 @@ function readOneChunk(stream, callback, timeout) {
|
|
|
3623
3623
|
timer = setTimeout(handler, timeout);
|
|
3624
3624
|
}
|
|
3625
3625
|
stream.on('data', handler);
|
|
3626
|
-
stream
|
|
3626
|
+
onReadEnd(stream, handler);
|
|
3627
3627
|
}
|
|
3628
3628
|
|
|
3629
3629
|
exports.readOneChunk = readOneChunk;
|
|
@@ -4031,3 +4031,9 @@ exports.joinBuffer = function(buf, chunk) {
|
|
|
4031
4031
|
exports.formatBuffer = function(buf, len) {
|
|
4032
4032
|
return Array.isArray(buf) ? Buffer.concat(buf, len) : buf;
|
|
4033
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",
|