Cleaner handling of our own multicast queries

This commit is contained in:
Bryan Boreham committed 2014-10-03 16:42:02 +01:00
1 parent eedb6a1c30
commit c3f4c1a85f
2 files changed
+21 -2

No files matched your search

+17 -1
View File
@@ -73,7 +73,7 @@ func (c *MDNSClient) SendQuery(name string, querytype uint16, responseCh chan<-
c.Lock()
query, found := c.inflight[name]
if !found {
query = &inflightQuery{name: name}
query = &inflightQuery{name: name, Id: m.Id}
c.inflight[name] = query
}
info := &responseInfo{ch: responseCh}
@@ -97,6 +97,22 @@ func (c *MDNSClient) SendResponse(m *dns.Msg) error {
return err
}
func (c *MDNSClient) IsInflightQuery(m *dns.Msg) bool {
if len(m.Question) == 1 {
q := m.Question[0]
if q.Qtype == dns.TypeA {
c.Lock()
defer c.Unlock()
if query, found := c.inflight[q.Name]; found {
if query.Id == m.Id {
return true
}
}
}
}
return false
}
func (c *MDNSClient) HandleResponse(r *dns.Msg) {
for _, answer := range r.Answer {
switch rr := answer.(type) {