diff --git a/client.go b/client.go index 981fd8ef..9cb47a75 100644 --- a/client.go +++ b/client.go @@ -15,7 +15,11 @@ type QueryHandler interface { // The RequestWriter interface is used by a DNS query handler to // construct a DNS request. type RequestWriter interface { - // Write returns the request message and the reply back to the client. + // RemoteAddr returns the net.Addr of the server + RemoteAddr() net.Addr + // TsigStatus returns the TSIG validation status. + TsigStatus() error + // Write returns the request message and the reply back to the client (i.e. your Go code). Write(*Msg) error // Send sends the message to the server. Send(*Msg) error @@ -25,8 +29,6 @@ type RequestWriter interface { Close() error // Dials calls the server. Dial() error - // TsigStatus returns the TSIG validation status. - TsigStatus() error } // hijacked connections...? @@ -222,6 +224,15 @@ func (w *reply) Write(m *Msg) error { return nil } +func (w *reply) RemoteAddr() net.Addr { + if w.conn == nil { + return nil + } else { + return w.conn.RemoteAddr() + } + return nil +} + // Do performs an asynchronous query. The result is returned on the // QueryChan channel set in the *Client c. Basic use pattern for // sending message m to the server listening on port 53 on localhost diff --git a/ex/q/q.go b/ex/q/q.go index 32745987..c8b1bf30 100644 --- a/ex/q/q.go +++ b/ex/q/q.go @@ -24,6 +24,7 @@ func q(w dns.RequestWriter, m *dns.Msg) { w.Write(nil) return } + w.Close() if w.TsigStatus() != nil { fmt.Printf(";; Couldn't verify TSIG signature: %s\n", w.TsigStatus().Error()) }