Hi @armon
This issue is probably my misunderstood, but I ask you for check.
Situation
I use mdns.Lookup
:
package main
import (
"github.com/armon/mdns"
"fmt"
)
func main() {
entriesCh := make(chan *mdns.ServiceEntry, 1)
go func() {
for entry := range entriesCh {
fmt.Printf("Got new entry: %v\n", entry)
}
}()
mdns.Lookup("_airplay._tcp", entriesCh)
close(entriesCh)
}
Then run $ go run main.go
, nothing is printed.
But I was able to search using dns-sd
command:
$ dns-sd -L "Apple TV" _airplay._tcp
Lookup Apple TV._airplay._tcp.local
DATE: ---Tue 20 May 2014---
21:54:29.174 ...STARTING...
21:54:29.299 Apple TV._airplay._tcp.local. can be reached at AppleTV.local.:7000 (interface 4)
deviceid=(skip...)
Print debug
I tried to fix client.go
based on 8be7e3ac
diff --git a/client.go b/client.go
index d449e4d..cfebe63 100644
--- a/client.go
+++ b/client.go
@@ -186,17 +186,20 @@ func (c *client) query(params *QueryParam) error {
case *dns.PTR:
// Create new entry for this
inp = ensureName(inprogress, rr.Ptr)
+ fmt.Printf("PTR: %v\n", rr)
case *dns.SRV:
// Get the port
inp = ensureName(inprogress, rr.Target)
inp.Port = int(rr.Port)
+ fmt.Printf("SRV: %v\n", rr)
case *dns.TXT:
// Pull out the txt
inp = ensureName(inprogress, rr.Hdr.Name)
inp.Info = strings.Join(rr.Txt, "|")
inp.hasTXT = true
+ fmt.Printf("TXT: %v\n", rr)
case *dns.A:
// Pull out the IP
@@ -209,7 +212,7 @@ func (c *client) query(params *QueryParam) error {
inp.Addr = rr.AAAA
}
}
-
+ fmt.Printf(" inp = %v\n", inp)
// Check if this entry is complete
if inp.complete() && !inp.sent {
inp.sent = true
@@ -221,10 +224,12 @@ func (c *client) query(params *QueryParam) error {
// Fire off a node specific query
m := new(dns.Msg)
m.SetQuestion(inp.Name, dns.TypeANY)
+ fmt.Printf("Question: %v\n", m)
if err := c.sendQuery(m); err != nil {
log.Printf("[ERR] mdns: Failed to query instance %s: %v", inp.Name, err)
}
}
+ fmt.Println("--------------------")
case <-finish:
return nil
Then run:
$ go run main.go
PTR: _airplay._tcp.local. 10 IN PTR Apple\194\160TV._airplay._tcp.local.
inp = &{Apple\194\160TV._airplay._tcp.local. <nil> 0 false false}
Question: ;; opcode: QUERY, status: NOERROR, id: 44739
;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;Apple\194\160TV._airplay._tcp.local. IN ANY
--------------------
TXT: Apple\194\160TV._airplay._tcp.local. 10 IN TXT "deviceid=58:55:CA:0D:DB:FA" "features=0x4A7FFFF7,0xE" "flags=0x44" "model=AppleTV2,1" "pk=4c58e46591dd61a873659cfc32441ad6e51ead18939b1cc683ec008f36bbba0b" "srcvers=200.54" "vv=2"
SRV: Apple\194\160TV._airplay._tcp.local. 10 IN SRV 0 0 7000 AppleTV.local.
inp = &{AppleTV.local. <nil> 7000 false false}
Question: ;; opcode: QUERY, status: NOERROR, id: 30016
;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;AppleTV.local. IN ANY
--------------------
inp = &{AppleTV.local. 192.168.0.2 7000 false false}
Question: ;; opcode: QUERY, status: NOERROR, id: 38769
;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;AppleTV.local. IN ANY
--------------------
inp = &{AppleTV.local. 192.168.0.2 7000 false false}
Question: ;; opcode: QUERY, status: NOERROR, id: 23884
;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;AppleTV.local. IN ANY
(repeat until timeout..)
Expected to cause of incomplete:
- When get
PTR
record, create new entry (inp.name = Apple\194\160TV._airplay._tcp.local.
)
- When get
TXT
record, inp.hasTxt = true
- When get
SRV
record, create new entry (inp.name = AppleTV.local
)
- Hereafter, question about
AppleTV.local
only sent, and never inp.hasTxt
becomes true
Supplementary
I was able to reproduce the problem on _daap._tcp