Debian Codegraph @

cmd/atomdns/handlers/tsig/tsig.go

raw
1 package tsig
2
3 import (
4 "context"
5
6 "codeberg.org/miekg/dns"
7 "codeberg.org/miekg/dns/cmd/atomdns/internal/dnsctx"
8 )
9
10 type Tsig struct {
11 TSIG *dns.TSIG
12 TSIGSecret string // base64
13 }
14
15 func (t *Tsig) HandlerFunc(next dns.HandlerFunc) dns.HandlerFunc {
16 return dns.HandlerFunc(func(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) {
17 // do the actual check
18 dnsctx.WithValue(ctx, dnsctx.Key(t, dnsctx.KeyStatus), true)
19 dnsctx.WithValue(ctx, dnsctx.Key(t, "name"), t.TSIG.Hdr.Name)
20 dnsctx.WithValue(ctx, dnsctx.Key(t, "secret"), t.TSIGSecret)
21 dnsctx.WithValue(ctx, dnsctx.Key(t, "algorithm"), t.TSIG.Algorithm)
22
23 next.ServeDNS(ctx, w, r)
24 })
25 }