@@ -69,6 +69,7 @@ func (m MDNS) AddARecord(msg *dns.Msg, state *request.Request, name string, addr
6969}
7070
7171func (m MDNS ) ServeDNS (ctx context.Context , w dns.ResponseWriter , r * dns.Msg ) (int , error ) {
72+ // If systemd-resolved isn't available, plugin can't do anything. Pass to the next one.
7273 if m .Resolver == nil {
7374 return plugin .NextOrFailure (m .Name (), m .Next , ctx , w , r )
7475 }
@@ -99,14 +100,16 @@ func (m MDNS) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i
99100 // There may be uncommon errors though so not swallowing it while debugging
100101 log .Debug (err )
101102
102- } else if m .AddARecord (msg , & state , hostName , addresses ) {
103+ } else {
104+ m .AddARecord (msg , & state , hostName , addresses )
103105 log .Debug (msg )
104- w .WriteMsg (msg )
105- return dns .RcodeSuccess , nil
106106 }
107107
108- log .Debugf ("No records found for '%s', forwarding to next plugin." , state .QName ())
109- return plugin .NextOrFailure (m .Name (), m .Next , ctx , w , r )
108+ // Plugin only processes A and AAAA type multicast queries (.local or single name)
109+ // Whether an answer was found or not this is end of the line, do not forward to external resolvers
110+ // Always return NOERROR since we are not authoritative for this domain
111+ w .WriteMsg (msg )
112+ return dns .RcodeSuccess , nil
110113}
111114
112115func GetPrimaryInterface (ctx context.Context , resolver * resolve1.Manager ) int32 {
0 commit comments