// main.cpp - Server entry point for ColumnLynx // Copyright (C) 2025 DcruBro // Distributed under the GPLv3 license. See LICENSE for details. #include #include #include #include #include #include using asio::ip::tcp; using namespace ColumnLynx::Utils; using namespace ColumnLynx::Net::TCP; int main(int argc, char** argv) { PanicHandler::init(); try { // TODO: Catch SIGINT and SIGTERM for graceful shutdown // 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(io, serverPort(), &sodiumWrapper); // Run the IO context in a separate thread std::thread ioThread([&io]() { io.run(); }); ioThread.join(); log("Server started on port " + std::to_string(serverPort())); } catch (const std::exception& e) { error("Server error: " + std::string(e.what())); } }