From 12f91af6ed1cd4aa5910843eab0f3c2dda8a0fa3 Mon Sep 17 00:00:00 2001 From: Luke Young Date: Sun, 27 Jul 2014 10:43:07 -0700 Subject: [PATCH 1/2] Added ResponseWriter.LocalAddr support --- server.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/server.go b/server.go index a514ad09..ca497b23 100644 --- a/server.go +++ b/server.go @@ -21,6 +21,8 @@ type Handler interface { // A ResponseWriter interface is used by an DNS handler to // construct an DNS response. type ResponseWriter interface { + // LocalAddr returns the net.Addr of the server + LocalAddr() net.Addr // RemoteAddr returns the net.Addr of the client that sent the current request. RemoteAddr() net.Addr // WriteMsg writes a reply back to the client. @@ -483,6 +485,15 @@ func (w *response) Write(m []byte) (int, error) { panic("not reached") } +// LocalAddr implements the ResponseWriter.LocalAddr method. +func (w *response) LocalAddr() net.Addr { + if w.tcp != nil { + return w.tcp.LocalAddr() + } else { + return w.udp.LocalAddr() + } +} + // RemoteAddr implements the ResponseWriter.RemoteAddr method. func (w *response) RemoteAddr() net.Addr { return w.remoteAddr } From 0a6f133b265486f6c59ca6ae3f5d93e97bd5dfd6 Mon Sep 17 00:00:00 2001 From: Luke Young Date: Sun, 27 Jul 2014 10:44:39 -0700 Subject: [PATCH 2/2] Match format of other code --- server.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server.go b/server.go index ca497b23..6c5f1f10 100644 --- a/server.go +++ b/server.go @@ -489,9 +489,8 @@ func (w *response) Write(m []byte) (int, error) { func (w *response) LocalAddr() net.Addr { if w.tcp != nil { return w.tcp.LocalAddr() - } else { - return w.udp.LocalAddr() } + return w.udp.LocalAddr() } // RemoteAddr implements the ResponseWriter.RemoteAddr method.