pires / go-proxyproto

A Go library implementation of the PROXY protocol, versions 1 and 2.
Apache License 2.0
478 stars 107 forks source link

Add Support for "ProxyHeaderTimeout" #65

Closed tecnobrat closed 3 years ago

tecnobrat commented 3 years ago

This library seems to lean heavily on inspiration from https://github.com/armon/go-proxyproto

That library supports passing in a timeout when you define the listener:

        tln = &proxyproto.Listener{
            Listener:           tln,
            ProxyHeaderTimeout: l.ProxyHeaderTimeout,
        }

It would be nice if the same feature, or a similar feature was possible with this library.

pires commented 3 years ago

Can you please describe the requirement instead? What is is the problem you're running into?

unmarshal commented 3 years ago

+1. The problem is that a malicious client can open thousands of tcp connections and not send the proxy protocol header. The server will hold those socket descriptors open indefinitely, eventually running out of resources. I'll take a crack at making a pull request.

unmarshal commented 3 years ago

For your consideration: https://github.com/pires/go-proxyproto/pull/74

Excellent library by the way. I am planning on using this in production.

tecnobrat commented 3 years ago

Thank you @unmarshal!

Sorry I didn't see your question before @pires. My motivation is a little different, but @unmarshal is right on the technical reasoning.

My motivation is that I would like to add proxy v2 support to https://github.com/fabiolb/fabio and they already make use of ProxyHeaderTimeout, so for me to be able to swap their implementation to this library, I'd need that support.

Not great motivation for this project, but thats my personal motivation!

unmarshal commented 3 years ago

Hi @tecnobrat, does that mean you would prefer it be called ProxyHeaderTimeout?

tecnobrat commented 3 years ago

@unmarshal I don't think the naming matters, it just means I'll need to do:

        ln = &proxyproto.Listener{
            Listener:           ln,
            ReadHeaderTimeout: l.ProxyHeaderTimeout,
        }

No big deal :)

pires commented 3 years ago

Thanks for sharing, @tecnobrat.

pires commented 3 years ago

This has been addressed by #74.