whistle 2.10.6 → 2.10.8
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/menu.html +2 -2
- package/assets/modal.html +2 -2
- package/assets/tab.html +2 -2
- package/bin/api.js +545 -0
- package/bin/import.js +3 -3
- package/bin/plugin.js +4 -8
- package/bin/use.js +22 -8
- package/bin/util.js +10 -5
- package/bin/whistle.js +11 -1
- package/biz/webui/cgi-bin/abort.js +14 -5
- package/biz/webui/cgi-bin/frames.js +12 -0
- package/biz/webui/cgi-bin/is-enabled-https.js +6 -0
- package/biz/webui/cgi-bin/plugins/disable-plugin.js +16 -7
- package/biz/webui/cgi-bin/plugins/list.js +17 -0
- package/biz/webui/cgi-bin/plugins/plugin.js +21 -0
- package/biz/webui/cgi-bin/plugins/status.js +21 -0
- package/biz/webui/cgi-bin/rules/is-multi-select.js +7 -0
- package/biz/webui/cgi-bin/rules/move-top.js +11 -0
- package/biz/webui/cgi-bin/rules/select.js +1 -1
- package/biz/webui/cgi-bin/rules/select2.js +16 -0
- package/biz/webui/cgi-bin/rules/status.js +6 -0
- package/biz/webui/cgi-bin/rules/unselect.js +3 -2
- package/biz/webui/cgi-bin/rules/unselect2.js +18 -0
- package/biz/webui/cgi-bin/rules/value.js +19 -0
- package/biz/webui/cgi-bin/sessions.js +6 -0
- package/biz/webui/cgi-bin/util.js +15 -1
- package/biz/webui/htdocs/index.html +1 -1
- package/biz/webui/htdocs/js/index.js +52 -52
- package/biz/webui/lib/index.js +7 -8
- package/lib/https/index.js +4 -4
- package/lib/init.js +1 -0
- package/lib/inspectors/data.js +6 -4
- package/lib/inspectors/req.js +1 -2
- package/lib/inspectors/res.js +6 -10
- package/lib/plugins/index.js +2 -2
- package/lib/plugins/load-plugin.js +17 -6
- package/lib/rules/util.js +20 -10
- package/lib/service/composer.js +11 -27
- package/lib/service/data-center.js +0 -12
- package/lib/service/generate-saz.js +2 -2
- package/lib/service/service.js +6 -5
- package/lib/service/util.js +6 -16
- package/lib/socket-mgr.js +23 -17
- package/lib/tunnel.js +7 -17
- package/lib/upgrade.js +4 -8
- package/lib/util/common.js +75 -9
- package/lib/util/data-server.js +273 -0
- package/lib/util/index.js +8 -22
- package/lib/util/patch.js +2 -6
- package/lib/util/speed-transform.js +17 -6
- package/lib/util/whistle-transform.js +18 -7
- package/package.json +13 -10
package/lib/util/patch.js
CHANGED
|
@@ -4,6 +4,7 @@ var Socket = require('net').Socket;
|
|
|
4
4
|
var http = require('http');
|
|
5
5
|
var https = require('https');
|
|
6
6
|
var hparser = require('hparser');
|
|
7
|
+
var common = require('./common');
|
|
7
8
|
|
|
8
9
|
var httpRequest = http.request;
|
|
9
10
|
var httpsRequest = https.request;
|
|
@@ -133,12 +134,7 @@ http.request = function (options) {
|
|
|
133
134
|
headers['x-whistle-policy'] = 'intercept';
|
|
134
135
|
delete headers['X-Whistle-Policy'];
|
|
135
136
|
}
|
|
136
|
-
|
|
137
|
-
var rawData = 'CONNECT ' + tunnelPath + ' HTTP/1.1';
|
|
138
|
-
if (headers) {
|
|
139
|
-
rawData += '\r\n' + headers;
|
|
140
|
-
}
|
|
141
|
-
rawData += '\r\n\r\n';
|
|
137
|
+
var rawData = common.getHttpMeta('CONNECT', tunnelPath, 'HTTP/1.1', headers);
|
|
142
138
|
if (res.statusCode === 200 && res.headers['x-whistle-allow-tunnel-ack']) {
|
|
143
139
|
rawData = '1' + rawData;
|
|
144
140
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
var Transform = require('pipestream').Transform;
|
|
2
|
-
var
|
|
2
|
+
var inherits = require('util').inherits;
|
|
3
|
+
var setDelayTimer = require('./common').setDelayTimer;
|
|
3
4
|
|
|
4
|
-
function SpeedTransform(options) {
|
|
5
|
+
function SpeedTransform(options, req) {
|
|
5
6
|
Transform.call(this);
|
|
6
7
|
options = options || {};
|
|
8
|
+
this._req = req;
|
|
7
9
|
var value = parseInt((options.speed * 1000) / 8);
|
|
8
10
|
if (value > 0) {
|
|
9
11
|
this._speed = value;
|
|
@@ -13,13 +15,22 @@ function SpeedTransform(options) {
|
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
inherits(SpeedTransform, Transform);
|
|
17
19
|
|
|
18
|
-
SpeedTransform.prototype
|
|
20
|
+
var proto = SpeedTransform.prototype;
|
|
21
|
+
|
|
22
|
+
proto._setTimeout = function (callback, delay) {
|
|
23
|
+
var timer = setTimeout(callback, delay);
|
|
24
|
+
if (this._req) {
|
|
25
|
+
setDelayTimer(this._req, timer);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
proto._transform = function (chunk, encoding, callback) {
|
|
19
30
|
var self = this;
|
|
20
31
|
var cb = function () {
|
|
21
32
|
if (chunk && self._speed) {
|
|
22
|
-
|
|
33
|
+
self._setTimeout(function () {
|
|
23
34
|
callback(null, chunk);
|
|
24
35
|
}, Math.round((chunk.length * 1000) / self._speed));
|
|
25
36
|
} else {
|
|
@@ -30,7 +41,7 @@ SpeedTransform.prototype._transform = function (chunk, encoding, callback) {
|
|
|
30
41
|
if (self._delay) {
|
|
31
42
|
var delay = self._delay;
|
|
32
43
|
self._delay = null;
|
|
33
|
-
return
|
|
44
|
+
return self._setTimeout(cb, delay);
|
|
34
45
|
}
|
|
35
46
|
|
|
36
47
|
cb();
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
var Transform = require('pipestream').Transform;
|
|
2
|
-
var
|
|
2
|
+
var inherits = require('util').inherits;
|
|
3
3
|
var iconv = require('iconv-lite');
|
|
4
4
|
var fileMgr = require('./file-mgr');
|
|
5
|
+
var setDelayTimer = require('./common').setDelayTimer;
|
|
5
6
|
|
|
6
7
|
var DOCTYPE = Buffer.from('<!DOCTYPE html>\r\n');
|
|
7
8
|
|
|
8
|
-
function WhistleTransform(options) {
|
|
9
|
+
function WhistleTransform(options, req) {
|
|
9
10
|
Transform.call(this);
|
|
10
11
|
options = options || {};
|
|
11
12
|
var value = parseInt((options.speed * 1000) / 8);
|
|
@@ -21,6 +22,7 @@ function WhistleTransform(options) {
|
|
|
21
22
|
if (!iconv.encodingExists(charset)) {
|
|
22
23
|
charset = 'utf8';
|
|
23
24
|
}
|
|
25
|
+
this._req = req;
|
|
24
26
|
this._isHtml = options.isHtml;
|
|
25
27
|
this._body = getBuffer(options, 'body', charset);
|
|
26
28
|
this._top = getBuffer(options, 'top', charset);
|
|
@@ -42,7 +44,16 @@ function getBuffer(options, name, charset) {
|
|
|
42
44
|
return iconv.encode(buf + '', charset);
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
inherits(WhistleTransform, Transform);
|
|
48
|
+
|
|
49
|
+
var proto = WhistleTransform.prototype;
|
|
50
|
+
|
|
51
|
+
proto._setTimeout = function (callback, delay) {
|
|
52
|
+
var timer = setTimeout(callback, delay);
|
|
53
|
+
if (this._req) {
|
|
54
|
+
setDelayTimer(this._req, timer);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
46
57
|
|
|
47
58
|
function filterHtml(list, isSafe) {
|
|
48
59
|
if (!Array.isArray(list)) {
|
|
@@ -64,7 +75,7 @@ function joinData(list) {
|
|
|
64
75
|
return Array.isArray(list) ? fileMgr.joinData(list) : list;
|
|
65
76
|
}
|
|
66
77
|
|
|
67
|
-
|
|
78
|
+
proto.allowInject = function (chunk) {
|
|
68
79
|
if (!this._isHtml) {
|
|
69
80
|
return true;
|
|
70
81
|
}
|
|
@@ -88,7 +99,7 @@ WhistleTransform.prototype.allowInject = function (chunk) {
|
|
|
88
99
|
return true;
|
|
89
100
|
};
|
|
90
101
|
|
|
91
|
-
|
|
102
|
+
proto._transform = function (chunk, encoding, callback) {
|
|
92
103
|
var self = this;
|
|
93
104
|
var cb = function () {
|
|
94
105
|
if (self._allowInject && self._ended && self._bottom) {
|
|
@@ -96,7 +107,7 @@ WhistleTransform.prototype._transform = function (chunk, encoding, callback) {
|
|
|
96
107
|
self._bottom = null;
|
|
97
108
|
}
|
|
98
109
|
if (chunk && self._speed) {
|
|
99
|
-
|
|
110
|
+
self._setTimeout(function () {
|
|
100
111
|
callback(null, chunk);
|
|
101
112
|
}, Math.round((chunk.length * 1000) / self._speed));
|
|
102
113
|
} else {
|
|
@@ -126,7 +137,7 @@ WhistleTransform.prototype._transform = function (chunk, encoding, callback) {
|
|
|
126
137
|
self._top = null;
|
|
127
138
|
}
|
|
128
139
|
}
|
|
129
|
-
return self._delay ?
|
|
140
|
+
return self._delay ? self._setTimeout(cb, self._delay) : cb();
|
|
130
141
|
}
|
|
131
142
|
|
|
132
143
|
if (self._ended) {
|
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.8",
|
|
5
5
|
"dataDirname": ".whistle",
|
|
6
6
|
"localUIHost": "local.whistlejs.com",
|
|
7
7
|
"port": 8899,
|
|
@@ -15,14 +15,17 @@
|
|
|
15
15
|
},
|
|
16
16
|
"homepage": "https://wproxy.org",
|
|
17
17
|
"keywords": [
|
|
18
|
-
"proxy",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
18
|
+
"http-proxy",
|
|
19
|
+
"https-proxy",
|
|
20
|
+
"web-debugging",
|
|
21
|
+
"network-debugging",
|
|
22
|
+
"http-interceptor",
|
|
23
|
+
"api-mocking",
|
|
21
24
|
"websocket",
|
|
22
25
|
"http2",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
+
"mitm",
|
|
27
|
+
"fiddler-alternative",
|
|
28
|
+
"charles-alternative"
|
|
26
29
|
],
|
|
27
30
|
"bin": {
|
|
28
31
|
"whistle": "./bin/whistle.js",
|
|
@@ -34,9 +37,9 @@
|
|
|
34
37
|
"url": "https://github.com/avwo/whistle.git"
|
|
35
38
|
},
|
|
36
39
|
"dependencies": {
|
|
37
|
-
"adm-zip": "0.
|
|
40
|
+
"adm-zip": "^0.6.0",
|
|
38
41
|
"async-limiter": "2.0.0",
|
|
39
|
-
"body-parser": "^1.20.
|
|
42
|
+
"body-parser": "^1.20.6",
|
|
40
43
|
"colors": "1.1.2",
|
|
41
44
|
"express": "^4.21.2",
|
|
42
45
|
"extend": "^3.0.2",
|
|
@@ -48,7 +51,7 @@
|
|
|
48
51
|
"lru-cache": "^4.1.1",
|
|
49
52
|
"mime": "^1.6.0",
|
|
50
53
|
"multer2": "^1.1.1",
|
|
51
|
-
"node-forge": "^1.
|
|
54
|
+
"node-forge": "^1.4.0",
|
|
52
55
|
"node-pac": "^0.5.1",
|
|
53
56
|
"parseurl": "^1.3.1",
|
|
54
57
|
"pfork": "^0.6.3",
|