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

test

parent 3b844f76
Loading
Loading
Loading
Loading
+332 −68

File changed.

Preview size limit exceeded, changes collapsed.

+3 −0
Changes for src/crypto/tls.h: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -402,6 +402,9 @@ namespace netplus {
        bool hasTLS13SV = false;
        bool hasTLS13KS = false;

        // --- Peer RSA key (client stores server's public key here) ---
        netplus::rsa peer_rsa;

        // --- Hostname (deprecated/legacy) ---
        std::string hostname;
        
+2 −2
Changes for src/event/epoll.cpp: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -338,8 +338,8 @@ namespace netplus {
                            }

                            // Drive the handshake state machine
                            // States that need input will throw Note if no data available
                            // States that only send output will proceed without input
                            // Use handshake_after_connect() for client sockets,
                            // handshake_after_accept() for server sockets
                            try {
                                c->csock->handshake_after_accept();
                            } catch (NetException& e) {
+2 −0
Changes for src/socket.h: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -194,6 +194,7 @@ namespace netplus {
		virtual size_t prime_recv(buffer& data, int flags = 0) { (void)data; (void)flags; return 0; }

		virtual bool getHandshakeDone() { return true; }
		virtual bool isClient() const { return false; }
		virtual bool hasBufferedData() const { return false; }
		virtual int  getSocketType() const { return _Type; }
		virtual bool hasPendingWrite() const { return _pendingIocpWrite.load(); }
@@ -369,6 +370,7 @@ namespace netplus {
		void setPendingWrite(bool pending) override { _pendingIocpWrite.store(pending); }

		bool getHandshakeDone() override { return _tls.getHandshakeDone(); }
		bool isClient() const override { return _tls.is_client; }

		virtual void queueRaw(const std::vector<uint8_t>& v) { _tls.queueRaw(v); }
		virtual void queueRaw(std::vector<uint8_t>&& v) { _tls.queueRaw(std::move(v)); }
+18 −0
Changes for src/ssl.cpp: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -102,12 +102,30 @@ void ssl::connect(const std::string& addr, int port, bool nonblock) {
    // First establish TCP connection
    tcp::connect(addr, port, nonblock);

    if (nonblock)
        setNonBlock();

    // Set up for client mode
    _tls.is_client = true;
    _tls.hostname = addr;
    _tls.setSocket(this);

    // Build and queue ClientHello, set state machine to flush it
    _tls.queueClientHello();
    _tls.hs_state = tls::HsState::CLI_FLUSH_CH;

    // For blocking connections, drive the handshake to completion.
    // For non-blocking, the caller (e.g. epoll event loop) will drive it.
    if (!nonblock) {
        while (!_tls.getHandshakeDone()) {
            // Flush any pending writes first
            while (_tls.hasPendingWrite()) {
                _tls.flush_out();
            }
            // Drive the handshake state machine
            _tls.handshake_after_connect();
        }
    }
}

// ============================================================================