whistle 2.9.108 → 2.10.0
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/bin/util.js +1 -1
- package/biz/index.js +12 -10
- package/biz/webui/cgi-bin/certs/active.js +6 -0
- package/biz/webui/cgi-bin/certs/remove.js +0 -1
- package/biz/webui/cgi-bin/certs/upload.js +0 -1
- package/biz/webui/cgi-bin/util.js +7 -20
- package/biz/webui/htdocs/index.html +1 -1
- package/biz/webui/htdocs/js/index.js +41 -41
- package/biz/webui/lib/index.js +10 -13
- package/lib/config.js +17 -36
- package/lib/handlers/file-proxy.js +2 -1
- package/lib/handlers/http-proxy.js +1 -1
- package/lib/https/ca.js +34 -27
- package/lib/https/h2.js +1 -1
- package/lib/https/index.js +21 -17
- package/lib/index.js +1 -1
- package/lib/init.js +13 -12
- package/lib/inspectors/req.js +13 -10
- package/lib/inspectors/res.js +375 -390
- package/lib/inspectors/rules.js +11 -0
- package/lib/plugins/compat.js +108 -0
- package/lib/plugins/get-plugins-sync.js +1 -4
- package/lib/plugins/index.js +92 -284
- package/lib/plugins/load-plugin.js +205 -223
- package/lib/plugins/module-paths.js +3 -4
- package/lib/plugins/proxy.js +4 -7
- package/lib/rules/index.js +69 -66
- package/lib/rules/protocols.js +6 -0
- package/lib/rules/rules.js +43 -31
- package/lib/rules/util.js +30 -0
- package/lib/service/composer.js +5 -5
- package/lib/service/util.js +7 -21
- package/lib/tunnel.js +15 -12
- package/lib/upgrade.js +8 -9
- package/lib/util/common.js +171 -48
- package/lib/util/file-mgr.js +3 -7
- package/lib/util/index.js +101 -143
- package/package.json +1 -1
- package/README-en_US.md +0 -80
- package/biz/webui/htdocs/img/assistant.svg +0 -1
package/bin/util.js
CHANGED
|
@@ -121,7 +121,7 @@ function showUsage(isRunning, options, restart) {
|
|
|
121
121
|
exports.showUsage = showUsage;
|
|
122
122
|
|
|
123
123
|
function getDataDir() {
|
|
124
|
-
return path.resolve(
|
|
124
|
+
return path.resolve(common.getHomedir(), '.startingAppData');
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
function formatOptions(options) {
|
package/biz/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var util = require('../lib/util');
|
|
|
4
4
|
var handleUIReq = require('./webui/lib').handleRequest;
|
|
5
5
|
var handleWeinreReq = require('./weinre');
|
|
6
6
|
var config = require('../lib/config');
|
|
7
|
+
var common = require('../lib/util/common');
|
|
7
8
|
|
|
8
9
|
var localIpCache = util.localIpCache;
|
|
9
10
|
var WEBUI_PATH = config.WEBUI_PATH;
|
|
@@ -31,7 +32,8 @@ module.exports = function(req, res, next) {
|
|
|
31
32
|
var config = this.config;
|
|
32
33
|
var pluginMgr = this.pluginMgr;
|
|
33
34
|
var fullUrl = req.fullUrl = util.getFullUrl(req); // format request
|
|
34
|
-
var
|
|
35
|
+
var headers = req.headers;
|
|
36
|
+
var host = util.parseHost(headers.host);
|
|
35
37
|
var port = host[1] || (req.isHttps ? 443 : 80);
|
|
36
38
|
var bypass;
|
|
37
39
|
host = host[0];
|
|
@@ -59,12 +61,12 @@ module.exports = function(req, res, next) {
|
|
|
59
61
|
var realPath = RegExp.$1;
|
|
60
62
|
var realPort = RegExp.$3;
|
|
61
63
|
realHost = RegExp.$2 + (realPort ? ':' + realPort : '');
|
|
62
|
-
|
|
64
|
+
headers[util.REAL_HOST_HEADER] = realHost;
|
|
63
65
|
req.url = req.url.replace(realPath, '');
|
|
64
66
|
} else {
|
|
65
67
|
req.curUrl = fullUrl;
|
|
66
68
|
if (realHost = rules.resolveInternalHost(req)) {
|
|
67
|
-
|
|
69
|
+
headers[util.REAL_HOST_HEADER] = realHost;
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
if (internalAppRe.test(req.path)) {
|
|
@@ -79,7 +81,7 @@ module.exports = function(req, res, next) {
|
|
|
79
81
|
isProxyReq = isProxyReq || isOld;
|
|
80
82
|
} else if (pluginRe.test(req.path)) {
|
|
81
83
|
isProxyReq = !pluginMgr.getPlugin(RegExp.$1 + ':');
|
|
82
|
-
} else if (!
|
|
84
|
+
} else if (!headers[config.WEBUI_HEAD]) {
|
|
83
85
|
isWebUI = false;
|
|
84
86
|
}
|
|
85
87
|
if (!config.proxyServer && isProxyReq && !config.isLocalUIUrl(host)) {
|
|
@@ -90,11 +92,11 @@ module.exports = function(req, res, next) {
|
|
|
90
92
|
if (isWebUI) {
|
|
91
93
|
req.fromInternalPath = true;
|
|
92
94
|
var hostname = (req._fwdHost && util.parseHost(req._fwdHost)[0]) || host;
|
|
93
|
-
|
|
95
|
+
headers[common.ORIGIN_HOST_HEADER] = hostname || '*';
|
|
94
96
|
}
|
|
95
97
|
}
|
|
96
98
|
} else {
|
|
97
|
-
isWebUI =
|
|
99
|
+
isWebUI = headers[config.WEBUI_HEAD];
|
|
98
100
|
if (!isWebUI) {
|
|
99
101
|
if (!(isWebUI = localIpCache.get(host))) {
|
|
100
102
|
isWebUI = config.isLocalUIUrl(host);
|
|
@@ -106,7 +108,7 @@ module.exports = function(req, res, next) {
|
|
|
106
108
|
localIpCache.set(host, 1);
|
|
107
109
|
}
|
|
108
110
|
if (PREVIEW_PATH_RE.test(req.url)) {
|
|
109
|
-
|
|
111
|
+
headers[util.INTERNAL_ID_HEADER] = util.INTERNAL_ID;
|
|
110
112
|
req.url = '/preview.html?charset=' + RegExp.$1;
|
|
111
113
|
isWebUI = true;
|
|
112
114
|
} else if (isWebUI) {
|
|
@@ -118,7 +120,7 @@ module.exports = function(req, res, next) {
|
|
|
118
120
|
if (bypass) {
|
|
119
121
|
req.url = req.url.replace(bypass, '/');
|
|
120
122
|
}
|
|
121
|
-
delete
|
|
123
|
+
delete headers[util.INTERNAL_ID_HEADER];
|
|
122
124
|
}
|
|
123
125
|
}
|
|
124
126
|
// 后续有用到
|
|
@@ -137,7 +139,7 @@ module.exports = function(req, res, next) {
|
|
|
137
139
|
var outerPort = RegExp.$2;
|
|
138
140
|
req.url = req.url.replace(RegExp['$&'], '/' + RegExp.$1 + '/');
|
|
139
141
|
if (outerPort > 0 && outerPort < 65536 && outerPort != config.port) {
|
|
140
|
-
|
|
142
|
+
headers.host = '127.0.0.1:' + outerPort;
|
|
141
143
|
return util.transformReq(req, res, outerPort);
|
|
142
144
|
}
|
|
143
145
|
}
|
|
@@ -151,7 +153,7 @@ module.exports = function(req, res, next) {
|
|
|
151
153
|
} else if (localRule = rules.resolveLocalRule(req)) {
|
|
152
154
|
req.url = localRule.url;
|
|
153
155
|
if (localRule.realPort) {
|
|
154
|
-
|
|
156
|
+
headers.host = '127.0.0.1:' + localRule.realPort;
|
|
155
157
|
util.transformReq(req, res, localRule.realPort);
|
|
156
158
|
} else {
|
|
157
159
|
transformUI(req, res);
|
|
@@ -2,6 +2,7 @@ var util = require('../../../lib/util');
|
|
|
2
2
|
var config = require('../../../lib/config');
|
|
3
3
|
var proc = require('../../../lib/util/process');
|
|
4
4
|
var rulesUtil = require('../../../lib/rules/util');
|
|
5
|
+
var padLeft = require('../../../lib/util/common').padLeft;
|
|
5
6
|
|
|
6
7
|
var properties = rulesUtil.properties;
|
|
7
8
|
var rules = rulesUtil.rules;
|
|
@@ -118,30 +119,16 @@ exports.getReqData = function(req, callback) {
|
|
|
118
119
|
});
|
|
119
120
|
};
|
|
120
121
|
|
|
121
|
-
function padding(num) {
|
|
122
|
-
return num < 10 ? '0' + num : num;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function paddingMS(ms) {
|
|
126
|
-
if (ms > 99) {
|
|
127
|
-
return ms;
|
|
128
|
-
}
|
|
129
|
-
if (ms > 9) {
|
|
130
|
-
return '0' + ms;
|
|
131
|
-
}
|
|
132
|
-
return '00' + ms;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
122
|
function formatDate() {
|
|
136
123
|
var date = new Date();
|
|
137
124
|
var result = [];
|
|
138
125
|
result.push(date.getFullYear());
|
|
139
|
-
result.push(
|
|
140
|
-
result.push(
|
|
141
|
-
result.push(
|
|
142
|
-
result.push(
|
|
143
|
-
result.push(
|
|
144
|
-
result.push(
|
|
126
|
+
result.push(padLeft(date.getMonth() + 1));
|
|
127
|
+
result.push(padLeft(date.getDate()));
|
|
128
|
+
result.push(padLeft(date.getHours()));
|
|
129
|
+
result.push(padLeft(date.getMinutes()));
|
|
130
|
+
result.push(padLeft(date.getSeconds()));
|
|
131
|
+
result.push(padLeft(date.getMilliseconds(), 3));
|
|
145
132
|
return result.join('');
|
|
146
133
|
}
|
|
147
134
|
|