backend: disconnect gateway clients if they send a ping packet before authenticaticating
This commit is contained in:
parent
97d155667d
commit
261e041792
2 changed files with 5 additions and 0 deletions
|
@ -17,4 +17,5 @@ export const gatewayErrors = {
|
|||
ALREADY_AUTHENTICATED: { code: 4006, message: "Already authenticated" },
|
||||
PAYLOAD_TOO_LARGE: { code: 4007, message: "Payload too large" },
|
||||
TOO_MANY_SESSIONS: { code: 4008, message: "Too many sessions" },
|
||||
NOT_AUTHENTICATED: { code: 4009, message: "Not authenticated" },
|
||||
};
|
||||
|
|
|
@ -245,6 +245,10 @@ export default function(server: Server) {
|
|||
return closeWithBadPayload(ws, "d: expected numeric '0'");
|
||||
}
|
||||
|
||||
if (!ws.state.ready) {
|
||||
return closeWithError(ws, gatewayErrors.NOT_AUTHENTICATED);
|
||||
}
|
||||
|
||||
// TODO: also check session here
|
||||
ws.state.alive = true;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue