Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Answer RRs are not sent as separate entries #92

Open
mmadraimov92 opened this issue Apr 6, 2022 · 0 comments
Open

Multiple Answer RRs are not sent as separate entries #92

mmadraimov92 opened this issue Apr 6, 2022 · 0 comments

Comments

@mmadraimov92
Copy link

Hello,

Thank you for the library!

I am using library to discover specific services on local network by querying service type. There can be multiple services of the same type from same machine/device. There is an issue I have encountered, query responses that have multiple answers are not reported as separate entries.

Checkout wireshark screenshot:

Screenshot 2022-04-06 at 16 16 50

Here 192.168.80.92 is the address of device running the client code. 192.168.80.182 is the server which responds to mdns queries (it is windows machine, uses bonjour service).
As you can see from screenshot, the are 2 services of type _itxpt_http._tcp. The Answer section contains 2 records, + additional records for each of these 2 answers.

The client code:

package main

import (
	"context"
	"fmt"
	"os"
	"os/signal"
	"time"

	"github.com/hashicorp/mdns"
)

func main() {
	timeout := 2 * time.Second
	ctx, _ := signal.NotifyContext(context.Background(), os.Interrupt, os.Kill)
	ctx, cancel := context.WithTimeout(ctx, timeout)
	defer cancel()

	entriesCh := make(chan *mdns.ServiceEntry, 4)
	go mdns.Query(&mdns.QueryParam{
		Service:     "_itxpt_http._tcp",
		Entries:     entriesCh,
		DisableIPv6: true,
		Domain:      "local",
		Timeout:     timeout,
	})

	for {
		select {
		case entry := <-entriesCh:
			fmt.Println("Got new entry:", entry.Name)
		case <-ctx.Done():
			fmt.Println("done")
			return
		}
	}
}

Client only registers 1 entry, with values of second answer:

$ go run client.go
Got new entry: vehicle-1000_inventory._itxpt_http._tcp.local.
done

Is there a way to get these values as two separate entries?
Like:

Got new entry: vehicle-1000_avms._itxpt_http._tcp.local.
Got new entry: vehicle-1000_inventory._itxpt_http._tcp.local.

It seems like the entry gets overwritten with the data from last answer in this loop: https://github.com/hashicorp/mdns/blob/v1.0.5/client.go#L272

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant