Закрытие сокета после неуспешного handshake

This commit is contained in:
set
2026-03-11 17:21:26 +02:00
parent c9aade2be3
commit 28b1b7c819

View File

@@ -82,12 +82,14 @@ func processData(data <-chan []byte, connection *Connection) {
}
connection.Socket.WriteMessage(websocket.BinaryMessage, []byte{0xFF})
logger.LogWarnMessage("failed handshake from " + connection.Socket.RemoteAddr().String() + " because of invalid secret key")
connection.Socket.Close()
return
}
// Так как следующие пакеты требуют обязательного завершения рукопожатия, нужно проверять, что сокет уже прошел рукопожатие
if _, exists := GetSocket(connection.Identificator); !exists {
logger.LogWarnMessage("received data from " + connection.Socket.RemoteAddr().String() + " but it has not completed handshake")
connection.Socket.Close()
return
}