From 2f76e37d59f15d556726964414f5b16a397a2fe6 Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Wed, 9 Oct 2024 13:26:51 +0300 Subject: [PATCH] feat: improve logging in parseQuery --- internal/dns/query.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/internal/dns/query.go b/internal/dns/query.go index 90a1be6..b0f839f 100644 --- a/internal/dns/query.go +++ b/internal/dns/query.go @@ -18,16 +18,25 @@ import ( func parseQuery(m *dns.Msg, r *dns.Msg) { for _, q := range m.Question { + slog.Info("Got Query", + slog.Any("id", r.Id), + slog.String("type", dns.TypeToString[q.Qtype]), + slog.String("qname", q.Name), + ) + switch q.Qtype { case dns.TypeA: handleARecord(&q, m, r) } + + slog.Info("Responding to Query", + slog.Any("id", r.Id), + slog.String("rcode", dns.RcodeToString[m.Rcode]), + ) } } func handleARecord(q *dns.Question, m *dns.Msg, r *dns.Msg) { - slog.Info("A Record Query", slog.String("qname", q.Name)) - if index := strings.IndexByte(q.Name, '.'); index >= 0 { aRecord, err := db.FetchDomainARecord(strings.ToLower(q.Name[:index])) if err != nil { -- 2.44.1