-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Requested unicast responses are never received #15
Comments
At the momet we cannot receive unicast responses #15
At the momet we cannot receive unicast responses #15
Regarding this bug, I've managed to recreate it in an alternate way: when the I created a test case package dnssd_test
import (
"context"
"fmt"
"github.com/brutella/dnssd"
"net"
"os"
"strings"
"testing"
"time"
)
func TestBrowse(t *testing.T) {
testIface, _ := net.InterfaceByName("lo0")
if testIface == nil {
testIface, _ = net.InterfaceByName("lo")
}
if testIface == nil {
t.Fatal("can not find the local interface")
}
localhost, err := os.Hostname()
if err != nil {
t.Fatal(err)
}
localhost = strings.TrimSuffix(strings.Replace(localhost, " ", "-", -1), ".local") // replace spaces with dashes and remove .local suffix
for tName, hostValue := range map[string]string{
"regular host": "My-Computer",
"empty host": "",
"ip address": "192.168.0.1",
} {
t.Run(tName, func(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
cfg := dnssd.Config{
Name: "My Service",
Type: "_hap._tcp",
Host: hostValue,
Port: 12334,
Ifaces: []string{testIface.Name},
}
srv, err := dnssd.NewService(cfg)
if err != nil {
t.Fatal(err)
}
rs, err := dnssd.NewResponder()
if err != nil {
t.Fatal(err)
}
go func() {
_ = rs.Respond(ctx)
}()
_, err = rs.Add(srv)
if err != nil {
t.Fatal(err)
}
resultChan := make(chan dnssd.BrowseEntry)
defer close(resultChan)
go func() {
_ = dnssd.LookupType(ctx, fmt.Sprintf("%s.local.", cfg.Type), func(entry dnssd.BrowseEntry) {
resultChan <- entry
}, func(entry dnssd.BrowseEntry) {})
}()
select {
case <-ctx.Done():
t.Fatal("timeout")
case entry := <-resultChan:
if entry.Name != cfg.Name {
t.Fatalf("is=%v want=%v", entry.Name, cfg.Name)
}
if tName == "empty host" {
if entry.Host != localhost {
t.Fatalf("is=%v want=%v", entry.Host, localhost)
}
} else {
if entry.Host != cfg.Host {
t.Fatalf("is=%v want=%v", entry.Host, cfg.Host)
}
}
if entry.Port != cfg.Port {
t.Fatalf("is=%v want=%v", entry.Port, cfg.Port)
}
}
})
}
} |
@daniel-sullivan Thanks for reporting. This is now fixed by 86afc0a |
Unicast responses are not received when listing to the multicast link local address.
The text was updated successfully, but these errors were encountered: