Skip to content

Commit

Permalink
server_handler: fixed Truncate may use a changed udp size
Browse files Browse the repository at this point in the history
  • Loading branch information
IrineSistiana committed Sep 23, 2023
1 parent 23603c2 commit 50c1ab2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/server_handler/entry_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (

const (
defaultQueryTimeout = time.Second * 5
edns0Size = 1200
)

var (
Expand Down Expand Up @@ -78,6 +79,9 @@ func (h *EntryHandler) Handle(ctx context.Context, q *dns.Msg, qInfo server.Quer
ctx, cancel := context.WithDeadline(ctx, ddl)
defer cancel()

// Get udp size before exec plugins. It may be changed by plugins.
queryUdpSize := getUDPSize(q)

// exec entry
qCtx := query_context.NewContext(q, qInfo)
err := h.opts.Entry.Exec(ctx, qCtx)
Expand All @@ -99,7 +103,7 @@ func (h *EntryHandler) Handle(ctx context.Context, q *dns.Msg, qInfo server.Quer
respMsg.RecursionAvailable = true

if qInfo.FromUDP {
respMsg.Truncate(getUDPSize(q))
respMsg.Truncate(queryUdpSize)
}

payload, err := packMsgPayload(respMsg)
Expand Down

0 comments on commit 50c1ab2

Please sign in to comment.