Skip to content

Commit

Permalink
Allow Unicast lookup queries - this solves missing response issue in b…
Browse files Browse the repository at this point in the history
  • Loading branch information
chinenual committed Sep 20, 2020
1 parent 5bf037f commit 7bef39a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions browse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down

0 comments on commit 7bef39a

Please sign in to comment.