diff --git a/index.ts b/index.ts index 3879cb6..b8698dc 100644 --- a/index.ts +++ b/index.ts @@ -42,12 +42,13 @@ let srv = net.createServer(function(socket: net.Socket) { socket.on('data', function(data: Buffer | string) { if (data[0] === 'P'.charCodeAt(0)) { if (addr == "127.0.0.1") { - let p = pp.V1ProxyProtocol.parse(String(data)); + let s = String(data); + let p = pp.V1ProxyProtocol.parse(s); addr = p.source.ipAddress; if (typeof p.data === 'undefined') { return; } else { - data = data.slice(p.data.length); + data = data.slice(s.search("\r")); } } else { console.log("Address " + addr + " tried to use proxy protocol.");