Don't crash on unknown command

This commit is contained in:
Tau
2019-11-06 17:28:29 -05:00
parent 7a95536d01
commit dedf06a263
2 changed files with 10 additions and 4 deletions
+3 -1
View File
@@ -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();
}
+7 -3
View File
@@ -35,12 +35,16 @@ console.log("RSA ENCDEC :", byteString(test2, 0x40).toString("hex"));
// -- TEST --
interface Session {
input: AsyncIterable<Request>;
input: AsyncIterable<Request> & {
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 };
}