From dc5996957ec61b00a38820b67c743304045fdb26 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Fri, 22 Jul 2022 19:58:28 -0400 Subject: [PATCH] *Change the communication protocol to require a rpc text "command" before attempting to read as a second listener --- src/rpc.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/rpc.ts b/src/rpc.ts index 60dd2b3..b33c9ed 100644 --- a/src/rpc.ts +++ b/src/rpc.ts @@ -246,7 +246,17 @@ export async function start() { (await getDHT("server")).on("connection", (socket: any) => { socket.rawStream._ondestroy = () => false; - socket.on("data", async (data: any) => { + + let isRpc = false; + socket.once("data", async (data: any) => { + if (data === "rpc") { + isRpc = true; + } + }); + socket.once("data", async (data: any) => { + if (!isRpc) { + return; + } let request: RPCRequest; try { request = unpack(data) as RPCRequest;