Try to fix things.
This commit is contained in:
parent
5d20ab866a
commit
3745fd9218
18
index.ts
18
index.ts
@ -40,6 +40,17 @@ let srv = net.createServer(function(socket: net.Socket) {
|
||||
}
|
||||
let addr = a.address;
|
||||
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));
|
||||
addr = p.source.ipAddress;
|
||||
if (typeof p.data === 'string') {
|
||||
data = p.data;
|
||||
}
|
||||
} else {
|
||||
console.log("Address " + addr + " tried to use proxy protocol.");
|
||||
}
|
||||
}
|
||||
switch (data[0]) {
|
||||
case 0x30:
|
||||
const store = db.prepare("INSERT INTO messages VALUES (?,?,?)");
|
||||
@ -63,13 +74,6 @@ let srv = net.createServer(function(socket: net.Socket) {
|
||||
socket.write(str);
|
||||
});
|
||||
return;
|
||||
case 'P'.charCodeAt(0):
|
||||
if (addr == "127.0.0.1") {
|
||||
addr = pp.V1ProxyProtocol.parse(String(data)).source.ipAddress;
|
||||
} else {
|
||||
console.log("Address " + addr + " tried to use proxy protocol.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
console.log(addr + "???" + data[0]);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user