Browse Source

Merge pull request #1472 from mcspr/ws/uninitialized-tempobj

Disconnect websocket when auth fails
refactor-terminal
Xose Pérez 5 years ago
committed by GitHub
parent
commit
4116509ecc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions
  1. +8
    -3
      code/espurna/ws.ino

+ 8
- 3
code/espurna/ws.ino View File

@ -66,8 +66,6 @@ bool _wsAuth(AsyncWebSocketClient * client) {
}
if (index == WS_BUFFER_SIZE) {
DEBUG_MSG_P(PSTR("[WEBSOCKET] Validation check failed\n"));
wsSend_P(client->id(), PSTR("{\"message\": 10}"));
return false;
}
@ -367,8 +365,15 @@ void _wsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventTy
if (type == WS_EVT_CONNECT) {
client->_tempObject = nullptr;
#ifndef NOWSAUTH
if (!_wsAuth(client)) return;
if (!_wsAuth(client)) {
wsSend_P(client->id(), PSTR("{\"message\": 10}"));
DEBUG_MSG_P(PSTR("[WEBSOCKET] Validation check failed\n"));
client->close();
return;
}
#endif
IPAddress ip = client->remoteIP();


Loading…
Cancel
Save