whistle 2.10.5 → 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/bin/util.js +3 -3
- package/biz/webui/cgi-bin/get-session.js +7 -3
- package/biz/webui/cgi-bin/util.js +31 -20
- package/biz/webui/htdocs/index.html +1 -1
- package/biz/webui/htdocs/js/index.js +51 -51
- package/lib/https/index.js +3 -1
- package/lib/inspectors/data.js +33 -30
- 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/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
|
};
|
|
@@ -71,47 +71,58 @@ exports.getServerInfo = function(req) {
|
|
|
71
71
|
ipv6: [],
|
|
72
72
|
mac: req.ip + (config.storage ? '\n' + config.storage : '')
|
|
73
73
|
};
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (iface.internal) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
info[iface.family == 'IPv4' || iface.family === 4 ? 'ipv4' : 'ipv6'].push(iface.address);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
74
|
+
var serverInfo = util.getServerInfo();
|
|
75
|
+
info.ipv4 = serverInfo.ipv4;
|
|
76
|
+
info.ipv6 = serverInfo.ipv6;
|
|
84
77
|
return info;
|
|
85
78
|
};
|
|
86
79
|
|
|
87
80
|
var DATA_RE = /[\r\n]\s*(\{[\s\S]*\})[\r\n]/;
|
|
88
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
|
+
|
|
89
85
|
exports.getReqData = function(req, callback) {
|
|
90
|
-
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
|
+
};
|
|
91
96
|
req.on('data', function(chunk) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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);
|
|
96
104
|
}
|
|
97
105
|
});
|
|
98
|
-
req.on('error',
|
|
106
|
+
req.on('error', handleCb);
|
|
99
107
|
req.on('end', function() {
|
|
100
|
-
|
|
108
|
+
if (done) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
101
111
|
var data;
|
|
112
|
+
result = Buffer.concat(result).toString();
|
|
102
113
|
result = result.replace(DATA_RE, function(all, match) {
|
|
103
114
|
data = match;
|
|
104
115
|
return '';
|
|
105
116
|
});
|
|
106
117
|
if (!data) {
|
|
107
|
-
return
|
|
118
|
+
return handleCb(INVALID_CONTENT_ERR);
|
|
108
119
|
}
|
|
109
120
|
try {
|
|
110
121
|
data = JSON.parse(data);
|
|
111
122
|
} catch(err) {
|
|
112
|
-
return
|
|
123
|
+
return handleCb(err);
|
|
113
124
|
}
|
|
114
|
-
|
|
125
|
+
handleCb(null, {
|
|
115
126
|
data: data,
|
|
116
127
|
replace: REPLACE_RE.test(result)
|
|
117
128
|
});
|