*Change the communication protocol to require a rpc text "command" before attempting to read as a second listener
This commit is contained in:
parent
76a3010ae6
commit
dc5996957e
12
src/rpc.ts
12
src/rpc.ts
|
@ -246,7 +246,17 @@ export async function start() {
|
||||||
|
|
||||||
(await getDHT("server")).on("connection", (socket: any) => {
|
(await getDHT("server")).on("connection", (socket: any) => {
|
||||||
socket.rawStream._ondestroy = () => false;
|
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;
|
let request: RPCRequest;
|
||||||
try {
|
try {
|
||||||
request = unpack(data) as RPCRequest;
|
request = unpack(data) as RPCRequest;
|
||||||
|
|
Loading…
Reference in New Issue