whistle 2.9.45 → 2.9.46

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/README.md CHANGED
@@ -7,7 +7,6 @@
7
7
  # whistle
8
8
  [![NPM version](https://img.shields.io/npm/v/whistle.svg?style=flat-square)](https://npmjs.org/package/whistle)
9
9
  [![node version](https://img.shields.io/badge/node.js-%3E=_8-green.svg?style=flat-square)](http://nodejs.org/download/)
10
- [![build status](https://img.shields.io/travis/avwo/whistle.svg?style=flat-square)](https://travis-ci.org/avwo/whistle)
11
10
  [![Test coverage](https://codecov.io/gh/avwo/whistle/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/avwo/whistle)
12
11
  [![npm download](https://img.shields.io/npm/dm/whistle.svg?style=flat-square)](https://npmjs.org/package/whistle)
13
12
  [![NPM count](https://img.shields.io/npm/dt/whistle.svg?style=flat-square)](https://www.npmjs.com/package/whistle)
@@ -70,6 +69,10 @@ Whistle 是基于 Node 实现的跨平台抓包调试工具,其主要特点:
70
69
  ### 详细用法参见:[Whistle 帮助文档](https://wproxy.org/whistle/quickstart.html)
71
70
 
72
71
  # 通过 SwitchyOmega 设置代理
72
+ ### 安装 SwitchyOmega
73
+ 打开 Chrome 扩展商店进行安装 https://chrome.google.com/webstore/detail/proxy-switchyomega/padekgcemlokbadohgkifijomclgjgif
74
+
75
+ ### 配置 SwitchyOmega
73
76
  全局代理如果会影响到某些客户端的请求(客户端设置了 ssl pinning),也可以使用 Chrome 插件设置代理(只对 Chrome 生效):
74
77
  > 可以通过 `w2 proxy off` 关闭全局代理
75
78
 
package/assets/tab.html CHANGED
@@ -282,6 +282,7 @@
282
282
  });
283
283
  getActiveSession = options.getActiveSession;
284
284
  getSelectedSessionList = options.getSelectedSessionList;
285
+ whistleBridge.copyText = options.copyText;
285
286
  whistleBridge.pageId = options.pageId;
286
287
  whistleBridge.compose = options.compose;
287
288
  whistleBridge.decodeBase64 = options.decodeBase64;
@@ -5,6 +5,7 @@ var mime = require('mime');
5
5
  var qs = require('querystring');
6
6
  var Buffer = require('safe-buffer').Buffer;
7
7
  var PassThrough = require('stream').PassThrough;
8
+ var rulesMgr = require('../rules');
8
9
  var protoMgr = require('../rules/protocols');
9
10
  var pluginMgr = require('../plugins');
10
11
 
@@ -13,6 +14,8 @@ var RAW_FILE_RE = /rawfile/;
13
14
  var HEADERS_SEP_RE = /(\r?\n(?:\r\n|\r|\n)|\r\r\n?)/;
14
15
  var MAX_HEADERS_SIZE = 256 * 1024;
15
16
  var TPL_RE = /(?:dust|tpl|jsonp):$/;
17
+ var VAR_RE = /\{\S+\}/;
18
+ var QUERY_VAR_RE = /\$?(?:\{\{([\w$-]+)\}\}|\{([\w$-]+)\})/g;
16
19
 
17
20
  function isRawFileProtocol(protocol) {
18
21
  return RAW_FILE_RE.test(protocol);
@@ -283,18 +286,20 @@ module.exports = function (req, res, next) {
283
286
 
284
287
  function render(reader) {
285
288
  if (reader.body) {
286
- var data = qs.parse(util.getQueryString(req.fullUrl));
287
- if (Object.keys(data).length) {
288
- reader.body = reader.body.replace(
289
- /\{\{([\w\-$]+)\}\}|\$?\{([\w\-$]+)\}/g,
290
- function (all, matched1, matched2) {
291
- var value = data[matched1 || matched2];
292
- if (value === undefined) {
289
+ if (VAR_RE.test(reader.body)) {
290
+ var data = util.getQueryString(req.fullUrl);
291
+ data = data && qs.parse(data);
292
+ if (data) {
293
+ reader.body = reader.body.replace(QUERY_VAR_RE, function (all, matched1, matched2) {
294
+ if (all[0] === '$') {
293
295
  return all;
294
296
  }
295
- return util.getQueryValue(value);
297
+ var value = data[matched1 || matched2];
298
+ return value === undefined ? all : util.getQueryValue(value);
296
299
  }
297
- );
300
+ );
301
+ }
302
+ reader.body = rulesMgr.resolveTplVar(reader.body, req);
298
303
  }
299
304
  addLength(reader, Buffer.byteLength(reader.body));
300
305
  } else {
@@ -60,6 +60,7 @@ exports.resolveBodyFilter = rules.resolveBodyFilter.bind(rules);
60
60
  exports.lookupHost = rules.lookupHost.bind(rules);
61
61
  exports.resolveLocalRule = rules.resolveLocalRule.bind(rules);
62
62
  exports.clearAppend = rules.clearAppend.bind(rules);
63
+ exports.resolveTplVar = Rules.resolveTplVar;
63
64
 
64
65
  exports.disableDnsCache = function () {
65
66
  Rules.disableDnsCache();
@@ -729,17 +729,18 @@ function resolveTplVar(value, req) {
729
729
  });
730
730
  }
731
731
 
732
+ Rules.resolveTplVar = resolveTplVar;
733
+
732
734
  function renderTpl(rule, req) {
733
735
  var matcher = rule.matcher;
734
736
  if (rule.isTpl === false) {
735
737
  return matcher;
736
738
  }
737
739
  rule.isTpl = false;
738
- matcher = matcher.replace(TPL_RE, function (_, proto, value) {
740
+ return matcher.replace(TPL_RE, function (_, proto, value) {
739
741
  rule.isTpl = true;
740
742
  return (proto || '') + resolveTplVar(value.slice(1, -1), req);
741
743
  });
742
- return matcher;
743
744
  }
744
745
 
745
746
  function resolveVar(rule, vals, req) {
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.9.45",
4
+ "version": "2.9.46",
5
5
  "dataDirname": ".whistle",
6
6
  "localUIHost": "local.whistlejs.com",
7
7
  "port": 8899,