go-proxyproto icon indicating copy to clipboard operation
go-proxyproto copied to clipboard

PacketConn interface

Open kayabe opened this issue 2 years ago • 6 comments

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

kayabe avatar Aug 24 '21 10:08 kayabe

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

pires avatar Aug 24 '21 10:08 pires

a server that uses udp protocol

kayabe avatar Aug 24 '21 10:08 kayabe

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

pires avatar Aug 24 '21 12:08 pires

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))

kayabe avatar Aug 24 '21 12:08 kayabe

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.

pires avatar Aug 26 '21 09:08 pires

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

shyam334 avatar Nov 21 '21 01:11 shyam334