From dedf06a263b47922c16454de392468ad30dda956 Mon Sep 17 00:00:00 2001 From: Tau Date: Sat, 13 Apr 2019 12:46:09 -0400 Subject: [PATCH] Don't crash on unknown command --- src/idz/index.ts | 4 +++- src/idz/setup.ts | 10 +++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/idz/index.ts b/src/idz/index.ts index 2ce2f49..77ef67b 100644 --- a/src/idz/index.ts +++ b/src/idz/index.ts @@ -15,8 +15,10 @@ export default async function idz(socket: Socket) { output.write(await dispatch(world, req)); } } catch (e) { - console.log("Idz: Error", e); + console.log("Idz: Error:", e); } console.log("Idz: Connection closed\n"); + + input.end(); } diff --git a/src/idz/setup.ts b/src/idz/setup.ts index cd5233f..bf023c6 100644 --- a/src/idz/setup.ts +++ b/src/idz/setup.ts @@ -35,12 +35,16 @@ console.log("RSA ENCDEC :", byteString(test2, 0x40).toString("hex")); // -- TEST -- interface Session { - input: AsyncIterable; + input: AsyncIterable & { + end: () => void; + }; output: { write: (res: Response) => void; }; } +function doNothing() {} + export function setup(socket: Socket): Session { // // Construct and transmit setup message @@ -67,13 +71,13 @@ export function setup(socket: Socket): Session { socket, createDecipheriv("aes-128-ecb", keybuf, null).setAutoPadding(false), input - ); + ).catch(doNothing); pipeline( output, createCipheriv("aes-128-ecb", keybuf, null).setAutoPadding(false), socket - ); + ).catch(doNothing); return { input, output }; }