fastdns icon indicating copy to clipboard operation
fastdns copied to clipboard

Allow `net.PacketConn` parameter

Open mrmelon54 opened this issue 1 year ago • 2 comments

Would be nice to accept a net.PacketConn parameter as well as addr string (see examples below).

https://github.com/phuslu/fastdns/blob/52d1cc6ef647a255b10ba0e78b3d492b96d405b7/server.go#L37

func (s *Server) ListenAndServe(conn net.PacketConn) error {

I use cloudflare/tableflip and this addition would enable usage of the tableflip supported UDP listener.

ListenPacket: https://github.com/cloudflare/tableflip/blob/b3a0d54308fba327fb463cc1a3c11d3607deea53/fds.go#L201-L204

mrmelon54 avatar Dec 02 '24 00:12 mrmelon54

make sense, let me take a look.

phuslu avatar Dec 02 '24 01:12 phuslu

A quick fix added https://github.com/phuslu/fastdns/commit/9b90ed22dd18f223064ec254624ad15f90efa5ee and I tagged v0.12.1

But I'm not happy with this becuase it lost "reuse_port" ability, let me try to figure out a better way.

phuslu avatar Dec 02 '24 08:12 phuslu