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

Use Zeroconf technology (a.k.a. "Bonjour", a.k.a. "Avahi") for DNS-SD (DNS-based Service Discovery) #39

Closed
KurtPfeifle opened this issue Jun 10, 2016 · 7 comments

Comments

@KurtPfeifle
Copy link

It should be easy-peasy for users + clients to discover an ownNextCloud service instance available to them (either on LAN/WLAN, or on Wide Area LAN) and then connect to it.

_Quotes from the future:_

"After installing Nextcloud, I just started my Android client, and BAMM!, it had already discovered the Nextcloud server and presented to me its login screen."

"After I started my Epiphany browser, a 'Nextcloud' bookmark within the 'Nearby Sites' category was already there. Clicking on it presented me its login screen."


For this to work, the server component should be able to announce its presence and its exact services to potential clients. (Clients also need a way to take notice of these announcements.)

Exactly for this purpose mDNS (Multicast-based DNS, described in RFC 6762) and DNS-SD (DNS-based Service Discovery, described in RFC 6763) have been specified by the IETF.

Given that most Linux distributions nowadays provide Avahi out of the box, getting this server part of the equation to work should be super-easy. Merely taking advantage of the already existing _webdav._tcp, _http._tcp and _https._tcp service types should already go a long way.

Utilizing the existing Apache module mod_dnssd (for more docu, see also here) should be a breeze. It may require an additional dependency to install: on Debian the package name is libapache2-mod-dnssd.

Finally, you may want to consider to register your own service types _nextcloud._tcp and _owncloud._tcp (possibly with sub-types for _contacts, _calendar, etc.) with IANA here: www.iana.org/cgi-bin/usr-port-number.pl.


See also _at the respective topic in the forums_, where further hints and some details have been discussed already.

@aronovgj
Copy link

"After I started my Epiphany browser, a 'Nextcloud' bookmark within the 'Nearby Sites' category was already there. Clicking on it presented me its login screen."

If Nextcloud would add bookmarks to my browser without asking me, my quote would look different.

@KurtPfeifle
Copy link
Author

KurtPfeifle commented Jun 10, 2016

@aronovgj :

Hey, Epiphany already _DOES_ automatically add bookmarks without asking you (if your box has a running avahi-daemon) !

It adds those bookmarks into a special bookmark department called 'Nearby Sites'. These bookmarks are auto-created whenever there is an Avahi- or Bonjour- or other DNS-SD announcement seen over mDNS which advertises a _http._tcp service record. (And I want this to happen for Nextcloud too (not necessarily/only in the browser, but also in all GUI clients -- so users can more easily connect to the server(s)).

But stay calm, please! Epiphany also auto-removes these same bookmarks again as soon as Avahi notices that the service has gone away from the network.

It's not a bug, it's a feature -- and it is the whole purpose of Avahi:

  • It's the same mechanism as the one which automatically finds nearby AirPrint-capable printers if you want to print from an iPad or an iPhone.
  • It's the same mechanism as the one which lets interested clients auto-discover CUPS print queues (if these are set up to be "shared").
  • It's the same mechanism as the one which lets you easily find your Amazon Fire TV stick in your home, if you want to access it from a computer.
  • It's the same mechanism, that lets you share iTunes music in a shared LAN, or lets you access others' iTunes shares.
  • It's the same mechanism, that lets you automatically find all Kodi servers (if set up to make this easy) from a client.

If you don't believe me -- I guess you won't (because you do not seem to have consciously encountered DNS-SD in your network life so far) -- just run the following two commands in a terminal, in any order:

 $ avahi-publish-service \
     --domain local.     \
     --address nextcloud.com. 88.198.160.129 &

 $ avahi-publish-service \
    --host nextcloud.com.\
    --domain local.      \
    --service "Nextcloud Web Site -- brand-new!" \
      _http._tcp         \
      80                 \
      path="/news" &

Now start Epiphany, open bookmarks, open the 'Nearby Sites' list, and admire your brand-new, auto-generated bookmark pointing to the Nextcloud web site.

(If you want to see how it is automatically removed again, type fg <enter> then <ctrl>-c into your terminal. Your automatically added bookmark is gone again.)


Congratulations! You've just let Epiphany add a bookmark to your browser without asking you. Now your quote is due 😃
I'm really interested in what your quote looks like now...
Will you let me know, please? 😃


(Above commands tested on Debian Jessie 8.0: working. Tested on Raspian on a Pi3: first command [which creates name-to-IP resolution in .local domain] doesn't work -- even though Avahi version was 0.6.31 for both.)

@aronovgj
Copy link

I'll change my quote to:

I'd prefer to not use epiphany

But thats interesting, I learned something new and excuse my ignorance :)

@MariusBluem MariusBluem changed the title [Feature Request] Use Zeroconf technology (a.k.a. "Bonjour", a.k.a. "Avahi") for DNS-SD (DNS-based Service Discovery) Use Zeroconf technology (a.k.a. "Bonjour", a.k.a. "Avahi") for DNS-SD (DNS-based Service Discovery) Jul 28, 2016
@MorrisJobke
Copy link
Member

Autodiscovery for servers has very limited user base (those who have their server in their home network). If you want to have this you should set this up on the server independent from the nextcloud server.

Thus I will close this ticket.

@KurtPfeifle
Copy link
Author

KurtPfeifle commented Mar 21, 2018

@MorrisJobke:

You are completely wrong when stating that "autodiscovery for servers has a very limited user base". However, that is not your fault -- it's mine, since I don't seem to have been able to explain and put over my ideas in a way which makes them understandable.

Also, you confused me by seemingly saying that the limited user base is equivalent to "those who have their server in their home network". Don't MOST Nextcloud users run their Nextcloud instances in their home network? How is that a limited user base then?

@MorrisJobke
Copy link
Member

You are completely wrong when stating that "autodiscovery for servers has a very limited user base". However, that is not your fault -- it's mine, since I don't seem to have been able to explain and put over my ideas in a way which makes them understandable.

Also, you confused me by seemingly saying that the limited user base is equivalent to "those who have their server in their home network". Don't MOST Nextcloud users run their Nextcloud instances in their home network? How is that a limited user base then?

Sorry for sounding a bit harsh here.

Let me elaborate a bit more: I fully understand the use case. Nevertheless we are building an web app, that responds to incoming HTTP requests mainly. As far as I understood this mDNS is not based on HTTP, right? It's its own protocol. I doubt that there is an easy way for the PHP runtime (without additional configuration) to respond to those requests.

Therefore I proposed to properly document how to configure the avahi daemon to make this service discoverable instead of putting this into our code and then require a lot of additional wiring to be able to respond to those requests.

Does that make sense or am I completely wrong here?

@stokito
Copy link

stokito commented May 5, 2021

NC API internally uses WebDAV with extensions so instead of creation of a new DNS-SD key we may use an existing _webdav.tcp_ with additional TXT record like product=nextcloud so mDNS clients can distinguish it and in the same time the same share will be seen in Gnome/KDE's file manager.

Then implement the search for such records in Nexcloud APP for iOS and Android.
Nextcloud may be installed from a package managers in Ubuntu and OpenWRT so we may add an additional package that will create /etc/avahi/services/nextloud.service file that advertise the NC instance on a default path.
It's not necessary to publish mDNS record from PHP script.
This simple change may improve user experience a lot

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

No branches or pull requests

5 participants