Commit 36af33e7 authored by jan.koester's avatar jan.koester
Browse files

test

parent 267b7f86
Loading
Loading
Loading
Loading
+22 −13
Original line number Diff line number Diff line
@@ -185,6 +185,11 @@ namespace netplus {

            _ServerSocket->accept(ccon->csock);

            if (!ccon || !ccon->csock) {
                // connection already closed/cleaned up
                return;
            }

            ccon->csock->setNonBlock();

            int fd = ccon->csock->fd();
@@ -195,7 +200,7 @@ namespace netplus {
            }

            struct epoll_event setevent = {0};
            setevent.events = EPOLLIN | EPOLLRDHUP | EPOLLONESHOT | EPOLLET; // kein EPOLLOUT
            setevent.events =EPOLLIN | EPOLLRDHUP | EPOLLONESHOT | EPOLLET;
            setevent.data.fd = fd;

            epoll_ctl(_pollFD, EPOLL_CTL_ADD, fd, &setevent);
@@ -228,31 +233,35 @@ namespace netplus {
                        rcv = rcon->csock->recvData(buf, 0);
                    } catch (NetException& e) {
                        if (e.getErrorType() == NetException::Note) {
                            // EAGAIN: Keine weiteren Daten im Kernel-Buffer
                            setpollEvents(pos, EPOLLIN | EPOLLONESHOT | EPOLLET | EPOLLRDHUP);
                            // Falls während des Handshakes Sendedaten (z.B. ServerHello)
                            // hängen geblieben sind, müssen wir auf EPOLLOUT warten
                            int event = EPOLLIN;
                            if (rcon->csock->_Type == sockettype::SSL && !rcon->SendData.empty())
                                event |= EPOLLOUT;

                            setpollEvents(pos, event | EPOLLONESHOT | EPOLLET | EPOLLRDHUP);
                            return;
                        }
                        throw; // Kritischer Fehler
                        throw;
                    }

                    if (rcv > 0) {
                        rcon->RecvData.append(buf.data.buf, rcv);
                        rcon->lasteventime = time(nullptr);
                        evconnection->RequestEvent(*rcon, tid, args);
                        // Nach dem RequestEvent brechen wir ab, damit die
                        // Antwort (SendData) im nächsten Schritt verarbeitet wird.
                        break;
                    } else { // rcv == 0
                        if (rcon->csock->_Type == sockettype::TCP) {
                            throw NetException() << "Client closed TCP connection";
                        }

                        if (!rcon->csock->getHandshakeDone()) {
                            continue;
                    } else {
                            throw NetException() << "Client closed SSL connection";
                        // rcv == 0: SSL Handshake Paket verarbeitet oder Connection Closed
                        if (rcon->csock->_Type == sockettype::SSL && !rcon->csock->getHandshakeDone()) {
                            continue;
                        }
                        throw NetException() << "Client closed connection";
                    }
                }
                // Entscheidung nach der Schleife: Müssen wir jetzt senden?

                // Nach der Schleife (wenn break aufgerufen wurde oder Handshake fertig ist)
                if (!rcon->SendData.empty()) {
                    setpollEvents(pos, EPOLLOUT | EPOLLONESHOT | EPOLLET | EPOLLRDHUP);
                } else {
+9 −7
Original line number Diff line number Diff line
@@ -310,6 +310,9 @@ namespace netplus {
		// --- Cryptographic Components ---
		netplus::x509cert _peer_cert;
		netplus::rsa _rsa;
		bool     _secureReneg = true;
		uint16_t _chosenSuite = 0x002F; // TLS_RSA_WITH_AES_128_CBC_SHA
		bool     _ccs_received = false;

		// Encryption engines (One for sending, one for receiving)
		std::unique_ptr<netplus::aes> _aes;      // Server Write Key (outbound)
@@ -373,7 +376,12 @@ namespace netplus {
			const std::vector<uint8_t>& data,
			ssl* csock
		);
		void _sendServerHello(ssl* csock, bool secureReneg);

		void _sendServerHello(
			ssl *csock,
			bool secureReneg,
			uint16_t suite
		);

		// PRF (Pseudo-Random Function) for Key Derivation
		std::vector<uint8_t> _prf(
@@ -394,14 +402,8 @@ namespace netplus {
			uint64_t seq,
			const std::vector<uint8_t>& macKey
		);
		std::vector<uint8_t> _decryptRecordCBC(
			uint8_t recType,
			uint16_t ver,
			const std::vector<uint8_t>& frag
		);

		std::vector<uint8_t> _decryptRecordCBC(
			netplus::ssl* cssock,
			uint8_t recType,
			uint16_t ver,
			const std::vector<uint8_t>& frag
+803 −417

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -358,7 +358,7 @@ void netplus::tcp::connect(std::unique_ptr<socket> &csock){
        exception[NetException::Error] << "Connect: getpeername failed on " << (int)_Socket << " error code : " << GetLastError();
        throw exception;
    }
    _Wait = true;
     _Wait = false;
}