Support "insistent" queries in the mDNS client, used for obtaining all possible responses from mDNS servers.

Support for multiple responses from Lookup*() methods
Support for multiple records when building packets with make*() methods
Use a common "ZoneRecord" interface for structs that contain names and IPs
This commit is contained in:
Alvaro Saurin committed 2015-04-23 13:01:29 +02:00
1 parent ec29c2c776
commit 58c8945b32
17 files changed
+504 -216

No files matched your search

+3 -2
View File
@@ -247,6 +247,7 @@ func (c *Cache) Purge(now time.Time) {
}
// Add adds a reply to the cache.
// When `ttl` is equal to `nullTTL`, the cache entry will be valid until the closest TTL in the `reply`
func (c *Cache) Put(request *dns.Msg, reply *dns.Msg, ttl int, flags uint8, now time.Time) int {
c.lock.Lock()
defer c.lock.Unlock()
@@ -274,8 +275,7 @@ func (c *Cache) Put(request *dns.Msg, reply *dns.Msg, ttl int, flags uint8, now
}
// Look up for a question's reply from the cache.
// If no reply is stored in the cache, it returns a `nil` reply and no error. The caller can then `Wait()`
// for another goroutine `Put`ing a reply in the cache.
// If no reply is stored in the cache, it returns a `nil` reply and no error.
func (c *Cache) Get(request *dns.Msg, maxLen int, now time.Time) (reply *dns.Msg, err error) {
c.lock.Lock()
defer c.lock.Unlock()
@@ -307,6 +307,7 @@ func (c *Cache) Remove(question *dns.Question) {
key := cacheKey(*question)
if entry, found := c.entries[key]; found {
Debug.Printf("[cache] removing %s-response for '%s'", dns.TypeToString[question.Qtype], question.Name)
if entry.index > 0 {
heap.Remove(&c.entriesH, entry.index)
}