mirror of
https://codeberg.org/guix/guix.git
synced 2026-01-25 03:55:08 -06:00
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>
This commit is contained in:
parent
9da40e7bc3
commit
a16d6225ee
2 changed files with 34 additions and 16 deletions
|
|
@ -46289,6 +46289,15 @@ This is the name service switch configuration with support for host name
|
|||
lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
|
||||
@end defvar
|
||||
|
||||
Furthermore, mDNS lookups could be restricted to IPv4 or IPv6 protocols
|
||||
using the procedure @code{mdns-host-lookup-nss}.
|
||||
|
||||
@deffn {Procedure} mdns-host-lookup-nss @
|
||||
[#:ipv6? #t] [#:ipv4? #t]
|
||||
Return a @code{name-service-switch} object with mDNS lookup restricted
|
||||
to specified protocols.
|
||||
@end deffn
|
||||
|
||||
The reference for name service switch configuration is given below. It
|
||||
is a direct mapping of the configuration file format of the C library , so
|
||||
please refer to the C library manual for more information (@pxref{NSS
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
||||
|
||||
;;;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue