probonopd / announce

Announce services on the network with Zeroconf/Bonjour with minimal overhead.
15 stars 5 forks source link

Announce services from a list #12

Closed nicopace closed 7 years ago

nicopace commented 7 years ago

I'm working on a service for the libremesh project, It would be great to be able to publish a list of services defined on a file or passed as parameters. Also would need to publish services that are not located on the host.

Is that doable?

This is the use case: we have a mesh network of +50 nodes. The mesh protocol has a service subprotocol that allows to send administrative information much more effectively than using multicast, so as we have openwrt on each node, what we want is to snoop the mdns resolvers on each node for their mdns records and publish them through this service subprotocol in order to efficiently share mdns information.

thanks!

probonopd commented 7 years ago

Yes, that would be doable, but it looks like avahi-daemon might be more suited to this use case and already provides the functionality you are looking for. Keep in mind that announce is meant to be a super-tiny, minimalistic version.

nicopace commented 7 years ago

The issue with avahi-daemon is that it doesn't allow to publish services from outside the host... that is really inconvinient in our case....

nicopace commented 7 years ago

Ok... i have researched a little bit inside the code. Let me know if I get it right. In order to implement a server that fetches mdns entries from other services, caches it, replicates caches over the network, I would need for this code to:

  1. support multiple host settings (having multiple host records inside the mdns server)
  2. keep the cache in a data structure and publish that instead of a fixed list
  3. configure the ip of the service, and let the code register the ip and the hostname against the mdns server
  4. make a way to modify the config while running, or via a config by restarting the daemon when new configs are in place

wow... that seems a lot to do.. any suggestions?

probonopd commented 7 years ago

Still think that using Avahi might be your best option...

nicopace commented 7 years ago

Avahi doesn't allow me to add entries that are not on the host that Avahi is installed, so it is not possible to go over that path... unless I go into modifying Avahi`s source code... quite complicated for now.

Thanks!

probonopd commented 7 years ago

Avahi doesn't allow me to add entries that are not on the host that Avahi is installed

Why do you keep thinking that?

https://linux.die.net/man/5/avahi-daemon.conf

host-name= Set the host name avahi-daemon tries to register on the LAN

nicopace commented 7 years ago

I got to this conclusion because you can't add many hosts... just one per interface (as it is with your code too). I might use the reflector feature to begin thinking an implementation.

probonopd commented 7 years ago

I think you can have as many Avahi service files on one host as you like...

nicopace commented 7 years ago

Ok... so I could create one avahi.service and avahi.hosts information... that may help! will try and post back... thanks!

nicopace commented 7 years ago

It works @probonopd, awesome!! Many thanks! Just to leave the information for others to find it, avahi allows to statically add any service or host information to its records... So if you add service files on /etc/avahi/services/ and host info on /etc/avahi/hosts and then reload the config with avahi-daemon -r ... it works!