Add RemoteAddr() to the RequestWriter interface
This commit is contained in:
parent
2385ca18a3
commit
2574856aa6
17
client.go
17
client.go
|
@ -15,7 +15,11 @@ type QueryHandler interface {
|
||||||
// The RequestWriter interface is used by a DNS query handler to
|
// The RequestWriter interface is used by a DNS query handler to
|
||||||
// construct a DNS request.
|
// construct a DNS request.
|
||||||
type RequestWriter interface {
|
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
|
Write(*Msg) error
|
||||||
// Send sends the message to the server.
|
// Send sends the message to the server.
|
||||||
Send(*Msg) error
|
Send(*Msg) error
|
||||||
|
@ -25,8 +29,6 @@ type RequestWriter interface {
|
||||||
Close() error
|
Close() error
|
||||||
// Dials calls the server.
|
// Dials calls the server.
|
||||||
Dial() error
|
Dial() error
|
||||||
// TsigStatus returns the TSIG validation status.
|
|
||||||
TsigStatus() error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// hijacked connections...?
|
// hijacked connections...?
|
||||||
|
@ -222,6 +224,15 @@ func (w *reply) Write(m *Msg) error {
|
||||||
return nil
|
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
|
// Do performs an asynchronous query. The result is returned on the
|
||||||
// QueryChan channel set in the *Client c. Basic use pattern for
|
// QueryChan channel set in the *Client c. Basic use pattern for
|
||||||
// sending message m to the server listening on port 53 on localhost
|
// sending message m to the server listening on port 53 on localhost
|
||||||
|
|
|
@ -24,6 +24,7 @@ func q(w dns.RequestWriter, m *dns.Msg) {
|
||||||
w.Write(nil)
|
w.Write(nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
w.Close()
|
||||||
if w.TsigStatus() != nil {
|
if w.TsigStatus() != nil {
|
||||||
fmt.Printf(";; Couldn't verify TSIG signature: %s\n", w.TsigStatus().Error())
|
fmt.Printf(";; Couldn't verify TSIG signature: %s\n", w.TsigStatus().Error())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue