chore: update deps
This commit is contained in:
parent
95803010d5
commit
d514cf41c3
525 changed files with 43230 additions and 14901 deletions
29
vendor/github.com/miekg/dns/server.go
generated
vendored
29
vendor/github.com/miekg/dns/server.go
generated
vendored
|
@ -188,6 +188,14 @@ type DecorateReader func(Reader) Reader
|
|||
// Implementations should never return a nil Writer.
|
||||
type DecorateWriter func(Writer) Writer
|
||||
|
||||
// MsgInvalidFunc is a listener hook for observing incoming messages that were discarded
|
||||
// because they could not be parsed.
|
||||
// Every message that is read by a Reader will eventually be provided to the Handler,
|
||||
// rejected (or ignored) by the MsgAcceptFunc, or passed to this function.
|
||||
type MsgInvalidFunc func(m []byte, err error)
|
||||
|
||||
func DefaultMsgInvalidFunc(m []byte, err error) {}
|
||||
|
||||
// A Server defines parameters for running an DNS server.
|
||||
type Server struct {
|
||||
// Address to listen on, ":dns" if empty.
|
||||
|
@ -226,9 +234,15 @@ type Server struct {
|
|||
// Whether to set the SO_REUSEPORT socket option, allowing multiple listeners to be bound to a single address.
|
||||
// It is only supported on certain GOOSes and when using ListenAndServe.
|
||||
ReusePort bool
|
||||
// Whether to set the SO_REUSEADDR socket option, allowing multiple listeners to be bound to a single address.
|
||||
// Crucially this allows binding when an existing server is listening on `0.0.0.0` or `::`.
|
||||
// It is only supported on certain GOOSes and when using ListenAndServe.
|
||||
ReuseAddr bool
|
||||
// AcceptMsgFunc will check the incoming message and will reject it early in the process.
|
||||
// By default DefaultMsgAcceptFunc will be used.
|
||||
MsgAcceptFunc MsgAcceptFunc
|
||||
// MsgInvalidFunc is optional, will be called if a message is received but cannot be parsed.
|
||||
MsgInvalidFunc MsgInvalidFunc
|
||||
|
||||
// Shutdown handling
|
||||
lock sync.RWMutex
|
||||
|
@ -273,6 +287,9 @@ func (srv *Server) init() {
|
|||
if srv.MsgAcceptFunc == nil {
|
||||
srv.MsgAcceptFunc = DefaultMsgAcceptFunc
|
||||
}
|
||||
if srv.MsgInvalidFunc == nil {
|
||||
srv.MsgInvalidFunc = DefaultMsgInvalidFunc
|
||||
}
|
||||
if srv.Handler == nil {
|
||||
srv.Handler = DefaultServeMux
|
||||
}
|
||||
|
@ -304,7 +321,7 @@ func (srv *Server) ListenAndServe() error {
|
|||
|
||||
switch srv.Net {
|
||||
case "tcp", "tcp4", "tcp6":
|
||||
l, err := listenTCP(srv.Net, addr, srv.ReusePort)
|
||||
l, err := listenTCP(srv.Net, addr, srv.ReusePort, srv.ReuseAddr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -317,7 +334,7 @@ func (srv *Server) ListenAndServe() error {
|
|||
return errors.New("dns: neither Certificates nor GetCertificate set in Config")
|
||||
}
|
||||
network := strings.TrimSuffix(srv.Net, "-tls")
|
||||
l, err := listenTCP(network, addr, srv.ReusePort)
|
||||
l, err := listenTCP(network, addr, srv.ReusePort, srv.ReuseAddr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -327,7 +344,7 @@ func (srv *Server) ListenAndServe() error {
|
|||
unlock()
|
||||
return srv.serveTCP(l)
|
||||
case "udp", "udp4", "udp6":
|
||||
l, err := listenUDP(srv.Net, addr, srv.ReusePort)
|
||||
l, err := listenUDP(srv.Net, addr, srv.ReusePort, srv.ReuseAddr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -527,6 +544,7 @@ func (srv *Server) serveUDP(l net.PacketConn) error {
|
|||
if cap(m) == srv.UDPSize {
|
||||
srv.udpPool.Put(m[:srv.UDPSize])
|
||||
}
|
||||
srv.MsgInvalidFunc(m, ErrShortRead)
|
||||
continue
|
||||
}
|
||||
wg.Add(1)
|
||||
|
@ -607,6 +625,7 @@ func (srv *Server) serveUDPPacket(wg *sync.WaitGroup, m []byte, u net.PacketConn
|
|||
func (srv *Server) serveDNS(m []byte, w *response) {
|
||||
dh, off, err := unpackMsgHdr(m, 0)
|
||||
if err != nil {
|
||||
srv.MsgInvalidFunc(m, err)
|
||||
// Let client hang, they are sending crap; any reply can be used to amplify.
|
||||
return
|
||||
}
|
||||
|
@ -616,10 +635,12 @@ func (srv *Server) serveDNS(m []byte, w *response) {
|
|||
|
||||
switch action := srv.MsgAcceptFunc(dh); action {
|
||||
case MsgAccept:
|
||||
if req.unpack(dh, m, off) == nil {
|
||||
err := req.unpack(dh, m, off)
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
|
||||
srv.MsgInvalidFunc(m, err)
|
||||
fallthrough
|
||||
case MsgReject, MsgRejectNotImplemented:
|
||||
opcode := req.Opcode
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue