Almost finished with the TCP Handshake procedure, need to properly handle disconnects (currently pretty forceful)
This commit is contained in:
@@ -21,9 +21,11 @@ int main(int argc, char** argv) {
|
||||
|
||||
// Generate a temporary keypair, replace with actual CA signed keys later (Note, these are stored in memory)
|
||||
LibSodiumWrapper sodiumWrapper = LibSodiumWrapper();
|
||||
log("Server public key: " + bytesToHexString(sodiumWrapper.getPublicKey(), crypto_sign_PUBLICKEYBYTES));
|
||||
log("Server private key: " + bytesToHexString(sodiumWrapper.getPrivateKey(), crypto_sign_SECRETKEYBYTES)); // TEMP, remove later
|
||||
|
||||
asio::io_context io;
|
||||
auto server = std::make_shared<TCPServer>(io, serverPort());
|
||||
auto server = std::make_shared<TCPServer>(io, serverPort(), &sodiumWrapper);
|
||||
|
||||
// Run the IO context in a separate thread
|
||||
std::thread ioThread([&io]() {
|
||||
|
||||
@@ -23,7 +23,8 @@ namespace ColumnLynx::Net::TCP {
|
||||
mAcceptor.async_accept(
|
||||
[this](asio::error_code ec, asio::ip::tcp::socket socket) {
|
||||
if (!NetHelper::isExpectedDisconnect(ec)) {
|
||||
auto client = TCPConnection::create(std::move(socket), mSodiumWrapper,
|
||||
auto client = TCPConnection::create(std::move(socket),
|
||||
mSodiumWrapper,
|
||||
[this](std::shared_ptr<TCPConnection> c) {
|
||||
mClients.erase(c);
|
||||
Utils::log("Client removed.");
|
||||
|
||||
Reference in New Issue
Block a user