Commit 282d9bfc authored by echicken's avatar echicken 🐔
Browse files

Build protocol header as string and send all in one big barforama.

parent 2225ced7
...@@ -93,20 +93,17 @@ try { ...@@ -93,20 +93,17 @@ try {
var ServerData = []; var ServerData = [];
if (UsingHAProxy()) { if (UsingHAProxy()) {
[0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21].forEach(function (e) { var hapstr = '\x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A\x21';
FServerSocket.sendBin(e, 1);
});
if (client.socket.family === PF_INET) { if (client.socket.family === PF_INET) {
FServerSocket.sendBin(0x11, 1); hapstr += '\x11\x0C';
FServerSocket.sendBin(12, 2);
} else if (client.socket.family === PF_INET6) { } else if (client.socket.family === PF_INET6) {
FServerSocket.sendBin(0x21, 1); hapstr += '\x21\x24';
FServerSocket.sendBin(36, 2);
} }
FServerSocket.sendBin(inet_pton(client.ip_address), 4); hapstr += inet_pton(client.ip_address);
FServerSocket.sendBin(inet_pton(FServerSocket.remote_ip_address), 4); hapstr += inet_pton(FServerSocket.remote_ip_address);
FServerSocket.sendBin(client.port, 2); hapstr += client.port.toString(16);
FServerSocket.sendBin(TargetPort, 2); hapstr += TargetPort.toString(16);
FServerSocket.send(hapstr);
} }
// Loop while we're still connected on both ends // Loop while we're still connected on both ends
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment