Debian Codegraph @

cmd/atomdns/atomtest/handler.go

raw
1 package atomtest
2
3 import (
4 "context"
5 "io"
6
7 "codeberg.org/miekg/dns"
8 "codeberg.org/miekg/dns/cmd/atomdns/internal/dnsctx"
9 "codeberg.org/miekg/dns/dnsutil"
10 )
11
12 // Echo is a [dns.HandlerFunc] that echos the message m. Any dnsctx.Funcs set in the context are run.
13 var Echo = dns.HandlerFunc(func(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) {
14 m := new(dns.Msg)
15 dnsutil.SetReply(m, r)
16 m = dnsctx.Funcs(ctx, m)
17 if err := m.Pack(); err != nil {
18 return
19 }
20 io.Copy(w, m)
21 })
22
23 // Noop is a [dns.HandlerFunc] that does nothing.
24 var Noop = dns.HandlerFunc(func(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) {})