Revert "Send response to multicast address if requested"
This reverts commit c6d75aa8ab
.
Conflicts:
server.go
This commit is contained in:
parent
e4aba3430c
commit
eb98accb64
26
server.go
26
server.go
@ -267,6 +267,8 @@ func (s *Server) handleQuestion(q dns.Question) (multicastRecs, unicastRecs []dn
|
|||||||
|
|
||||||
// sendResponse is used to send a response packet
|
// sendResponse is used to send a response packet
|
||||||
func (s *Server) sendResponse(resp *dns.Msg, from net.Addr, unicast bool) error {
|
func (s *Server) sendResponse(resp *dns.Msg, from net.Addr, unicast bool) error {
|
||||||
|
// TODO(reddaly): Respect the unicast argument, and allow sending responses
|
||||||
|
// over multicast.
|
||||||
buf, err := resp.Pack()
|
buf, err := resp.Pack()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -274,27 +276,11 @@ func (s *Server) sendResponse(resp *dns.Msg, from net.Addr, unicast bool) error
|
|||||||
|
|
||||||
// Determine the socket to send from
|
// Determine the socket to send from
|
||||||
addr := from.(*net.UDPAddr)
|
addr := from.(*net.UDPAddr)
|
||||||
var conn *net.UDPConn
|
|
||||||
if addr.IP.To4() != nil {
|
if addr.IP.To4() != nil {
|
||||||
conn = s.ipv4List
|
_, err = s.ipv4List.WriteToUDP(buf, addr)
|
||||||
|
return err
|
||||||
} else {
|
} else {
|
||||||
conn = s.ipv6List
|
_, err = s.ipv6List.WriteToUDP(buf, addr)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the address to send to if not unicast
|
|
||||||
if !unicast {
|
|
||||||
if addr.IP.To4() != nil {
|
|
||||||
addr = ipv4Addr
|
|
||||||
} else {
|
|
||||||
addr = ipv6Addr
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Guard against a missing connection or address
|
|
||||||
if conn == nil || addr == nil {
|
|
||||||
return fmt.Errorf("Unable to respond, missing connection (%v) or address (%v)",
|
|
||||||
conn, addr)
|
|
||||||
}
|
|
||||||
_, err = conn.WriteToUDP(buf, addr)
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user