whistle 2.10.4 → 2.10.6
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 +0 -1
- package/assets/modal.html +0 -1
- package/assets/tab.html +0 -1
- package/bin/util.js +3 -3
- package/biz/webui/cgi-bin/get-session.js +7 -3
- package/biz/webui/cgi-bin/util.js +31 -21
- package/biz/webui/htdocs/index.html +1 -1
- package/biz/webui/htdocs/js/index.js +51 -53
- package/lib/https/index.js +3 -1
- package/lib/inspectors/data.js +34 -31
- package/lib/inspectors/req.js +8 -4
- package/lib/inspectors/res.js +4 -4
- package/lib/plugins/load-plugin.js +2 -2
- package/lib/service/service.js +2 -2
- package/lib/util/common.js +3 -2
- package/lib/util/file-mgr.js +7 -4
- package/lib/util/http-mgr.js +17 -9
- package/lib/util/index.js +59 -32
- package/lib/util/parse-url.js +11 -9
- package/package.json +1 -1
package/assets/menu.html
CHANGED
|
@@ -200,7 +200,6 @@
|
|
|
200
200
|
whistleBridge.compose = options.compose;
|
|
201
201
|
whistleBridge.composeInterrupt = options.createComposeInterrupt();
|
|
202
202
|
whistleBridge.getWhistleId = options.getWhistleId;
|
|
203
|
-
whistleBridge.hasWhistleToken = options.hasWhistleToken;
|
|
204
203
|
whistleBridge.decodeBase64 = options.decodeBase64;
|
|
205
204
|
whistleBridge.joinBase64 = options.joinBase64;
|
|
206
205
|
whistleBridge.getReqId = options.getReqId;
|
package/assets/modal.html
CHANGED
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
whistleBridge.compose = options.compose;
|
|
24
24
|
whistleBridge.composeInterrupt = options.createComposeInterrupt();
|
|
25
25
|
whistleBridge.getWhistleId = options.getWhistleId;
|
|
26
|
-
whistleBridge.hasWhistleToken = options.hasWhistleToken;
|
|
27
26
|
whistleBridge.decodeBase64 = options.decodeBase64;
|
|
28
27
|
whistleBridge.joinBase64 = options.joinBase64;
|
|
29
28
|
whistleBridge.getReqId = options.getReqId;
|
package/assets/tab.html
CHANGED
|
@@ -292,7 +292,6 @@
|
|
|
292
292
|
whistleBridge.compose = options.compose;
|
|
293
293
|
whistleBridge.composeInterrupt = options.createComposeInterrupt();
|
|
294
294
|
whistleBridge.getWhistleId = options.getWhistleId;
|
|
295
|
-
whistleBridge.hasWhistleToken = options.hasWhistleToken;
|
|
296
295
|
whistleBridge.decodeBase64 = options.decodeBase64;
|
|
297
296
|
whistleBridge.joinBase64 = options.joinBase64;
|
|
298
297
|
whistleBridge.getReqId = options.getReqId;
|
package/bin/util.js
CHANGED
|
@@ -185,15 +185,15 @@ exports.getDefaultPort = function () {
|
|
|
185
185
|
};
|
|
186
186
|
|
|
187
187
|
exports.getBody = function (res, callback) {
|
|
188
|
-
var resBody;
|
|
188
|
+
var resBody = [];
|
|
189
189
|
res.on('data', function(data) {
|
|
190
|
-
resBody
|
|
190
|
+
resBody.push(data);
|
|
191
191
|
});
|
|
192
192
|
res.on('end', function() {
|
|
193
193
|
if (res.statusCode != 200) {
|
|
194
194
|
callback('Bad response (' + res.statusCode + ')');
|
|
195
195
|
} else {
|
|
196
|
-
callback(null, JSON.parse(resBody
|
|
196
|
+
callback(null, JSON.parse(Buffer.concat(resBody).toString()));
|
|
197
197
|
}
|
|
198
198
|
});
|
|
199
199
|
};
|
|
@@ -13,7 +13,8 @@ module.exports = function(req, res) {
|
|
|
13
13
|
var reqList = parseArray(req.query.reqList);
|
|
14
14
|
var resList = parseArray(req.query.resList);
|
|
15
15
|
var result = {};
|
|
16
|
-
|
|
16
|
+
var isReq;
|
|
17
|
+
var appendResult = function(id) {
|
|
17
18
|
if (result[id] != null) {
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
@@ -22,9 +23,12 @@ module.exports = function(req, res) {
|
|
|
22
23
|
result[id] = 0;
|
|
23
24
|
return;
|
|
24
25
|
}
|
|
25
|
-
if ((item.requestTime &&
|
|
26
|
+
if ((item.requestTime && isReq) || item.endTime) {
|
|
26
27
|
result[id] = item;
|
|
27
28
|
}
|
|
28
|
-
}
|
|
29
|
+
};
|
|
30
|
+
resList.forEach(appendResult);
|
|
31
|
+
isReq = true;
|
|
32
|
+
reqList.forEach(appendResult);
|
|
29
33
|
res.json(result);
|
|
30
34
|
};
|
|
@@ -27,7 +27,6 @@ exports.getServerInfo = function(req) {
|
|
|
27
27
|
var info = {
|
|
28
28
|
whistleId: config.whistleId,
|
|
29
29
|
hasUpdater: config.hasUpdater,
|
|
30
|
-
hasWhistleToken: config.hasWhistleToken,
|
|
31
30
|
pid: PID,
|
|
32
31
|
pInfo: proc,
|
|
33
32
|
verbatim: config.verbatim,
|
|
@@ -72,47 +71,58 @@ exports.getServerInfo = function(req) {
|
|
|
72
71
|
ipv6: [],
|
|
73
72
|
mac: req.ip + (config.storage ? '\n' + config.storage : '')
|
|
74
73
|
};
|
|
75
|
-
var
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (iface.internal) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
info[iface.family == 'IPv4' || iface.family === 4 ? 'ipv4' : 'ipv6'].push(iface.address);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
74
|
+
var serverInfo = util.getServerInfo();
|
|
75
|
+
info.ipv4 = serverInfo.ipv4;
|
|
76
|
+
info.ipv6 = serverInfo.ipv6;
|
|
85
77
|
return info;
|
|
86
78
|
};
|
|
87
79
|
|
|
88
80
|
var DATA_RE = /[\r\n]\s*(\{[\s\S]*\})[\r\n]/;
|
|
89
81
|
var REPLACE_RE = /[\r\n]1[\r\n]/;
|
|
82
|
+
var EXCEED_SIZE_ERR = new Error('The file size can not exceed 6MB');
|
|
83
|
+
var INVALID_CONTENT_ERR = new Error('The file content is not a JSON object');
|
|
84
|
+
|
|
90
85
|
exports.getReqData = function(req, callback) {
|
|
91
|
-
var result =
|
|
86
|
+
var result = [];
|
|
87
|
+
var len = 0;
|
|
88
|
+
var done;
|
|
89
|
+
var handleCb = function(err, data) {
|
|
90
|
+
if (!done) {
|
|
91
|
+
done = true;
|
|
92
|
+
callback(err, data);
|
|
93
|
+
result = null;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
92
96
|
req.on('data', function(chunk) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
if (done) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
len += chunk.length;
|
|
101
|
+
result.push(chunk);
|
|
102
|
+
if (len > MAX_OBJECT_SIZE) {
|
|
103
|
+
handleCb(EXCEED_SIZE_ERR);
|
|
97
104
|
}
|
|
98
105
|
});
|
|
99
|
-
req.on('error',
|
|
106
|
+
req.on('error', handleCb);
|
|
100
107
|
req.on('end', function() {
|
|
101
|
-
|
|
108
|
+
if (done) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
102
111
|
var data;
|
|
112
|
+
result = Buffer.concat(result).toString();
|
|
103
113
|
result = result.replace(DATA_RE, function(all, match) {
|
|
104
114
|
data = match;
|
|
105
115
|
return '';
|
|
106
116
|
});
|
|
107
117
|
if (!data) {
|
|
108
|
-
return
|
|
118
|
+
return handleCb(INVALID_CONTENT_ERR);
|
|
109
119
|
}
|
|
110
120
|
try {
|
|
111
121
|
data = JSON.parse(data);
|
|
112
122
|
} catch(err) {
|
|
113
|
-
return
|
|
123
|
+
return handleCb(err);
|
|
114
124
|
}
|
|
115
|
-
|
|
125
|
+
handleCb(null, {
|
|
116
126
|
data: data,
|
|
117
127
|
replace: REPLACE_RE.test(result)
|
|
118
128
|
});
|