whistle 2.9.97 → 2.9.98
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/assets/menu.html +7 -0
- package/assets/modal.html +7 -0
- package/assets/tab.html +7 -0
- package/bin/ca/cli.js +3 -3
- package/bin/ca/index.js +1 -1
- package/bin/proxy.js +4 -4
- package/bin/status.js +3 -3
- package/bin/use.js +8 -8
- package/bin/util.js +5 -5
- package/bin/whistle.js +49 -49
- package/biz/index.js +18 -0
- package/biz/webui/cgi-bin/status.js +1 -4
- package/biz/webui/htdocs/index.html +1 -1
- package/biz/webui/htdocs/js/index.js +43 -43
- package/biz/webui/lib/index.js +3 -0
- package/lib/config.js +0 -1
- package/lib/handlers/plugin-handler.js +1 -1
- package/lib/https/h2.js +2 -3
- package/lib/https/index.js +4 -6
- package/lib/init.js +4 -0
- package/lib/inspectors/data.js +9 -0
- package/lib/inspectors/res.js +5 -1
- package/lib/rules/dns.js +12 -18
- package/lib/rules/rules.js +11 -3
- package/lib/service/extract-saz.js +3 -0
- package/lib/service/generate-saz.js +3 -0
- package/lib/service/util.js +3 -3
- package/lib/upgrade.js +1 -0
- package/lib/util/common.js +2 -2
- package/lib/util/http-mgr.js +18 -1
- package/lib/util/index.js +12 -2
- package/package.json +1 -1
- package/biz/webui/htdocs/img/qrcode-cer.png +0 -0
- package/biz/webui/htdocs/img/qrcode-crt.png +0 -0
- package/biz/webui/htdocs/img/qrcode-pem.png +0 -0
package/assets/menu.html
CHANGED
|
@@ -204,6 +204,13 @@
|
|
|
204
204
|
whistleBridge.setComposerData = options.setComposerData;
|
|
205
205
|
whistleBridge.showHttpsSettings = options.showHttpsSettings;
|
|
206
206
|
whistleBridge.showCustomCerts = options.showCustomCerts;
|
|
207
|
+
whistleBridge.showService = options.showService;
|
|
208
|
+
whistleBridge.hideService = options.hideService;
|
|
209
|
+
whistleBridge.showInstallPlugins = options.showInstallPlugins;
|
|
210
|
+
whistleBridge.showUpdatePlugins = options.showUpdatePlugins;
|
|
211
|
+
whistleBridge.readFileAsText = options.readFileAsText;
|
|
212
|
+
whistleBridge.readFileAsBase64 = options.readFileAsBase64;
|
|
213
|
+
whistleBridge.getVersion = options.getVersion;
|
|
207
214
|
whistleBridge.request = options.request;
|
|
208
215
|
whistleBridge.createRequest = options.createRequest;
|
|
209
216
|
whistleBridge.parseRules = options.parseRules;
|
package/assets/modal.html
CHANGED
|
@@ -27,6 +27,13 @@
|
|
|
27
27
|
whistleBridge.setComposerData = options.setComposerData;
|
|
28
28
|
whistleBridge.showHttpsSettings = options.showHttpsSettings;
|
|
29
29
|
whistleBridge.showCustomCerts = options.showCustomCerts;
|
|
30
|
+
whistleBridge.showService = options.showService;
|
|
31
|
+
whistleBridge.hideService = options.hideService;
|
|
32
|
+
whistleBridge.showInstallPlugins = options.showInstallPlugins;
|
|
33
|
+
whistleBridge.showUpdatePlugins = options.showUpdatePlugins;
|
|
34
|
+
whistleBridge.readFileAsText = options.readFileAsText;
|
|
35
|
+
whistleBridge.readFileAsBase64 = options.readFileAsBase64;
|
|
36
|
+
whistleBridge.getVersion = options.getVersion;
|
|
30
37
|
whistleBridge.request = options.request;
|
|
31
38
|
whistleBridge.createRequest = options.createRequest;
|
|
32
39
|
whistleBridge.parseRules = options.parseRules;
|
package/assets/tab.html
CHANGED
|
@@ -297,6 +297,13 @@
|
|
|
297
297
|
whistleBridge.setComposerData = options.setComposerData;
|
|
298
298
|
whistleBridge.showHttpsSettings = options.showHttpsSettings;
|
|
299
299
|
whistleBridge.showCustomCerts = options.showCustomCerts;
|
|
300
|
+
whistleBridge.showService = options.showService;
|
|
301
|
+
whistleBridge.hideService = options.hideService;
|
|
302
|
+
whistleBridge.showInstallPlugins = options.showInstallPlugins;
|
|
303
|
+
whistleBridge.showUpdatePlugins = options.showUpdatePlugins;
|
|
304
|
+
whistleBridge.readFileAsText = options.readFileAsText;
|
|
305
|
+
whistleBridge.readFileAsBase64 = options.readFileAsBase64;
|
|
306
|
+
whistleBridge.getVersion = options.getVersion;
|
|
300
307
|
whistleBridge.request = options.request;
|
|
301
308
|
whistleBridge.createRequest = options.createRequest;
|
|
302
309
|
whistleBridge.parseRules = options.parseRules;
|
package/bin/ca/cli.js
CHANGED
|
@@ -16,9 +16,9 @@ var MAX_LEN = 1024 * 1024;
|
|
|
16
16
|
function installCert(certFile, url) {
|
|
17
17
|
try {
|
|
18
18
|
installRootCA(fileMgr.convertSlash(certFile));
|
|
19
|
-
util.info('
|
|
19
|
+
util.info('Successfully installed Root CA from (' + (url || certFile) + ').');
|
|
20
20
|
} catch (e) {
|
|
21
|
-
util.error(e.message);
|
|
21
|
+
util.error('Certificate installation failed: ' + e.message);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -39,7 +39,7 @@ function install(addr) {
|
|
|
39
39
|
return util.error('Bad response (' + res.statusCode + ').');
|
|
40
40
|
}
|
|
41
41
|
if (!body || !body.length) {
|
|
42
|
-
return util.error('
|
|
42
|
+
return util.error('Empty certificate content.');
|
|
43
43
|
}
|
|
44
44
|
var tempFile = path.join(commonUtil.getWhistlePath(), Date.now() + '-' + util.getHash(addr.url) + '.crt');
|
|
45
45
|
fs.writeFileSync(tempFile, body);
|
package/bin/ca/index.js
CHANGED
|
@@ -39,5 +39,5 @@ module.exports = function(certFile) {
|
|
|
39
39
|
if (platform === 'win32') {
|
|
40
40
|
return installWin(certFile);
|
|
41
41
|
}
|
|
42
|
-
throw new Error('Platform ' + platform + ' is unsupported
|
|
42
|
+
throw new Error('Platform ' + platform + ' is currently unsupported for Root CA installation.');
|
|
43
43
|
};
|
package/bin/proxy.js
CHANGED
|
@@ -24,9 +24,9 @@ function enableProxy(options) {
|
|
|
24
24
|
try {
|
|
25
25
|
var host = util.joinIpPort(options.host, options.port);
|
|
26
26
|
if (proxy.enableProxy(options)) {
|
|
27
|
-
showInfo('
|
|
27
|
+
showInfo('Successfully set system proxy (' + host + ').');
|
|
28
28
|
} else {
|
|
29
|
-
showError('Failed to set
|
|
29
|
+
showError('Failed to set system proxy (' + host + ').');
|
|
30
30
|
}
|
|
31
31
|
} catch (e) {
|
|
32
32
|
showError(e.message);
|
|
@@ -36,9 +36,9 @@ function enableProxy(options) {
|
|
|
36
36
|
function disableProxy(sudo) {
|
|
37
37
|
try {
|
|
38
38
|
if (proxy.disableProxy(sudo)) {
|
|
39
|
-
showInfo('
|
|
39
|
+
showInfo('Successfully disabled system proxy.');
|
|
40
40
|
} else {
|
|
41
|
-
showError('Failed to
|
|
41
|
+
showError('Failed to disable system proxy.');
|
|
42
42
|
}
|
|
43
43
|
} catch (e) {
|
|
44
44
|
showError(e.message);
|
package/bin/status.js
CHANGED
|
@@ -22,9 +22,9 @@ function showAll(byStop) {
|
|
|
22
22
|
});
|
|
23
23
|
var len = confList.length;
|
|
24
24
|
if (!len) {
|
|
25
|
-
warn('[!] No running
|
|
25
|
+
warn('[!] No running Whistle instances.');
|
|
26
26
|
} else {
|
|
27
|
-
var tips = ['[i] All running
|
|
27
|
+
var tips = ['[i] All running Whistle instances:'];
|
|
28
28
|
confList.forEach(function(conf, i) {
|
|
29
29
|
++i;
|
|
30
30
|
var options = conf.options;
|
|
@@ -34,7 +34,7 @@ function showAll(byStop) {
|
|
|
34
34
|
+ (options.storage ? ', Storage: ' + options.storage : '')
|
|
35
35
|
+ (byStop ? colors.red(' (Stop cmd: ' + (options.storage ? 'w2 stop -S ' + options.storage : 'w2 stop') + ')') : ''));
|
|
36
36
|
});
|
|
37
|
-
byStop && warn('[!] This
|
|
37
|
+
byStop && warn('[!] This Whistle instance is not running.');
|
|
38
38
|
info(tips.join('\n'));
|
|
39
39
|
}
|
|
40
40
|
});
|
package/bin/use.js
CHANGED
|
@@ -19,9 +19,9 @@ var options;
|
|
|
19
19
|
|
|
20
20
|
function showStartWhistleTips(storage, isClient) {
|
|
21
21
|
if (isClient) {
|
|
22
|
-
error('No running
|
|
22
|
+
error('No running Whistle client. Please install and start the latest Whistle client: https://github.com/avwo/whistle-client');
|
|
23
23
|
} else {
|
|
24
|
-
error('No running
|
|
24
|
+
error('No running Whistle instances. Execute `w2 start' + (storage ? ' -S ' + storage : '') + '` to start Whistle on the cli.');
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -172,17 +172,17 @@ module.exports = function(filepath, storage, force, isClient) {
|
|
|
172
172
|
}
|
|
173
173
|
handleRules(filepath, function(result) {
|
|
174
174
|
if (!result) {
|
|
175
|
-
error('The name and rules
|
|
175
|
+
error('The name and rules are required.');
|
|
176
176
|
return;
|
|
177
177
|
}
|
|
178
178
|
var name = getString(result.name);
|
|
179
179
|
if (!name || name.length > 64) {
|
|
180
|
-
error('The name
|
|
180
|
+
error('The name must be 1-64 characters.');
|
|
181
181
|
return;
|
|
182
182
|
}
|
|
183
183
|
var rules = getString(result.rules);
|
|
184
184
|
if (rules.length > MAX_RULES_LEN) {
|
|
185
|
-
error('
|
|
185
|
+
error('Maximum rules size: 256KB.');
|
|
186
186
|
return;
|
|
187
187
|
}
|
|
188
188
|
var groupName = getString(result.groupName) || getString(result.group);
|
|
@@ -193,7 +193,7 @@ module.exports = function(filepath, storage, force, isClient) {
|
|
|
193
193
|
'groupName=' + encodeURIComponent(groupName.trim())
|
|
194
194
|
].join('&');
|
|
195
195
|
request(body, function() {
|
|
196
|
-
info('
|
|
196
|
+
info('Successfully configured rules for Whistle' + (isClient ? ' client' : '') + ' (' + util.joinIpPort(options.host || '127.0.0.1', port) + ').');
|
|
197
197
|
});
|
|
198
198
|
};
|
|
199
199
|
if (force) {
|
|
@@ -202,7 +202,7 @@ module.exports = function(filepath, storage, force, isClient) {
|
|
|
202
202
|
request('name=' + encodeURIComponent(name) + '&enable=1&top=1', function(data) {
|
|
203
203
|
if (data.rules) {
|
|
204
204
|
info('Successfully enabled.');
|
|
205
|
-
warn('Warning:
|
|
205
|
+
warn('Warning: Rule already exists. Use \'--force\' to override.');
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
208
|
setRules();
|
|
@@ -210,4 +210,4 @@ module.exports = function(filepath, storage, force, isClient) {
|
|
|
210
210
|
}, port);
|
|
211
211
|
});
|
|
212
212
|
});
|
|
213
|
-
};
|
|
213
|
+
};
|
package/bin/util.js
CHANGED
|
@@ -14,13 +14,13 @@ var joinIpPort = common.joinIpPort;
|
|
|
14
14
|
|
|
15
15
|
exports.joinIpPort = joinIpPort;
|
|
16
16
|
/*eslint no-console: "off"*/
|
|
17
|
-
var CHECK_RUNNING_CMD = process.platform === 'win32' ?
|
|
17
|
+
var CHECK_RUNNING_CMD = process.platform === 'win32' ?
|
|
18
18
|
'tasklist /fi "PID eq %s" | findstr /i "node.exe"'
|
|
19
19
|
: 'ps -f -p %s | grep "node"';
|
|
20
20
|
var isWin = process.platform === 'win32';
|
|
21
21
|
|
|
22
22
|
function isRunning(pid, callback) {
|
|
23
|
-
pid ? cp.exec(util.format(CHECK_RUNNING_CMD, pid),
|
|
23
|
+
pid ? cp.exec(util.format(CHECK_RUNNING_CMD, pid),
|
|
24
24
|
function (err, stdout, stderr) {
|
|
25
25
|
callback(!err && !!stdout.toString().trim());
|
|
26
26
|
}) : callback();
|
|
@@ -64,7 +64,7 @@ exports.info = info;
|
|
|
64
64
|
|
|
65
65
|
function showKillError() {
|
|
66
66
|
error('[!] Cannot kill ' + config.name + ' owned by root');
|
|
67
|
-
info('[i] Try to run command ' + (isWin ? 'as an administrator' : 'with
|
|
67
|
+
info('[i] Try to run command ' + (isWin ? 'as an administrator' : 'with sudo'));
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
exports.showKillError = showKillError;
|
|
@@ -87,13 +87,13 @@ function showUsage(isRunning, options, restart) {
|
|
|
87
87
|
return ' http://' + colors.bold(joinIpPort(ip, port != 80 && port)) + '/';
|
|
88
88
|
}).join('\n'));
|
|
89
89
|
|
|
90
|
-
warn(' Note: If all
|
|
90
|
+
warn(' Note: If all URLs are inaccessible, check firewall settings');
|
|
91
91
|
warn(' For help see ' + colors.bold('https://github.com/avwo/whistle'));
|
|
92
92
|
info('[i] 2. set the HTTP proxy on your device with ' + colors.bold((list.length === 1 ? 'IP(' + list[0] + ')' : 'the above IP') + ' & PORT(' + port + ')'));
|
|
93
93
|
info('[i] 3. use ' + colors.bold('Chrome') + ' to visit ' + colors.bold('http://' + (options.localUIHost || config.localUIHost) + '/') + ' to get started');
|
|
94
94
|
|
|
95
95
|
if (parseInt(process.version.slice(1), 10) < 6) {
|
|
96
|
-
warn(colors.bold('\nWarning:
|
|
96
|
+
warn(colors.bold('\nWarning: Node version too low. Update at https://nodejs.org to capture HTTPS connections\n'));
|
|
97
97
|
}
|
|
98
98
|
var bypass = program.init;
|
|
99
99
|
if (bypass == null) {
|
package/bin/whistle.js
CHANGED
|
@@ -34,12 +34,12 @@ function showStartupInfo(err, options, debugMode, restart) {
|
|
|
34
34
|
if (/listen EADDRINUSE/.test(err)) {
|
|
35
35
|
options = util.formatOptions(options);
|
|
36
36
|
var port = options.port || config.port;
|
|
37
|
-
error('[!] Failed to bind proxy port ' + (options.host ? util.joinIpPort(options.host, port) : port) + ':
|
|
38
|
-
info('[i]
|
|
39
|
-
info(' or
|
|
37
|
+
error('[!] Failed to bind proxy port ' + (options.host ? util.joinIpPort(options.host, port) : port) + ': Port already in use');
|
|
38
|
+
info('[i] ' + config.name + ' may already be running. Try: ' + (debugMode ? 'w2 stop' : 'w2 restart') + ' to ' + (debugMode ? 'stop' : 'restart') + ' the ' + config.name);
|
|
39
|
+
info(' or use a different port with: ' + (debugMode ? '`w2 run -p newPort`\n' : '`w2 start -p newPort`\n'));
|
|
40
40
|
} else if (err.code == 'EACCES' || err.code == 'EPERM') {
|
|
41
|
-
error('[!] Cannot start ' + config.name + '
|
|
42
|
-
info('[i] Try
|
|
41
|
+
error('[!] Permission denied: Cannot start ' + config.name + ' as root');
|
|
42
|
+
info('[i] Try running with sudo\n');
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
error(err.stack ? 'Date: ' + new Date().toLocaleString() + '\n' + err.stack : err);
|
|
@@ -55,9 +55,9 @@ program.setConfig({
|
|
|
55
55
|
main: function(options) {
|
|
56
56
|
var cmd = process.argv[2];
|
|
57
57
|
if ((cmd === 'start' || cmd === 'restart') && (options.inspect || options.inspectBrk)) {
|
|
58
|
-
error('[!]
|
|
58
|
+
error('[!] Inspector mode only supported with `w2 run` command.');
|
|
59
59
|
var argv = Array.prototype.slice.call(process.argv, 3);
|
|
60
|
-
info('[i]
|
|
60
|
+
info('[i] Usage: w2 run' + (argv.length ? ' ' + argv.join(' ') : ''));
|
|
61
61
|
return process.exit(1);
|
|
62
62
|
}
|
|
63
63
|
var hash = options && options.storage && encodeURIComponent(options.storage);
|
|
@@ -94,58 +94,58 @@ program.setConfig({
|
|
|
94
94
|
|
|
95
95
|
program
|
|
96
96
|
.command('status')
|
|
97
|
-
.description('
|
|
97
|
+
.description('Display running status');
|
|
98
98
|
program
|
|
99
99
|
.command('add')
|
|
100
|
-
.description('Add rules from local
|
|
100
|
+
.description('Add rules from local JS file (.whistle.js by default)');
|
|
101
101
|
program.command('proxy')
|
|
102
|
-
.description('
|
|
102
|
+
.description('Configure system proxy settings');
|
|
103
103
|
program.command('ca')
|
|
104
|
-
.description('
|
|
104
|
+
.description('Manage Root CA certificates');
|
|
105
105
|
program.command('install')
|
|
106
|
-
.description('Install
|
|
106
|
+
.description('Install Whistle plugin');
|
|
107
107
|
program.command('uninstall')
|
|
108
|
-
.description('Uninstall
|
|
108
|
+
.description('Uninstall Whistle plugin');
|
|
109
109
|
program.command('exec')
|
|
110
|
-
.description('
|
|
110
|
+
.description('Execute plugin command');
|
|
111
111
|
|
|
112
112
|
program
|
|
113
|
-
.option('-D, --baseDir [baseDir]', 'set
|
|
114
|
-
.option('-z, --certDir [directory]', 'set custom certificate
|
|
115
|
-
.option('-l, --localUIHost [hostname]', 'set
|
|
116
|
-
.option('-L, --pluginHost [hostname]', 'set
|
|
117
|
-
.option('-n, --username [username]', 'set
|
|
118
|
-
.option('-w, --password [password]', 'set
|
|
119
|
-
.option('-N, --guestName [username]', 'set
|
|
120
|
-
.option('-W, --guestPassword [password]', 'set
|
|
121
|
-
.option('-s, --sockets [number]', 'set
|
|
122
|
-
.option('-S, --storage [newStorageDir]', 'set
|
|
123
|
-
.option('-C, --copy [storageDir]', 'copy
|
|
124
|
-
.option('-c, --dnsCache [time]', 'set
|
|
125
|
-
.option('-H, --host [boundHost]', 'set
|
|
126
|
-
.option('-p, --port [proxyPort]', 'set
|
|
127
|
-
.option('-P, --uiport [uiport]', 'set
|
|
128
|
-
.option('-m, --middlewares [script path or module name]', 'set
|
|
129
|
-
.option('-M, --mode [mode]', 'set
|
|
130
|
-
.option('-t, --timeout [ms]', 'set
|
|
131
|
-
.option('-e, --extra [extraData]', 'set
|
|
132
|
-
.option('-f, --secureFilter [secureFilter]', 'set
|
|
133
|
-
.option('-r, --shadowRules [shadowRules]', 'set
|
|
134
|
-
.option('-R, --reqCacheSize [reqCacheSize]', 'set
|
|
135
|
-
.option('-F, --frameCacheSize [frameCacheSize]', 'set
|
|
113
|
+
.option('-D, --baseDir [baseDir]', 'set storage root path', String, undefined)
|
|
114
|
+
.option('-z, --certDir [directory]', 'set custom certificate directory', String, undefined)
|
|
115
|
+
.option('-l, --localUIHost [hostname]', 'set web UI domain (' + config.localUIHost + ' by default)', String, undefined)
|
|
116
|
+
.option('-L, --pluginHost [hostname]', 'set plugin UI domains (as: "script=a.b.com&vase=x.y.com")', String, undefined)
|
|
117
|
+
.option('-n, --username [username]', 'set web UI username', String, undefined)
|
|
118
|
+
.option('-w, --password [password]', 'set web UI password', String, undefined)
|
|
119
|
+
.option('-N, --guestName [username]', 'set web UI guest username (read-only)', String, undefined)
|
|
120
|
+
.option('-W, --guestPassword [password]', 'set web UI guest password (read-only)', String, undefined)
|
|
121
|
+
.option('-s, --sockets [number]', 'set max cached connections per domain (' + config.sockets + ' by default)', parseInt, undefined)
|
|
122
|
+
.option('-S, --storage [newStorageDir]', 'set configuration storage directory', String, undefined)
|
|
123
|
+
.option('-C, --copy [storageDir]', 'copy configuration from specified directory', String, undefined)
|
|
124
|
+
.option('-c, --dnsCache [time]', 'set DNS cache time (default: 60000ms)', String, undefined)
|
|
125
|
+
.option('-H, --host [boundHost]', 'set bound host (default: INADDR_ANY)', String, undefined)
|
|
126
|
+
.option('-p, --port [proxyPort]', 'set proxy port (default: ' + config.port + ' by default)', String, undefined)
|
|
127
|
+
.option('-P, --uiport [uiport]', 'set web UI port', String, undefined)
|
|
128
|
+
.option('-m, --middlewares [script path or module name]', 'set startup middlewares (format: xx,yy/zz.js)', String, undefined)
|
|
129
|
+
.option('-M, --mode [mode]', 'set startup mode (options: pureProxy|debug|multiEnv|capture|disableH2|network|rules|plugins|prod)', String, undefined)
|
|
130
|
+
.option('-t, --timeout [ms]', 'set request timeout (default: ' + config.timeout, parseInt, undefined)
|
|
131
|
+
.option('-e, --extra [extraData]', 'set plugin extra parameters', String, undefined)
|
|
132
|
+
.option('-f, --secureFilter [secureFilter]', 'set secure filter path', String, undefined)
|
|
133
|
+
.option('-r, --shadowRules [shadowRules]', 'set default shadow rules', String, undefined)
|
|
134
|
+
.option('-R, --reqCacheSize [reqCacheSize]', 'set request data cache size (default: 600)', String, undefined)
|
|
135
|
+
.option('-F, --frameCacheSize [frameCacheSize]', 'set WebSocket frame cache size (default: 512)', String, undefined)
|
|
136
136
|
.option('-A, --addon [pluginPaths]', 'add custom plugin paths', String, undefined)
|
|
137
|
-
.option('--init [bypass]', 'auto
|
|
138
|
-
.option('--cluster [workers]', 'start
|
|
139
|
-
.option('--config [config]', 'load
|
|
140
|
-
.option('--dnsServer [dnsServer]', 'set custom
|
|
141
|
-
.option('--socksPort [socksPort]', 'set
|
|
142
|
-
.option('--httpPort [httpPort]', 'set
|
|
143
|
-
.option('--httpsPort [httpsPort]', 'set
|
|
144
|
-
.option('--allowOrigin [originList]', '
|
|
145
|
-
.option('--no-global-plugins', '
|
|
146
|
-
.option('--no-prev-options', '
|
|
147
|
-
.option('--inspect [[host:]port]', '
|
|
148
|
-
.option('--inspectBrk [[host:]port]', '
|
|
137
|
+
.option('--init [bypass]', 'auto configure proxy and install Root CA')
|
|
138
|
+
.option('--cluster [workers]', 'start cluster with worker count (default: CPU cores)', String, undefined)
|
|
139
|
+
.option('--config [config]', 'load startup config from file', String, undefined)
|
|
140
|
+
.option('--dnsServer [dnsServer]', 'set custom DNS servers', String, undefined)
|
|
141
|
+
.option('--socksPort [socksPort]', 'set SOCKSv5 server port', String, undefined)
|
|
142
|
+
.option('--httpPort [httpPort]', 'set HTTP server port', String, undefined)
|
|
143
|
+
.option('--httpsPort [httpsPort]', 'set HTTPS server port', String, undefined)
|
|
144
|
+
.option('--allowOrigin [originList]', 'set allowed CORS origins (format: a.b.c,x.y.z or *)', String, undefined)
|
|
145
|
+
.option('--no-global-plugins', 'disable global plugins')
|
|
146
|
+
.option('--no-prev-options', 'ignore previous options on restart')
|
|
147
|
+
.option('--inspect [[host:]port]', 'enable inspector (default: 127.0.0.1:9229)')
|
|
148
|
+
.option('--inspectBrk [[host:]port]', 'enable inspector with breakpoint (default: 127.0.0.1:9229)');
|
|
149
149
|
|
|
150
150
|
var argv = process.argv;
|
|
151
151
|
var cmd = argv[2];
|
package/biz/index.js
CHANGED
|
@@ -19,6 +19,7 @@ var CUSTOM_INTERNAL_APP = new RegExp('^/[\\w.-]*\\.whistle-path\\.5b6af7b9884e11
|
|
|
19
19
|
var CUSTOM_PLUGIN_RE = new RegExp('^/[\\w.-]*\\.whistle-path\\.5b6af7b9884e1165[\\w.-]*/+whistle\\.([a-z\\d_-]+)/');
|
|
20
20
|
var REAL_WEBUI_HOST_PARAM = /_whistleInternalHost_=(__([a-z\d.-]+)(?:__(\d{1,5}))?__)/;
|
|
21
21
|
var OUTER_PLUGIN_RE = /^(?:\/whistle)?\/((?:whistle|plugin)\.[a-z\\d_-]+)::(\d{1,5})\//;
|
|
22
|
+
var SERVICE_HOST = 'admin.wiso.pro';
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
function transformUI(req, res) {
|
|
@@ -28,6 +29,22 @@ function transformUI(req, res) {
|
|
|
28
29
|
return handleUIReq(req, res);
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
function setServiceUrl(req) {
|
|
33
|
+
var isService = req.path.indexOf('/whistle/service/') === 0;
|
|
34
|
+
if (isService || req.path.indexOf('/service/') === 0) {
|
|
35
|
+
if (isService) {
|
|
36
|
+
req.url = req.url.replace('/whistle/', '/');
|
|
37
|
+
}
|
|
38
|
+
req.headers.host = SERVICE_HOST;
|
|
39
|
+
req.headers[config.REAL_HOST_HEADER] = SERVICE_HOST;
|
|
40
|
+
req.isHttps = true;
|
|
41
|
+
req.isPluginReq = true;
|
|
42
|
+
req._isInternalReq = true;
|
|
43
|
+
req._isPureInternalReq = true;
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
31
48
|
module.exports = function(req, res, next) {
|
|
32
49
|
var config = this.config;
|
|
33
50
|
var pluginMgr = this.pluginMgr;
|
|
@@ -122,6 +139,7 @@ module.exports = function(req, res, next) {
|
|
|
122
139
|
isWebUI = true;
|
|
123
140
|
}
|
|
124
141
|
}
|
|
142
|
+
isWebUI = isWebUI && !setServiceUrl(req);
|
|
125
143
|
// 后续有用到
|
|
126
144
|
fullUrl = req.fullUrl = util.getFullUrl(req);
|
|
127
145
|
if (bypass) {
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
var config = require('../../../lib/config');
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports = function(req, res) {
|
|
3
|
+
module.exports = function(_, res) {
|
|
6
4
|
res.json({
|
|
7
|
-
pid: pid,
|
|
8
5
|
storage: config.storage || '',
|
|
9
6
|
client: config.client,
|
|
10
7
|
whistleName: config.whistleName,
|