Commit 492ec594 authored by jan.koester's avatar jan.koester
Browse files

test

parent aa9767f9
Loading
Loading
Loading
Loading
Loading
+2 −28
Changes for src/cluster.cpp: 2 added lines, 28 removed lines.
Original line number Diff line number Diff line
@@ -36,13 +36,10 @@

#include <netplus/exception.h>
#include <crypto/sha.h>
#include <crypto/x509.h>
#include <crypto/rsa.h>

#include <cstring>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <unistd.h>

namespace authdb {
@@ -203,30 +200,7 @@ namespace authdb {
        scfg.max_connections = 64;
        scfg.require_auth = !cfg_.client_name.empty();

        // Load certificate bundle and create QUIC server socket
        netplus::x509cert x509;
        x509.loadFromFile(cfg_.cert_file);

        netplus::ssl::CertificateBundle bundle;
        bundle.cert = x509;

        std::ifstream kf(cfg_.key_file, std::ios::binary | std::ios::ate);
        if (kf) {
            auto sz = kf.tellg();
            kf.seekg(0);
            bundle.privateKeyDer.resize(static_cast<size_t>(sz));
            kf.read(reinterpret_cast<char*>(bundle.privateKeyDer.data()), sz);
            bundle.rsa_key = netplus::rsa(bundle.privateKeyDer);
        }

        std::map<std::string, netplus::ssl::CertificateBundle> certs;
        certs[x509.getSubjectCN()] = std::move(bundle);

        quic_socket_ = std::make_unique<netplus::quic>(
            certs, cfg_.bind_address, cfg_.port, scfg.max_connections, 0);

        std::vector<netplus::socket*> sockets = { quic_socket_.get() };
        server_ = std::make_unique<paritypp::server>(scfg, store_, auth_, sockets);
        server_ = std::make_unique<paritypp::server>(scfg, store_, auth_);

        // Setup client for talking to peers — filter out self
        if (!cfg_.peers.empty()) {
@@ -276,7 +250,7 @@ namespace authdb {

    void Cluster::server_loop() {
        try {
            server_->runEventloop();
            server_->run();
        } catch (const netplus::NetException &e) {
            std::cerr << "Cluster server error: " << e.what() << std::endl;
        } catch (const std::exception &e) {
+0 −3
Changes for src/cluster.h: 0 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -39,8 +39,6 @@
#include <paritypp/client.h>
#include <paritypp/auth.h>

#include <socket.h>

#include "session.h"
#include "backend.h"
#include "authdb.h"
@@ -154,7 +152,6 @@ namespace authdb {

        std::shared_ptr<paritypp::block_store> store_;
        std::shared_ptr<paritypp::auth_store> auth_;
        std::unique_ptr<netplus::quic> quic_socket_;
        std::unique_ptr<paritypp::server> server_;

        std::unique_ptr<paritypp::client> pclient_;