Version 1.2.1 - Bug Fixes
Critical (4)
C1 — udp_client.hpp / udp_client.cpp: Moved mStartReceive() out of the constructor into start(), after the socket is opened.
C2 — client/main.cpp:187: || → && in the main loop condition, so it exits when the connection drops instead of spinning forever.
C3 — tcp_connection.hpp: Added mConnectionAESKey{}, mConnectionSessionID(0), and mConnectionPublicKey{} to the constructor initializer list.
C4 — tcp_server.hpp / tcp_server.cpp: Added std::mutex mClientsMutex and locked it at all three mClients access sites (insert, erase callback, stop snapshot).
High (5)
H1 — tcp_connection.cpp:284: Replaced hardcoded htonl(0x0A0A0001) with htonl(baseIP + 1).
H2 — session_registry.hpp / session_registry.cpp / udp_server.cpp: Changed get() and getByIP() to return shared_ptr<SessionState> (non-const); removed all four const_cast usages.
H3 — session_registry.cpp:90: Guarded against mask == 0 || mask >= 32 (shift UB) and hostCount < 3 (unsigned underflow).
H4 — virtual_interface.cpp: Added runCommandWin32() using CreateProcess (no shell); replaced both system() calls in resetIP().
H5 — virtual_interface.cpp: Added close(mFd); mFd = -1; before both throw sites in the macOS constructor (ioctl failure and connect failure).
Medium (4)
M1 — tcp_connection.cpp:241: Added explicit find() + end-iterator check for NETWORK and SUBNET_MASK before dereferencing.
M2 — tcp_message_handler.cpp: Added an 8 KB (MAX_MSG_BODY = 8192) cap on incoming message body length; oversized messages close the connection.
M3 — tcp_connection.cpp:232: Capped the session ID generation loop at 16 attempts before disconnecting.
M4 — session_registry.cpp:8: put() now evicts the old IP→session mapping before replacing an entry, preventing stale mIPSessions entries.
This commit is contained in:
@@ -20,7 +20,6 @@ namespace ColumnLynx::Net::UDP {
|
||||
const std::string& port)
|
||||
: mSocket(ioContext), mResolver(ioContext), mHost(host), mPort(port)
|
||||
{
|
||||
mStartReceive();
|
||||
}
|
||||
|
||||
// Start the UDP client
|
||||
|
||||
@@ -61,10 +61,10 @@ namespace ColumnLynx::Net {
|
||||
void put(uint32_t sessionID, std::shared_ptr<SessionState> state);
|
||||
|
||||
// Lookup a session entry by session ID
|
||||
std::shared_ptr<const SessionState> get(uint32_t sessionID) const;
|
||||
std::shared_ptr<SessionState> get(uint32_t sessionID) const;
|
||||
|
||||
// Lookup a session entry by IPv4
|
||||
std::shared_ptr<const SessionState> getByIP(uint32_t ip) const;
|
||||
std::shared_ptr<SessionState> getByIP(uint32_t ip) const;
|
||||
|
||||
// Get a snapshot of the Session Registry
|
||||
std::unordered_map<uint32_t, std::shared_ptr<SessionState>> snapshot() const;
|
||||
|
||||
@@ -53,6 +53,9 @@ namespace ColumnLynx::Net::TCP {
|
||||
:
|
||||
mHandler(std::make_shared<MessageHandler>(std::move(socket))),
|
||||
mHeartbeatTimer(mHandler->socket().get_executor()),
|
||||
mConnectionAESKey{},
|
||||
mConnectionSessionID(0),
|
||||
mConnectionPublicKey{},
|
||||
mLastHeartbeatReceived(std::chrono::steady_clock::now()),
|
||||
mLastHeartbeatSent(std::chrono::steady_clock::now())
|
||||
{}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <unordered_set>
|
||||
#include <new>
|
||||
#include <asio.hpp>
|
||||
@@ -77,6 +78,7 @@ namespace ColumnLynx::Net::TCP {
|
||||
|
||||
asio::io_context &mIoContext;
|
||||
asio::ip::tcp::acceptor mAcceptor;
|
||||
std::mutex mClientsMutex;
|
||||
std::unordered_set<TCPConnection::pointer> mClients;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user