From 7bef39a57fc651a1eeef25f6b3e42d9556426602 Mon Sep 17 00:00:00 2001 From: Steve Tynor Date: Sun, 20 Sep 2020 15:15:42 -0400 Subject: [PATCH] Allow Unicast lookup queries - this solves missing response issue in https://github.com/brutella/dnssd/issues/20 --- browse.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/browse.go b/browse.go index 46849ed..22ee0c0 100644 --- a/browse.go +++ b/browse.go @@ -15,10 +15,18 @@ func LookupType(ctx context.Context, service string, add AddServiceFunc, rmv Rmv } defer conn.close() - return lookupType(ctx, service, conn, add, rmv) + return lookupType(ctx, service, conn, add, rmv,false) } +func LookupTypeUnicast(ctx context.Context, service string, add AddServiceFunc, rmv RmvServiceFunc) (err error) { + conn, err := newMDNSConn() + if err != nil { + return err + } + defer conn.close() -func lookupType(ctx context.Context, service string, conn MDNSConn, add AddServiceFunc, rmv RmvServiceFunc) (err error) { + return lookupType(ctx, service, conn, add, rmv,true) +} +func lookupType(ctx context.Context, service string, conn MDNSConn, add AddServiceFunc, rmv RmvServiceFunc, unicast bool) (err error) { var cache = NewCache() m := new(dns.Msg) @@ -37,6 +45,9 @@ func lookupType(ctx context.Context, service string, conn MDNSConn, add AddServi q := &Query{msg: m} conn.SendQuery(q) + if unicast { + setQuestionUnicast(&m.Question[0]) + } for { select { case req := <-ch: