Skip to content

Question: Divert socket seems to not be forwarding traffic back to original client #85

@apschultz

Description

@apschultz

I'm working on a modification to sslproxy to use addresses provided using the haproxy PROXY v1 protocol from the initial client TCP connection to allow easier redirection and load distribution without the need for complicated iptables which isn't available in all environments.

My test environment is the following

                     ┌───────────┐                     
                     │sslproxy   │                     
                     └─────▲─────┘                     
                           │                           
                           │                           
                           │                           
                     ┌─────▼─────┐                     
    ┌────────┐       │Python     │       ┌───────┐     
    │ Client ◄───────►Redirector ◄───────►Server │     
    └────────┘       └───────────┘       └───────┘     

All connections are made successfully; sslproxy reports TLS negotiation to client and server; the divert socket in the python redirector shows all data, unencrypted, and has no issues passing messages. tcpdump on the lo interface shows diverted responses coming back from sslproxy are received and sent back to sslproxy as well. However, sslproxy never passes the encrypted data back to the client socket.

I'm really struggling to debug this and would appreciate some thoughts.

The main code change is to prototcp_fd_readcb. I've added a handler that will peek the receive buffer, parse the PROXY header if present, and override srcaddr/dstaddr if the header is parsed successfully. In pxy_conn_init I have to bypass dstaddr handling as well.

The only odd thing I see in the packet capture is that there is 2 TCP connections sent from sslproxy to the divert port. The first remains unused/idle while the second receives the SSLproxy header and is where the decrypted traffic is sent back to.

log.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions