From fa29c9640b88b5d9434c16d6feaac4dc5a42c655 Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Wed, 9 Oct 2024 13:18:09 +0300 Subject: [PATCH] feat: serve dns on tcp too --- cmd/felu/main.go | 8 ++++++-- internal/dns/server.go | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/felu/main.go b/cmd/felu/main.go index fe66827..36d203b 100644 --- a/cmd/felu/main.go +++ b/cmd/felu/main.go @@ -77,9 +77,13 @@ func main() { dnsIP := config.FeluConfig.DNSBindIP dnsPort := strconv.Itoa(int(config.FeluConfig.DNSBindPort)) dnsAddr := dnsIP + ":" + dnsPort - slog.Info("Serving DNS", slog.String("addr", dnsAddr)) + slog.Info("Serving DNS (udp)", slog.String("addr", dnsAddr)) g.Go(func() error { - return dns.Run(dnsAddr) + return dns.Run(dnsAddr, "udp") + }) + slog.Info("Serving DNS (tcp)", slog.String("addr", dnsAddr)) + g.Go(func() error { + return dns.Run(dnsAddr, "tcp") }) if err := g.Wait(); err != nil { diff --git a/internal/dns/server.go b/internal/dns/server.go index 008d11e..c92b499 100644 --- a/internal/dns/server.go +++ b/internal/dns/server.go @@ -14,12 +14,12 @@ import ( ) // Run starts the DNS server. -func Run(addr string) error { +func Run(addr string, net string) error { dns.HandleFunc(config.FeluConfig.DNSPattern, handleDNSRequest) server := &dns.Server{ Addr: addr, - Net: "udp", + Net: net, } return server.ListenAndServe() -- 2.44.1