cnlohr / minimdnsd

Simple, dependency-less, and low-overhead MDNS server for Linux
MIT License
61 stars 3 forks source link

Advertise services to the network #5

Open probonopd opened 5 months ago

probonopd commented 5 months ago

The main point of Zeroconf (for me, anyways) is to announce services to the network, e.g., a web server can announce its existence to other devices on the network. Is this possible/planned for minimdnsd?

Is that what is meant by

Allow response to services

?

My main use cases would be all kinds of embedded boxes with, e.g., sshd on them, which I would like to be advertised to the local network so that I don't have to remember their hostnames nor find out their IP addresses.

cnlohr commented 5 months ago

I would consider doing a blanket advertisement, like mdns or add a service by command-line flag, but to do full services, you would have to do a lot of integration within the host system.

Is there any sort of "universal service" like "present.local" or something everyone can reply to I don't see one at first glance.

probonopd commented 4 months ago

Not sure what your intended use case is, but (to me at least) the magic of DNS-SD is that the SSH application finds SSH servers and the web browser finds web servers etc. So to announce a service properly to the network, the type of the service needs to be announced (such as _ssh._tcp or _http._tcp). The inventor Stuart Cheshire lists helpful resources at http://www.dns-sd.org/.

cnlohr commented 4 months ago

The use case is for you to say ssh cnlohr@myraspberrypi.local and it connect you in there.

How do you detect if individual services are supported? Or rather, how would this tool be aware of how to know whether your local system should advertise a service or not.

probonopd commented 4 months ago

Certain SSH tools (e.g., https://cyberduck.io/, at least the Mac version) show a list of the SSH servers advertised on the network. So all one has to do is open Cyberduck, choose one of the servers (with speaking names, like "Backup Raspberry Pi") from the drop-down list, and log in.

Similarly, some web browsers can show a menu containing all webservers advertised to the network. And so on.

minimdnsd would need a small config file telling it which services to advertise under which names, on which ports, and optionally with with TXT records, roughly something along these lines:

[Service]
# The type of service (_http._tcp, _ssh._tcp, etc.)
type=
# The name of the service
name=
# The port number the service is running on
port=
# TXT records for additional information, see dns-sd spec
txt=

[HTTPService]
type=_http._tcp
name=My Webserver
port=80
txt=path=/

[SSHService]
type=_ssh._tcp
name=My Unix Box
port=22
probonopd commented 4 months ago

To take it to the next level, it could check whether certain processes are running and only if they are, advertise the corresponding service. But maybe this is too much for a small, simple tool.

cnlohr commented 4 months ago

No config file. Too big. Maybe command-line parameters?

But point being you aren't looking to set it up as some sort of auto-detect? Do you actually need names and ports? I thought services were normally just advertised with the service name, i.e. _ssh.tcp.

probonopd commented 4 months ago

Yes, command line options would do. I am not looking for it to automatically know what to advertise.

Ports and names are needed. If you don't advertise a name, how would the other machine know how the service is called? Likewise, if you don't advertise a port, how would the other machine know which port to use?