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

PacketConn interface #79

Open kayabe opened 3 years ago

kayabe commented 3 years ago

is it possible to add support for the udp net.PacketConn interface?

pires commented 3 years ago

I'm not familiar with that API type. What is your use case?

kayabe commented 3 years ago

a server that uses udp protocol

pires commented 3 years ago

UDP is already supported but this project could use some tests and/or examples doing UDP as well.

kayabe commented 3 years ago

using proxyproto.NewConn doesnt let me convert the proxyproto.Conn to net.PacketConn

func(c net.PacketConn) net.PacketConn {
        e := c.(net.Conn)
        d := proxyproto.NewConn(e)
        return d
}

errors:

cannot use d (variable of type *proxyproto.Conn) as net.PacketConn value in return statement: wrong type for method ReadFrom (have func(r io.Reader) (int64, error), want func(p []byte) (n int, addr net.Addr, err error))
pires commented 3 years ago

This library supports your use-case already, just not through the API type. I don't plan to work on this, I'm sorry. But I'll keep it open so that maybe someone shares the same need and we learn about it. Or maybe someone submits a patch.

shyam334 commented 2 years ago

Have a need to use it in a UDP server. Would be great to have support for this.