Commit 1fc759cc authored by jan.koester's avatar jan.koester
Browse files

test

parent ca4cf4b8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -17,3 +17,4 @@ reproduce_issue.cpp
silence_logs.py
test_openssl.sh
test_tls_client.py
*.log
 No newline at end of file
+11 −0
Original line number Diff line number Diff line
@@ -4,6 +4,17 @@
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
    {
        "name": "(Windows) Launch HTTPS Test",
        "type": "cppvsdbg",
        "request": "launch",
        "program": "${workspaceFolder}/build/test/Debug/https_test.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "console": "externalTerminal"
    },
    {
        "name": "(Windows) Launch",
        "type": "cppvsdbg",

server_output.txt

0 → 100644
+0 −0

File added.

Preview suppressed by a .gitattributes entry or the file's encoding is unsupported.

simple_test.py

0 → 100644
+47 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3
import socket
import ssl
import sys

def test_connection():
    # Create SSL context
    context = ssl.create_default_context()
    context.check_hostname = False
    context.verify_mode = ssl.CERT_NONE
    
    # Create socket
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    
    try:
        # Connect
        print("Connecting to 127.0.0.1:8443...")
        sock.connect(('127.0.0.1', 8443))
        
        # Wrap with SSL
        print("Starting TLS handshake...")
        ssock = context.wrap_socket(sock, server_hostname='127.0.0.1')
        
        print("TLS handshake successful!")
        print(f"Protocol: {ssock.version}")
        print(f"Cipher: {ssock.cipher()}")
        
        # Send request
        print("Sending HTTP request...")
        ssock.sendall(b"GET / HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n")
        
        # Receive response
        print("Receiving response...")
        data = ssock.recv(4096)
        print(f"Received {len(data)} bytes")
        print(data.decode('utf-8', errors='ignore')[:200])
        
        ssock.close()
    except Exception as e:
        print(f"Error: {e}")
        import traceback
        traceback.print_exc()
    finally:
        sock.close()

if __name__ == '__main__':
    test_connection()
+30 −5
Original line number Diff line number Diff line
@@ -415,9 +415,18 @@ namespace netplus {
                continue;
            }

            buffer* buf = reinterpret_cast<buffer*>(
            // Calculate buffer from overlapped offset
            // CRITICAL: pov might point to offset within WSAOVERLAPPED field
            buffer* buf = nullptr;
            if (pov) {
                buf = reinterpret_cast<buffer*>(
                    reinterpret_cast<char*>(pov) - offsetof(buffer, overlapped)
                );
            }
            if (!buf) {
                std::cerr << "[IOCP] buf calculation failed, pov=" << pov << std::endl;
                continue;
            }

            // Look up connection by socket fd (key is the socket*)
            SOCKET cs = (SOCKET)sockObj->fd();
@@ -517,7 +526,16 @@ namespace netplus {
                    // CRITICAL: flush_out() posts WSASend ASYNCHRONOUSLY in IOCP mode
                    if (owner->csock->hasPendingWrite()) {
                        std::cerr << "[IOCP] Flushing handshake response, posting async WSASend..." << std::endl;
                        try {
                            owner->csock->flush_out();
                        } catch (NetException& flushEx) {
                            if (flushEx.getErrorType() == NetException::Note) {
                                std::cerr << "[IOCP] flush_out Note - buffer full, will retry" << std::endl;
                            } else {
                                std::cerr << "[IOCP] flush_out error: " << flushEx.what() << std::endl;
                                throw;
                            }
                        }
                        std::cerr << "[IOCP] flush_out posted - now continuing in READ handler" << std::endl;
                        // After posting async write, DON'T try to recv more data yet.
                        // The write completion handler will decide what's next.
@@ -622,7 +640,14 @@ namespace netplus {
                        // If there's more data to send, flush it
                        if (owner->csock->hasPendingWrite()) {
                            std::cerr << "[IOCP] More data to send, flushing..." << std::endl;
                            try {
                                owner->csock->flush_out();
                            } catch (NetException& flushEx) {
                                if (flushEx.getErrorType() != NetException::Note) {
                                    throw;
                                }
                                std::cerr << "[IOCP] flush_out returned Note during handshake continuation" << std::endl;
                            }
                        }
                    } catch (NetException& e) {
                        if (e.getErrorType() == NetException::Note) {
Loading