Skip to content

Commit 820fad2

Browse files
committed
Merge commit 'e6880711061d6b399d1e777b51a2b510bd552694'
2 parents eb5b14a + e688071 commit 820fad2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+2758
-1721
lines changed

vendor/whistle/CHANGELOG.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,66 @@
1+
# v2.9.86
2+
1. feat: JSON View 右键菜单 `Inspect Value` 查看当前 key 对应的 Value 对象
3+
2. feat: JSON Dialog 添加前进和后退键查看历史记录
4+
3. feat: 通过 Whistle 构造的请求会在 Network 的 Order 里面加特殊标识
5+
6+
# v2.9.85
7+
1. feat: 支持显示 sse 内容(默认只对非 gzip 及 content-length 头小于 2m 的请求生效,其它类型请求可以通过 `enable://captureStream` 强制开启)
8+
2. fix: https://github.com/avwo/whistle-client/issues/60
9+
3. fix: https://github.com/avwo/whistle/issues/1145
10+
11+
# v2.9.84
12+
1. feat: 证书默认格式改成 cer 以适配更多机型(涉及:短链接,二维码,点击下载)
13+
2. fix: 某些浏览器没有发送 `sec-fetch-site` 导致内部请求误判为跨域请求问题
14+
15+
# v2.9.83
16+
1. fix: https://github.com/nodejs/node/issues/52681
17+
2. fix: https://github.com/avwo/whistle/issues/1137
18+
3. feat: 新增参数 `--allowOrigin` 用于设置允许哪些第三方页面访问 Whistle 的内部接口
19+
4. feat: 插件的 rules.txt 文件支持引入 3 个远程规则 `@path`,之前版本只支持1个
20+
21+
# v2.9.82
22+
1. feat: Overview、Inpsectors 支持自定义右键菜单
23+
2. feat: 支持通过 `-M` `dnsResolve``dnsResolve4``dnsResolve6` 改 dns 方法
24+
3. refactor: 优化界面,`dns.lookup` 失败使用 `dns.resolve``dns.resolve6` 重试
25+
26+
# v2.9.81
27+
1. feat: 支持设置 URL 列不显示请求参数
28+
2. feat: 域名为 IP 的 HTTPS 请求不解包
29+
30+
# v2.9.80
31+
1. fix: 远程部署可能出现 `captureError` 问题
32+
2. feat: 优化界面
33+
34+
# v2.9.79
35+
1. feat: 优化 Dark 模式样式,并重新调整为默认不跟随系统的 Dark 模式
36+
2. feat: 根证书过期后,可以通过 `w2 ca` 更新根证书
37+
38+
# v2.9.78
39+
1. feat: 保留无法识别的 `accept-encoding` 请求头
40+
2. feat: Rules 里面的规则如果未发生改变,点击 Save 也可以启用规则
41+
3. feat: `statusCode://401` 默认会弹出输入用户名和密码的登录框,可以通过 `disable://userLogin``lineProps://disableUserLogin` 去掉登录框
42+
43+
# v2.9.77
44+
1. feat: `locationHref://url``redirect://url` 自动去重
45+
2. feat: 支持通过 `jsPrepend://` 设置 `window.__WHISTLE_PATH_PREFIX__ = '/path/to';`(可以配置规则或集成在插件) 修改 Whistle 内部路径 `/.whistle-path.5b6af7b9884e1165/` 改成 `${window.__WHISTLE_PATH_PREFIX__}/.whistle-path.5b6af7b9884e1165/`,方便通过 ngnix 转发(ngnix 可以把 `/path/to` 路径去掉再发送给 Whistle)
46+
47+
# v2.9.76
48+
1. refactor: 删除所有 q 模块,解决安装告警问题
49+
50+
# v2.9.75
51+
1. refactor: 优化 sse 请求的 `resReplace` 逻辑
52+
2. fix: 界面 `Enable HTTP/2` 报错问题
53+
3. feat: 新增 `locationHref://url``locationHref://js:url` 协议,相当于在 html 页面或 js 文件返回 `window.location.href = url`
54+
55+
# v2.9.74
56+
1.fix: https://github.com/avwo/whistle/issues/1098
57+
58+
# v2.9.73
59+
1. feat: 新增启动参数 `-M ipv4first|ipv6first` 用于设置 [dns.lookup的 options.order 参数](https://nodejs.org/docs/latest/api/dns.html#dnslookuphostname-options-callback)
60+
2. feat: `localhost` 的 dns.lookup 默认使用 `ipv4first`
61+
3. feat: Online 支持设置 `Verbatim``IPv4-first``IPv6-first`
62+
4. feat: 支持 `delete://query.xxx` 删除请求 url 里面的参数
63+
164
# v2.9.72
265
1. fix: socks 代理无法获取 clientIp 及 IPv6 转发问题
366

vendor/whistle/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[![Test coverage](https://codecov.io/gh/avwo/whistle/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/avwo/whistle)
1111
[![npm download](https://img.shields.io/npm/dm/whistle.svg?style=flat-square)](https://npmjs.org/package/whistle)
1212
[![NPM count](https://img.shields.io/npm/dt/whistle.svg?style=flat-square)](https://www.npmjs.com/package/whistle)
13-
[![License](https://img.shields.io/npm/l/whistle.svg?style=flat-square)](https://www.npmjs.com/package/whistle)
13+
[![License](https://img.shields.io/aur/license/whistle?style=flat-square)](https://www.npmjs.com/package/whistle)
1414

1515
**Mac 或 Windows 系统推荐使用客户端版本:https://github.com/avwo/whistle-client**
1616

@@ -29,7 +29,8 @@ Whistle 是基于 Node 实现的跨平台抓包调试工具,其主要特点:
2929
* 项目可以自带代理规则配置并一键设置到本地 Whistle 代理,也可以通过定制插件简化操作
3030

3131
# 一键安装
32-
> 已安装 `brew` 的 PC,可以省略以下 1、2 步骤,直接通过以下方式一键安装:`brew install whistle && w2 start --init`(arm64 平台尝试用 `brew install node && npm i -g whistle && w2 start --init`
32+
> 已安装 `brew` 的 PC,可以省略以下 1、2 步骤,直接通过以下方式一键安装:`brew install whistle && w2 start --init`
33+
3334
1. 安装 Node(建议安装**最新的 LTS 版本**,如已安装忽略此步骤):https://nodejs.org/
3435
2. 一键安装,在命令行执行以下命令:
3536
``` sh

vendor/whistle/assets/js/log.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,22 @@
220220

221221
return obj === undefined ? 'undefined' : obj;
222222
}
223+
var prefixPath;
224+
function getPathPrefix() {
225+
if (prefixPath) {
226+
return prefixPath;
227+
}
228+
prefixPath = window.__WHISTLE_PATH_PREFIX__;
229+
if (/^\/[\w./-]+$/.test(prefixPath) && prefixPath.length <= 128) {
230+
var len = prefixPath.length - 1;
231+
if (prefixPath[len] === '/') {
232+
prefixPath = prefixPath.substring(0, len);
233+
}
234+
} else {
235+
prefixPath = '';
236+
}
237+
return prefixPath;
238+
}
223239

224240
var index = 0;
225241
var MAX_LEN = 1024 * 56;
@@ -237,7 +253,8 @@
237253
logStr = logStr.substring(0, percIndex);
238254
}
239255
}
240-
img.src ='$LOG_CGI?id=$LOG_ID&level=' + level + '&text=' + logStr
256+
var baseUrl = '$BASE_URL' + getPathPrefix();
257+
img.src = baseUrl + '$LOG_CGI?id=$LOG_ID&level=' + level + '&text=' + logStr
241258
+ '&t=' + new Date().getTime() + '&' + ++index;
242259
var preventGC = function() {
243260
img.onload = img.onerror = null;

vendor/whistle/assets/js/weinre.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,22 @@
33
if (typeof window === 'undefined' || window.WeinreServerURL) {
44
return;
55
}
6-
window.WeinreServerURL = '$WEINRE_PATH';
6+
var prefixPath = window.__WHISTLE_PATH_PREFIX__;
7+
if (/^\/[\w./-]+$/.test(prefixPath) && prefixPath.length <= 128) {
8+
var len = prefixPath.length - 1;
9+
if (prefixPath[len] === '/') {
10+
prefixPath = prefixPath.substring(0, len);
11+
}
12+
} else {
13+
prefixPath = '';
14+
}
15+
var baseUrl = '$BASE_URL' + prefixPath;
16+
window.WeinreServerURL = baseUrl + '$WEINRE_PATH';
717
var head = document.head || document.getElementsByTagName('head')[0] || document.documentElement;
818
var script = document.createElement('script');
919
script.async = true;
1020
script.charset = 'utf8';
11-
script.src = '$WEINRE_URL';
21+
script.src = baseUrl + '$WEINRE_URL';
1222
if (head.firstChild) {
1323
head.insertBefore(script, head.firstChild);
1424
} else {

vendor/whistle/bin/ca/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module.exports = function(argv) {
8888
if (!options.addr) {
8989
var host = options.host || '127.0.0.1';
9090
var port = options.port || util.getDefaultPort();
91-
options.addr = { url: 'http://' + host + ':' + port + '/cgi-bin/rootca' };
91+
options.addr = { url: 'http://' + util.joinIpPort(host, + port) + '/cgi-bin/rootca' };
9292
}
9393
install(options.addr);
9494
};

vendor/whistle/bin/plugin.js

100755100644
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
var os = require('os');
21
var cp = require('child_process');
32
var fs = require('fs');
43
var path = require('path');
@@ -39,6 +38,13 @@ function getTempName(name) {
3938
return name.join('/');
4039
}
4140

41+
function formatCmdOpions(options) {
42+
if (CMD_SUFFIX) {
43+
options.shell = true;
44+
}
45+
return options;
46+
}
47+
4248
function getInstallDir(argv) {
4349
argv = argv.slice();
4450
var result = { argv: argv };
@@ -87,10 +93,10 @@ function install(cmd, name, argv, ver, pluginsCache, callback) {
8793
fs.writeFileSync(path.join(installPath, 'README.md'), RESP_URL);
8894
argv.unshift('install', name);
8995
pluginsCache[pkgName] = 1;
90-
cp.spawn(cmd, argv, {
96+
cp.spawn(cmd, argv, formatCmdOpions({
9197
stdio: 'inherit',
9298
cwd: installPath
93-
}).once('exit', function(code) {
99+
})).once('exit', function(code) {
94100
if (code) {
95101
removeDir(installPath);
96102
callback();
@@ -248,10 +254,10 @@ exports.run = function(cmd, argv) {
248254
}
249255
});
250256
process.env.PATH && newPath.push(process.env.PATH);
251-
newPath = newPath.join(os.platform() === 'win32' ? ';' : ':');
257+
newPath = newPath.join(CMD_SUFFIX ? ';' : ':');
252258
process.env.PATH = newPath;
253-
cp.spawn(cmd + CMD_SUFFIX, argv, {
259+
cp.spawn(cmd + CMD_SUFFIX, argv, formatCmdOpions({
254260
stdio: 'inherit',
255261
env: process.env
256-
});
262+
}));
257263
};

vendor/whistle/bin/proxy.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ function showError(msg) {
2222

2323
function enableProxy(options) {
2424
try {
25+
var host = util.joinIpPort(options.host, options.port);
2526
if (proxy.enableProxy(options)) {
26-
showInfo('Setting global proxy (' + options.host + ':' + options.port + ') successful.');
27+
showInfo('Setting global proxy (' + host + ') successful.');
2728
} else {
28-
showError('Failed to set global proxy (' + options.host + ':' + options.port + ').');
29+
showError('Failed to set global proxy (' + host + ').');
2930
}
3031
} catch (e) {
3132
showError(e.message);

vendor/whistle/bin/status.js

100755100644
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
var Q = require('q');
2-
31
var util = require('./util');
42
var pkg = require('../package.json');
53
var colors = require('colors/safe');
@@ -12,13 +10,13 @@ var info = util.info;
1210

1311
function showAll(byStop) {
1412
var list = readConfigList().map(function(config) {
15-
var deferred = Q.defer();
16-
isRunning(config.pid, function(running) {
17-
deferred.resolve(running && config);
13+
return new Promise(function(resolve) {
14+
isRunning(config.pid, function(running) {
15+
resolve(running && config);
16+
});
1817
});
19-
return deferred.promise;
2018
});
21-
Q.all(list).then(function(confList) {
19+
Promise.all(list).then(function(confList) {
2220
confList = confList.filter(function(conf) {
2321
return conf;
2422
});

vendor/whistle/bin/use.js

100755100644
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function getBody(res, callback) {
7878
var reqOptions;
7979
function request(body, callback) {
8080
if (!reqOptions) {
81-
reqOptions = url.parse('http://' + (options.host || '127.0.0.1') + ':' + options.port + '/cgi-bin/rules/project');
81+
reqOptions = url.parse('http://' + util.joinIpPort(options.host || '127.0.0.1', options.port) + '/cgi-bin/rules/project');
8282
reqOptions.headers = {
8383
'content-type': 'application/x-www-form-urlencoded'
8484
};
@@ -193,7 +193,7 @@ module.exports = function(filepath, storage, force, isClient) {
193193
'groupName=' + encodeURIComponent(groupName.trim())
194194
].join('&');
195195
request(body, function() {
196-
info('Setting whistle' + (isClient ? ' client' : '') + ' (' + (options.host || '127.0.0.1') + ':' + port + ') rules successful.');
196+
info('Setting whistle' + (isClient ? ' client' : '') + ' (' + util.joinIpPort(options.host || '127.0.0.1', port) + ') rules successful.');
197197
});
198198
};
199199
if (force) {

vendor/whistle/bin/util.js

100755100644
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ var os = require('os');
55
var fs = require('fs');
66
var fse = require('fs-extra2');
77
var config = require('../lib/config');
8+
var common = require('../lib/util/common');
89
var colors = require('colors/safe');
910
var path = require('path');
1011
var createHmac = require('crypto').createHmac;
1112

13+
var joinIpPort = common.joinIpPort;
14+
15+
exports.joinIpPort = joinIpPort;
1216
/*eslint no-console: "off"*/
1317
var CHECK_RUNNING_CMD = process.platform === 'win32' ?
1418
'tasklist /fi "PID eq %s" | findstr /i "node.exe"'
@@ -24,6 +28,7 @@ function isRunning(pid, callback) {
2428

2529
exports.isRunning = isRunning;
2630

31+
2732
function getIpList() {
2833
var ipList = [];
2934
var ifaces = os.networkInterfaces();
@@ -64,10 +69,6 @@ function showKillError() {
6469

6570
exports.showKillError = showKillError;
6671

67-
function getIpHost(ip) {
68-
return ip.indexOf(':') === -1 ? ip : '[' + ip + ']';
69-
}
70-
7172
function showUsage(isRunning, options, restart) {
7273
options = formatOptions(options);
7374
if (isRunning) {
@@ -83,7 +84,7 @@ function showUsage(isRunning, options, restart) {
8384
var list = options.host && typeof options.host === 'string' ? [options.host] : getIpList();
8485
info('[i] 1. use your device to visit the following URL list, gets the ' + colors.bold('IP') + ' of the URL you can access:');
8586
info(list.map(function(ip) {
86-
return ' http://' + colors.bold(getIpHost(ip)) + (port && port != 80 ? ':' + port : '') + '/';
87+
return ' http://' + colors.bold(joinIpPort(ip, port != 80 && port)) + '/';
8788
}).join('\n'));
8889

8990
warn(' Note: If all the above URLs are unable to access, check the firewall settings');

0 commit comments

Comments
 (0)