mirror of
https://github.com/avwo/whistle.git
synced 2026-10-29 07:06:36 +08:00
fix: clientIp & clientPort
This commit is contained in:
+7
-1
@@ -622,9 +622,15 @@ module.exports = function(socket, hostname, next, isWebPort) {
|
||||
if (!chunk) {//没有数据
|
||||
return isWebPort ? socket.destroy() : next(chunk);
|
||||
}
|
||||
var clientPort = socket.remotePort;
|
||||
if (HTTP_RE.test(headersStr)) {
|
||||
socket.test = clientPort;
|
||||
var statusLine = RegExp['$&'];
|
||||
var len = Buffer.byteLength(statusLine);
|
||||
server.emit('connection', socket);
|
||||
socket.emit('data', chunk);
|
||||
chunk = chunk.slice(len);
|
||||
statusLine += '\r\n' + config.CLIENT_INFO_HEAD + ': ' + clientIp + ',' + clientPort;
|
||||
socket.emit('data', Buffer.concat([Buffer.from(statusLine), chunk]));
|
||||
} else if (chunk[0] != 22) {
|
||||
next(chunk);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user