Merge pull request #103 from innoying/master

Add support for ResponseWriter.LocalAddr()
This commit is contained in:
Miek Gieben 2014-07-27 19:06:09 +01:00
commit d178b7da2f
1 changed files with 10 additions and 0 deletions

View File

@ -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,14 @@ 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()
}
return w.udp.LocalAddr()
}
// RemoteAddr implements the ResponseWriter.RemoteAddr method.
func (w *response) RemoteAddr() net.Addr { return w.remoteAddr }