cmd/atomdns/handlers/id/id.go
raw| 1 | package id |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "crypto/rand" |
| 6 | |
| 7 | "codeberg.org/miekg/dns" |
| 8 | "codeberg.org/miekg/dns/cmd/atomdns/internal/dnsctx" |
| 9 | ) |
| 10 | |
| 11 | type Id int |
| 12 | |
| 13 | func (i *Id) HandlerFunc(next dns.HandlerFunc) dns.HandlerFunc { |
| 14 | return dns.HandlerFunc(func(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) { |
| 15 | ctx = dnsctx.WithValue(ctx, dnsctx.Key(i, "id"), rand.Text()) |
| 16 | next.ServeDNS(ctx, w, r) |
| 17 | }) |
| 18 | } |