Add check for missing reconnection token

This means something is misconfigured.
This commit is contained in:
Asher 2019-08-23 13:43:45 -05:00
parent c4fd725875
commit 78b6b3afdf
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
1 changed files with 5 additions and 2 deletions

View File

@ -266,7 +266,7 @@ export abstract class Server {
await this.preHandleWebSocket(request, socket); await this.preHandleWebSocket(request, socket);
} catch (error) { } catch (error) {
socket.destroy(); socket.destroy();
console.error(error); console.error(error.message);
} }
} }
@ -421,8 +421,11 @@ export class MainServer extends Server {
} }
protected async handleWebSocket(socket: net.Socket, parsedUrl: url.UrlWithParsedQuery): Promise<void> { protected async handleWebSocket(socket: net.Socket, parsedUrl: url.UrlWithParsedQuery): Promise<void> {
if (!parsedUrl.query.reconnectionToken) {
throw new Error("Reconnection token is missing from query parameters");
}
const protocol = new Protocol(await this.createProxy(socket), { const protocol = new Protocol(await this.createProxy(socket), {
reconnectionToken: <string>parsedUrl.query.reconnectionToken || "", reconnectionToken: <string>parsedUrl.query.reconnectionToken,
reconnection: parsedUrl.query.reconnection === "true", reconnection: parsedUrl.query.reconnection === "true",
skipWebSocketFrames: parsedUrl.query.skipWebSocketFrames === "true", skipWebSocketFrames: parsedUrl.query.skipWebSocketFrames === "true",
}); });