diff options
| author | Sergey Trofimov <sarg@sarg.org.ru> | 2025-10-06 16:57:06 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2025-10-13 14:48:27 +0200 |
| commit | a16d6225ee519cb7031d1610784daefe99b570e8 (patch) | |
| tree | cac5fc260e48f7761f16852873ce4b9491300568 /gnu/system | |
| parent | 9da40e7bc3ac957395977748274893702e7207f3 (diff) | |
nss: Allow selecting IP protocol for mDNS lookups.
* gnu/system/nss.scm (mdns-host-lookup-nss): New procedure.
* doc/guix.texi (Name Service Switch): Document it.
Change-Id: Ie4ff4aab6bf41eb2cec69b78a8427594b20bc954
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'gnu/system')
| -rw-r--r-- | gnu/system/nss.scm | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/gnu/system/nss.scm b/gnu/system/nss.scm index 673b96c7132..e46840713fe 100644 --- a/gnu/system/nss.scm +++ b/gnu/system/nss.scm @@ -27,6 +27,7 @@ name-service lookup-specification + mdns-host-lookup-nss %default-nss %mdns-host-lookup-nss @@ -152,26 +153,34 @@ ;; Default NSS configuration. (name-service-switch)) -(define %mdns-host-lookup-nss - (name-service-switch - (hosts (list %files ;first, check /etc/hosts +(define* (mdns-host-lookup-nss #:key (ipv6? #t) (ipv4? #t)) + (let ((flavour (cond + ((and ipv6? ipv4?) "mdns") + (ipv6? "mdns6") + (ipv4? "mdns4") + (#t (error "No protocols enabled for mDNS lookups."))))) + (name-service-switch + (hosts (list %files ;first, check /etc/hosts - ;; If the above did not succeed, try with 'mdns_minimal'. - (name-service - (name "mdns_minimal") + ;; If the above did not succeed, try with 'mdns_minimal'. + (name-service + (name (string-append flavour "_minimal")) - ;; 'mdns_minimal' is authoritative for '.local'. When it - ;; returns "not found", no need to try the next methods. - (reaction (lookup-specification - (not-found => return)))) + ;; 'mdns_minimal' is authoritative for '.local'. When it + ;; returns "not found", no need to try the next methods. + (reaction (lookup-specification + (not-found => return)))) - ;; Then fall back to DNS. - (name-service - (name "dns")) + ;; Then fall back to DNS. + (name-service + (name "dns")) - ;; Finally, try with the "full" 'mdns'. - (name-service - (name "mdns")))))) + ;; Finally, try with the "full" 'mdns'. + (name-service + (name flavour))))))) + + +(define %mdns-host-lookup-nss (mdns-host-lookup-nss)) ;;; |
