Commit bb7aa9b3 authored by jan.koester's avatar jan.koester
Browse files

test

parent f3a61f1e
Loading
Loading
Loading
Loading
+9 −1
Changes for src/event/poll.cpp: 9 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    #include <unistd.h>
    #include <signal.h>
    #include <sys/select.h>
    #include <poll.h>
    #include <fcntl.h>
    #include <pthread.h>
#endif
@@ -315,7 +316,14 @@ namespace netplus {
                    ccon->slots[0].csock = std::make_unique<tcp>(-1);
                else if (_ServerSocket->_Type == sockettype::SSL) {
                    ssl* srv = static_cast<ssl*>(_ServerSocket);
                    ccon->slots[0].csock = std::make_unique<ssl>(srv->_tls.cert_map, -1);
                    // ssl's shared_ptr<cert_map> constructors are private (only
                    // a fixed set of friend classes may bypass the public,
                    // deep-copying map constructors) -- std::make_unique can't
                    // reach a private constructor even from a friend class,
                    // since its `new T(...)` isn't in the friend's own lexical
                    // scope. Same direct-new-in-a-unique_ptr idiom already used
                    // by ssl::accept() itself (ssl.cpp) for this exact reason.
                    ccon->slots[0].csock = std::unique_ptr<ssl>(new ssl(srv->_tls.cert_map, -1));
                } else if (_ServerSocket->_Type == sockettype::QUIC) {
                    do {
                        std::unique_ptr<socket> quic_csock;
+1 −0
Changes for src/socket.h: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -568,6 +568,7 @@ namespace netplus {

	private:
		ssl(std::shared_ptr<const std::map<std::string, CertificateBundle>> shared_certs);
		ssl(std::shared_ptr<const std::map<std::string, CertificateBundle>> shared_certs, int sock);
		tls _tls;
		FramingCallback _framing_cb;

+9 −0
Changes for src/ssl.cpp: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -77,6 +77,15 @@ ssl::ssl(std::shared_ptr<const std::map<std::string, CertificateBundle>> shared_
    _Type = sockettype::SSL;
}

ssl::ssl(std::shared_ptr<const std::map<std::string, CertificateBundle>> shared_certs, int sock) : tcp(sock) {
    _tls.cert_map = std::move(shared_certs);
    if (_tls.cert_map && !_tls.cert_map->empty()) {
        _tls.selected_cert_bundle = const_cast<CertificateBundle*>(&_tls.cert_map->begin()->second);
    }
    _tls.setSocket(this);
    _Type = sockettype::SSL;
}

void ssl::setCertificates(const std::map<std::string, CertificateBundle>& certs) {
    _tls.cert_map = std::make_shared<const std::map<std::string, CertificateBundle>>(certs);
    if (!certs.empty()) {