sony / nmos-cpp

An NMOS (Networked Media Open Specifications) Registry and Node in C++ (IS-04, IS-05)
Apache License 2.0
141 stars 80 forks source link

Provide an HTTP Host header from DNS-SD name resolution for Registration API and System API discovery #357

Closed garethsb closed 7 months ago

garethsb commented 10 months ago

nmos-cpp uses a DNS-SD library (Bonjour/mDNSResponder or Avahi) to discover the hostname of the Registry.

By default it also uses the DNS-SD library to then resolve the hostname to an IP address, and makes HTTP requests using that IP address. This ensured success with mDNS .local names on Windows, and on Linux systems where the Name Service Switch was misconfigured. However, it means that the HTTP requests to the Registry do not get a Host header. That causes trouble for Gateways/Proxies.

Since June 2022 (https://github.com/sony/nmos-cpp/pull/263) nmos-cpp supports a discovery mode where it delegates name resolution to the HTTP library (which will rely on the system resolver). Using this would fix the problem... if you didn't care about the cases I mentioned above...

Probably ideally, nmos-cpp would implement name resolution using DNS-SD, but ensure that a Host header is included even so. That'll mean passing both the hostname and the IP Address back from nmos::details::get_resolved_hosts and ultimately out of nmos::resolve_service to be used by the node behaviour thread and node system behaviour thread... All assuming that the underlying HTTP library will allow us to specify a URL with an IP address but include a Host header!

The DNS-SD resolution mechanism falls back to getaddrinfo, so using this approach should work in all cases and we could apply it also in HTTPS mode, and therefore remove the discovery_mode setting again.