rust-mdns icon indicating copy to clipboard operation
rust-mdns copied to clipboard

Multiple registrations with same name

Open soundprojects opened this issue 7 years ago • 3 comments

Hi

When attempting to register the same service twice, the second attempt doesn't seem to register a service at all.

The expected result would be that the name is made unique by adding a number for example MyService (1). Is there a setting to make this happen ?

Thanks!

soundprojects avatar Sep 15 '18 12:09 soundprojects

As far as I see it is not possible without making changes inside the crate.

Mapping name -> id keeps only last registered service for every name:

https://github.com/plietar/rust-mdns/blob/0974ab4ff7874437e11a89037c8258362a0061f8/src/services.rs#L13-L21

It could be MultiMap instead to allow the responder to quickly find multiple services with the same name.

If you want to rename duplicate service, you can do it in this method:

https://github.com/plietar/rust-mdns/blob/0974ab4ff7874437e11a89037c8258362a0061f8/src/services.rs#L50-L61

but I think it is not a good idea to do that. If someone will query for exactly MyService (it is common in mDNS), he won't know that you have some MyService (1) too.

quilir avatar Sep 15 '18 14:09 quilir

Ah right I see. I think many Bonjour libraries do implement this when there is a name conflict as this does make it possible to run multiple local instances with a hardcoded name. What do you think?

soundprojects avatar Sep 15 '18 18:09 soundprojects

You're right that this is recommended way. I've read about it and found this:

https://tools.ietf.org/html/rfc6763#appendix-D

I was focused too much on queries that I make in my project - programmatically discovering all services with some name. Renaming in that way might cause too much trouble to be worth it. I would rather modify this crate to allow multiple services with the same name on one publisher.

But it is probably not the most common case. Results of mDNS queries are often presented on UI and user wants to have clear and distinguishable names.

quilir avatar Sep 16 '18 04:09 quilir