whistle 2.9.21 → 2.9.25

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
@@ -28,6 +28,7 @@ Whistle 是基于 Node 实现的跨平台抓包调试工具,其主要特点:
28
28
  * 项目可以自带代理规则配置并一键设置到本地 Whistle 代理,也可以通过定制插件简化操作
29
29
 
30
30
  # 一键安装
31
+ > 已安装 `brew` 的 PC,可以省略以下 1、2 步骤,直接通过以下方式一键安装:`brew install whistle && w2 start --init`(arm64 平台尝试用 `brew install node && npm i -g whistle && w2 start --init`)
31
32
  1. 安装 Node(建议安装**最新的 LTS 版本**,如已安装忽略此步骤):https://nodejs.org/
32
33
  2. 一键安装,在命令行执行以下命令:
33
34
  ``` sh
@@ -36,9 +37,10 @@ Whistle 是基于 Node 实现的跨平台抓包调试工具,其主要特点:
36
37
  > 上述命令会先全局安装 Whistle 的 npm 包后,启动 Whistle 并设置系统全局代理,以及安装系统根证书,目前一键安装只支持 Mac & Windows 系统,其它系统按照下面 **手动安装** 的方式操作。
37
38
  3. 一键安装过程中注意事项:
38
39
  * Mac 需要两次输入开机密码或指纹验证
39
-
40
- <img alt="输入开机密码" width="236" src="https://user-images.githubusercontent.com/11450939/168847149-c0765e81-2ce4-4ed4-b7d3-a958d8c0cf08.png">
41
- <img alt="输入指纹" width="300" src="https://user-images.githubusercontent.com/11450939/168847123-e66845d0-6002-4f24-874f-b6943f7f376b.png">
40
+ <p>
41
+ <img alt="输入开机密码" width="330" src="https://user-images.githubusercontent.com/11450939/176977027-4a7b06a0-64f6-4580-b983-312515e9cd4e.png">
42
+ </p>
43
+ <img alt="输入指纹" width="330" src="https://user-images.githubusercontent.com/11450939/168847123-e66845d0-6002-4f24-874f-b6943f7f376b.png">
42
44
 
43
45
  * Windows 需要最后点击 “是(Y)” 确认
44
46
 
@@ -65,5 +67,17 @@ Whistle 是基于 Node 实现的跨平台抓包调试工具,其主要特点:
65
67
 
66
68
  ### 详细用法参见:[Whistle 帮助文档](https://wproxy.org/whistle/quickstart.html)
67
69
 
70
+ # 通过 SwitchyOmega 设置代理
71
+ 全局代理如果会影响到某些客户端的请求(客户端设置了 ssl pinning),也可以使用 Chrome 插件设置代理(只对 Chrome 生效):
72
+ > 可以通过 `w2 proxy off` 关闭全局代理
73
+
74
+ 1. 设置 Whistle 代理
75
+
76
+ <img src="https://user-images.githubusercontent.com/11450939/36636618-132bb09e-1a05-11e8-8514-813fd34a5454.png" width="800" />
77
+ 2. 选择 Whistle 代理
78
+
79
+ <img width="180" alt="image" src="https://user-images.githubusercontent.com/11450939/173984519-143615b2-2a99-4486-a22a-fec71fe00423.png">
80
+
81
+
68
82
  # License
69
83
  [MIT](./LICENSE)
@@ -1,6 +1,6 @@
1
1
  var net = require('net');
2
- var proxy = require('./index');
3
- var util = require('../util');
2
+ var proxy = require('set-global-proxy');
3
+ var util = require('./util');
4
4
 
5
5
  var OFF_RE = /^(?:o|0|-{0,2}off)$/i;
6
6
  var BYPASS_RE = /^(?:-{0,2}bypass|-x|-b)$/i;
@@ -8,34 +8,47 @@ var NUM_RE = /^\d+$/;
8
8
  var HOST_SUFFIX_RE = /\:(\d+|auto)?$/;
9
9
  var HOST_RE = /^[a-z\d_-]+(?:\.[a-z\d_-]+)*$/i;
10
10
 
11
+ function showInfo(msg) {
12
+ process.nextTick(function() {
13
+ util.info(msg);
14
+ });
15
+ }
16
+
17
+ function showError(msg) {
18
+ process.nextTick(function() {
19
+ util.error(msg);
20
+ });
21
+ }
22
+
11
23
  function enableProxy(options) {
12
24
  try {
13
25
  if (proxy.enableProxy(options)) {
14
- util.info('Setting global proxy (' + options.host + ':' + options.port + ') successful.');
26
+ showInfo('Setting global proxy (' + options.host + ':' + options.port + ') successful.');
15
27
  } else {
16
- util.error('Failed to set global proxy (' + options.host + ':' + options.port + ').');
28
+ showError('Failed to set global proxy (' + options.host + ':' + options.port + ').');
17
29
  }
18
30
  } catch (e) {
19
- util.error(e.message);
31
+ showError(e.message);
20
32
  }
21
33
  }
22
34
 
23
- function disableProxy() {
35
+ function disableProxy(sudo) {
24
36
  try {
25
- if (proxy.disableProxy()) {
26
- util.info('Turn off global proxy successful.');
37
+ if (proxy.disableProxy(sudo)) {
38
+ showInfo('Turn off global proxy successful.');
27
39
  } else {
28
- util.error('Failed to turn off global proxy.');
40
+ showError('Failed to turn off global proxy.');
29
41
  }
30
42
  } catch (e) {
31
- util.error(e.message);
43
+ showError(e.message);
32
44
  }
33
45
  }
34
46
 
35
47
  module.exports = function(argv) {
36
48
  var cmd = argv[0];
49
+ var sudo = argv.indexOf('--no-sudo') === -1;
37
50
  if (OFF_RE.test(cmd)) {
38
- return disableProxy();
51
+ return disableProxy(sudo);
39
52
  }
40
53
  var options = {};
41
54
  var skip;
@@ -72,5 +85,6 @@ module.exports = function(argv) {
72
85
  options.port = util.getDefaultPort();
73
86
  }
74
87
  options.host = options.host || '127.0.0.1';
88
+ options.sudo = sudo;
75
89
  enableProxy(options);
76
90
  };
package/bin/whistle.js CHANGED
@@ -7,7 +7,7 @@ var useRules = require('./use');
7
7
  var showStatus = require('./status');
8
8
  var util = require('./util');
9
9
  var plugin = require('./plugin');
10
- var setProxy = require('./proxy/cli');
10
+ var setProxy = require('./proxy');
11
11
  var installCA = require('./ca/cli');
12
12
 
13
13
  var error = util.error;
@@ -8,6 +8,6 @@
8
8
  </head>
9
9
  <body style="overscroll-behavior-x: none;">
10
10
  <div id="container" class="main"></div>
11
- <script src="js/index.js?v=2.9.21"></script>
11
+ <script src="js/index.js?v=2.9.22"></script>
12
12
  </body>
13
13
  </html>