whistle 2.10.9 → 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.
Files changed (47) hide show
  1. package/assets/js/log.js +4 -0
  2. package/bin/api.js +3 -1
  3. package/bin/util.js +1 -1
  4. package/bin/whistle.js +5 -0
  5. package/biz/webui/cgi-bin/get-data.js +0 -1
  6. package/biz/webui/cgi-bin/init.js +0 -1
  7. package/biz/webui/cgi-bin/status.js +2 -1
  8. package/biz/webui/cgi-bin/util.js +1 -1
  9. package/biz/webui/cgi-bin/values/add.js +15 -13
  10. package/biz/webui/htdocs/index.html +1 -1
  11. package/biz/webui/htdocs/js/index.js +50 -51
  12. package/biz/webui/lib/index.js +39 -30
  13. package/index.js +10 -12
  14. package/lib/config.js +25 -79
  15. package/lib/handlers/file-proxy.js +1 -1
  16. package/lib/https/ca.js +18 -17
  17. package/lib/https/h2.js +54 -35
  18. package/lib/https/index.js +124 -107
  19. package/lib/inspectors/data.js +9 -3
  20. package/lib/inspectors/log.js +14 -33
  21. package/lib/inspectors/req.js +3 -6
  22. package/lib/inspectors/res.js +2 -5
  23. package/lib/inspectors/rules.js +11 -6
  24. package/lib/inspectors/weinre.js +1 -1
  25. package/lib/plugins/index.js +45 -54
  26. package/lib/plugins/load-plugin.js +31 -40
  27. package/lib/rules/dns.js +1 -1
  28. package/lib/rules/index.js +3 -1
  29. package/lib/rules/protocols.js +2 -4
  30. package/lib/rules/rules.js +3 -5
  31. package/lib/rules/util.js +2 -7
  32. package/lib/service/compose-data.js +2 -1
  33. package/lib/service/composer.js +12 -10
  34. package/lib/service/service.js +3 -5
  35. package/lib/socket-mgr.js +5 -2
  36. package/lib/tunnel.js +9 -5
  37. package/lib/util/common.js +190 -37
  38. package/lib/util/data-server.js +5 -1
  39. package/lib/util/drain.js +5 -6
  40. package/lib/util/file-mgr.js +1 -1
  41. package/lib/util/http-mgr.js +6 -2
  42. package/lib/util/index.js +48 -69
  43. package/lib/util/speed-transform.js +2 -2
  44. package/lib/util/transproto.js +4 -3
  45. package/lib/util/whistle-transform.js +2 -2
  46. package/lib/util/zlib.js +1 -1
  47. package/package.json +4 -4
package/assets/js/log.js CHANGED
@@ -243,6 +243,10 @@
243
243
  var cacheList = [];
244
244
  var origin = (location.origin || (location.protocol + '//' + location.host)) + '/';
245
245
 
246
+ try {
247
+ LOG_ID = decodeURIComponent(LOG_ID);
248
+ } catch(e) {}
249
+
246
250
  function setLog() {
247
251
  if (!cacheList.length) {
248
252
  return;
package/bin/api.js CHANGED
@@ -139,7 +139,8 @@ exports.network = {
139
139
  * - `Font`:字体文件
140
140
  * - `Img`:图片资源
141
141
  * - `Media`:音视频媒体
142
- * - `WS`:WebSocket 帧数据
142
+ * - `WS`:WebSocket 请求
143
+ * - `SSE`:Server-Sent Events 请求
143
144
  * - `Tunnel`:隧道连接(如 WebSocket 升级)
144
145
  * - `Wasm`:WebAssembly 模块
145
146
  * - `Mock`:Mock 数据
@@ -527,6 +528,7 @@ function getTimings(session) {
527
528
  }
528
529
 
529
530
  exports.utils = {
531
+ createPattern: common.createPattern,
530
532
  isUtf8: isUtf8,
531
533
  getText: getText,
532
534
  getUtf8Buf: getUtf8Buf,
package/bin/util.js CHANGED
@@ -193,7 +193,7 @@ exports.getBody = function (res, callback, isRaw) {
193
193
  res.on('data', function(data) {
194
194
  resBody.push(data);
195
195
  });
196
- res.on('end', function() {
196
+ res.once('end', function() {
197
197
  resBody = Buffer.concat(resBody);
198
198
  try {
199
199
  callback(null, isRaw ? resBody : JSON.parse(resBody.toString()));
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
  });
@@ -104,7 +104,7 @@ exports.getReqData = function(req, callback) {
104
104
  }
105
105
  });
106
106
  req.on('error', handleCb);
107
- req.on('end', function() {
107
+ req.once('end', function() {
108
108
  if (done) {
109
109
  return;
110
110
  }
@@ -6,21 +6,23 @@ module.exports = function(req, res) {
6
6
  var body = req.body;
7
7
  var list;
8
8
  var exists = values.exists(body.name);
9
- if (values.add(body.name, body.value, body.clientId) != null) {
10
- if (isGroup(body.name)) {
11
- if (body.focusName) {
12
- values.moveTo(body.name, body.focusName, body.clientId);
9
+ if (!exists || !body.graceful) {
10
+ if (values.add(body.name, body.value, body.clientId) != null) {
11
+ if (isGroup(body.name)) {
12
+ if (body.focusName) {
13
+ values.moveTo(body.name, body.focusName, body.clientId);
14
+ }
15
+ } else if (body.groupName) {
16
+ values.moveToGroup(body.name, body.groupName);
17
+ } else if (!exists) {
18
+ var group = values.getFirstGroup();
19
+ group && values.moveTo(body.name, group.name, body.clientId, null, true);
13
20
  }
14
- } else if (body.groupName) {
15
- values.moveToGroup(body.name, body.groupName);
16
- } else if (!exists) {
17
- var group = values.getFirstGroup();
18
- group && values.moveTo(body.name, group.name, body.clientId, null, true);
19
21
  }
20
- }
21
- if (req.body.recycleFilename) {
22
- recycleBin.remove(req.body.recycleFilename);
23
- list = recycleBin.list();
22
+ if (body.recycleFilename) {
23
+ recycleBin.remove(body.recycleFilename);
24
+ list = recycleBin.list();
25
+ }
24
26
  }
25
27
  res.json({
26
28
  ec: 0,
@@ -8,6 +8,6 @@
8
8
  </head>
9
9
  <body>
10
10
  <div id="container" class="main"></div>
11
- <script src="js/index.js?v=2.10.9"></script>
11
+ <script src="js/index.js?v=2.10.11"></script>
12
12
  </body>
13
13
  </html>