From 4a077f4170e20124ad3415ad1a4ccdd0d1218f2a Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Mon, 25 Nov 2024 07:48:13 +0100 Subject: [PATCH] refactor(dnscoretest): embed io.Writer in ResponseWriter (#11) This is more clear, obvious, and idiomatic. While there, document by NewServerAddr constructs a pointer and other API functions expect a `*ServerAddr` value. --- dnscoretest/handler.go | 3 ++- serveraddr.go | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dnscoretest/handler.go b/dnscoretest/handler.go index c34c98d..d22574c 100644 --- a/dnscoretest/handler.go +++ b/dnscoretest/handler.go @@ -3,6 +3,7 @@ package dnscoretest import ( + "io" "net" "github.com/miekg/dns" @@ -11,7 +12,7 @@ import ( // ResponseWriter allows writing raw DNS responses. type ResponseWriter interface { - Write(rawMsg []byte) (int, error) + io.Writer } // Handler is a function that handles a DNS query. diff --git a/serveraddr.go b/serveraddr.go index 4cdd72a..720a06a 100644 --- a/serveraddr.go +++ b/serveraddr.go @@ -21,6 +21,10 @@ const ( // ServerAddr is a DNS server address. // +// While currently minimal, ServerAddr is designed as a pointer type to +// allow for future extensions of server-specific properties (e.g., custom +// headers for DoH) without requiring breaking API changes. +// // Construct using [NewServerAddr]. type ServerAddr struct { // Protocol is the transport protocol to use.