Commit 7ef37b86 authored by jan.koester's avatar jan.koester
Browse files

test

parent eda38331
Loading
Loading
Loading
Loading
Loading
+24 −2
Changes for src/cluster.cpp: 24 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@
#include <cstring>
#include <iostream>
#include <algorithm>
#include <fstream>

namespace authdb {

@@ -201,9 +202,30 @@ namespace authdb {
        scfg.max_connections = 64;
        scfg.require_auth = !cfg_.client_name.empty();

        server_ = std::make_unique<paritypp::server>(scfg, store_, auth_);
        // Load certificate bundle and create QUIC server socket
        netplus::x509cert x509;
        x509.loadFromFile(cfg_.cert_file);

        server_->run();
        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);

        // Setup client for talking to peers
        if (!cfg_.peers.empty()) {