whistle 2.10.5 → 2.10.7

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 (56) hide show
  1. package/assets/menu.html +2 -2
  2. package/assets/modal.html +2 -2
  3. package/assets/tab.html +2 -2
  4. package/bin/api.js +545 -0
  5. package/bin/import.js +3 -3
  6. package/bin/plugin.js +4 -8
  7. package/bin/use.js +22 -8
  8. package/bin/util.js +12 -7
  9. package/bin/whistle.js +11 -1
  10. package/biz/webui/cgi-bin/abort.js +14 -5
  11. package/biz/webui/cgi-bin/frames.js +12 -0
  12. package/biz/webui/cgi-bin/get-session.js +7 -3
  13. package/biz/webui/cgi-bin/is-enabled-https.js +6 -0
  14. package/biz/webui/cgi-bin/plugins/disable-plugin.js +16 -7
  15. package/biz/webui/cgi-bin/plugins/list.js +17 -0
  16. package/biz/webui/cgi-bin/plugins/plugin.js +21 -0
  17. package/biz/webui/cgi-bin/plugins/status.js +21 -0
  18. package/biz/webui/cgi-bin/rules/is-multi-select.js +7 -0
  19. package/biz/webui/cgi-bin/rules/move-top.js +11 -0
  20. package/biz/webui/cgi-bin/rules/select.js +1 -1
  21. package/biz/webui/cgi-bin/rules/select2.js +16 -0
  22. package/biz/webui/cgi-bin/rules/status.js +6 -0
  23. package/biz/webui/cgi-bin/rules/unselect.js +3 -2
  24. package/biz/webui/cgi-bin/rules/unselect2.js +18 -0
  25. package/biz/webui/cgi-bin/rules/value.js +19 -0
  26. package/biz/webui/cgi-bin/sessions.js +6 -0
  27. package/biz/webui/cgi-bin/util.js +45 -20
  28. package/biz/webui/htdocs/index.html +1 -1
  29. package/biz/webui/htdocs/js/index.js +51 -51
  30. package/biz/webui/lib/index.js +1 -3
  31. package/lib/https/index.js +7 -5
  32. package/lib/init.js +1 -0
  33. package/lib/inspectors/data.js +39 -34
  34. package/lib/inspectors/req.js +9 -6
  35. package/lib/inspectors/res.js +10 -14
  36. package/lib/plugins/index.js +2 -2
  37. package/lib/plugins/load-plugin.js +19 -8
  38. package/lib/rules/util.js +20 -10
  39. package/lib/service/composer.js +7 -22
  40. package/lib/service/data-center.js +0 -12
  41. package/lib/service/generate-saz.js +2 -2
  42. package/lib/service/service.js +8 -7
  43. package/lib/service/util.js +6 -16
  44. package/lib/socket-mgr.js +23 -17
  45. package/lib/tunnel.js +7 -17
  46. package/lib/upgrade.js +4 -8
  47. package/lib/util/common.js +78 -11
  48. package/lib/util/data-server.js +273 -0
  49. package/lib/util/file-mgr.js +7 -4
  50. package/lib/util/http-mgr.js +17 -9
  51. package/lib/util/index.js +67 -54
  52. package/lib/util/parse-url.js +11 -9
  53. package/lib/util/patch.js +2 -6
  54. package/lib/util/speed-transform.js +17 -6
  55. package/lib/util/whistle-transform.js +18 -7
  56. package/package.json +10 -7
@@ -1,11 +1,12 @@
1
1
  var Transform = require('pipestream').Transform;
2
- var util = require('util');
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
- util.inherits(WhistleTransform, Transform);
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
- WhistleTransform.prototype.allowInject = function (chunk) {
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
- WhistleTransform.prototype._transform = function (chunk, encoding, callback) {
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
- setTimeout(function () {
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 ? setTimeout(cb, self._delay) : cb();
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.5",
4
+ "version": "2.10.7",
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
- "fiddler",
20
- "charles",
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
- "hosts",
24
- "debug",
25
- "mock"
26
+ "mitm",
27
+ "fiddler-alternative",
28
+ "charles-alternative"
26
29
  ],
27
30
  "bin": {
28
31
  "whistle": "./bin/whistle.js",