Skip to content

Commit

Permalink
s/InvalidMsg/MsgInvalid/g
Browse files Browse the repository at this point in the history
  • Loading branch information
bemasc committed Jun 13, 2024
1 parent d4e3566 commit caf25b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion acceptfunc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestInvalidMsg(t *testing.T) {
}

invalidErrors := make(chan error)
s.InvalidMsgFunc = func(m []byte, err error) {
s.MsgInvalidFunc = func(m []byte, err error) {
invalidErrors <- err
}

Expand Down
16 changes: 8 additions & 8 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ type DecorateWriter func(Writer) Writer
// rejected (or ignored) by the MsgAcceptFunc, or passed to this function.
type InvalidMsgFunc func(m []byte, err error)

func DefaultInvalidMsgFunc(m []byte, err error) {}
func DefaultMsgInvalidFunc(m []byte, err error) {}

// A Server defines parameters for running an DNS server.
type Server struct {
Expand Down Expand Up @@ -241,8 +241,8 @@ type Server struct {
// AcceptMsgFunc will check the incoming message and will reject it early in the process.
// By default DefaultMsgAcceptFunc will be used.
MsgAcceptFunc MsgAcceptFunc
// InvalidMsgFunc is optional, will be called if a message is received but cannot be parsed.
InvalidMsgFunc InvalidMsgFunc
// MsgInvalidFunc is optional, will be called if a message is received but cannot be parsed.
MsgInvalidFunc InvalidMsgFunc

// Shutdown handling
lock sync.RWMutex
Expand Down Expand Up @@ -287,8 +287,8 @@ func (srv *Server) init() {
if srv.MsgAcceptFunc == nil {
srv.MsgAcceptFunc = DefaultMsgAcceptFunc
}
if srv.InvalidMsgFunc == nil {
srv.InvalidMsgFunc = DefaultInvalidMsgFunc
if srv.MsgInvalidFunc == nil {
srv.MsgInvalidFunc = DefaultMsgInvalidFunc
}
if srv.Handler == nil {
srv.Handler = DefaultServeMux
Expand Down Expand Up @@ -544,7 +544,7 @@ func (srv *Server) serveUDP(l net.PacketConn) error {
if cap(m) == srv.UDPSize {
srv.udpPool.Put(m[:srv.UDPSize])
}
srv.InvalidMsgFunc(m, ErrShortRead)
srv.MsgInvalidFunc(m, ErrShortRead)
continue
}
wg.Add(1)
Expand Down Expand Up @@ -625,7 +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.InvalidMsgFunc(m, err)
srv.MsgInvalidFunc(m, err)
// Let client hang, they are sending crap; any reply can be used to amplify.
return
}
Expand All @@ -640,7 +640,7 @@ func (srv *Server) serveDNS(m []byte, w *response) {
break
}

srv.InvalidMsgFunc(m, err)
srv.MsgInvalidFunc(m, err)
fallthrough
case MsgReject, MsgRejectNotImplemented:
opcode := req.Opcode
Expand Down

0 comments on commit caf25b3

Please sign in to comment.