From eb98accb64ea232136b5344464ed1d66d40f6196 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Thu, 12 Feb 2015 18:22:57 -0800 Subject: [PATCH] Revert "Send response to multicast address if requested" This reverts commit c6d75aa8ab07e215beb8c1315155e55d3ca830c6. Conflicts: server.go --- server.go | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/server.go b/server.go index 4f2799d..55988c4 100644 --- a/server.go +++ b/server.go @@ -267,6 +267,8 @@ func (s *Server) handleQuestion(q dns.Question) (multicastRecs, unicastRecs []dn // sendResponse is used to send a response packet 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() if err != nil { 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 addr := from.(*net.UDPAddr) - var conn *net.UDPConn if addr.IP.To4() != nil { - conn = s.ipv4List + _, err = s.ipv4List.WriteToUDP(buf, addr) + return err } 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 }