GNU bug report logs -
#31687
[PATCH] services: Add dnsmasq-service-type.
Previous Next
Reported by: 宋文武 <iyzsong <at> member.fsf.org>
Date: Sat, 2 Jun 2018 15:29:01 UTC
Severity: normal
Tags: patch
Done: iyzsong <at> member.fsf.org (宋文武)
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 31687 in the body.
You can then email your comments to 31687 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix-patches <at> gnu.org
:
bug#31687
; Package
guix-patches
.
(Sat, 02 Jun 2018 15:29:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
宋文武 <iyzsong <at> member.fsf.org>
:
New bug report received and forwarded. Copy sent to
guix-patches <at> gnu.org
.
(Sat, 02 Jun 2018 15:29:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
* gnu/services/dns.scm (dnsmasq-service-type): New variable.
(<dnsmasq-configuration>): New record type.
(dnsmasq-shepherd-service): New procedure.
* doc/guix.texi (DNS Services): Document it.
---
doc/guix.texi | 59 ++++++++++++++++++++++++++++++++++++++-
gnu/services/dns.scm | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 136 insertions(+), 2 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 77bdaa50e..e1353842e 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -16405,7 +16405,11 @@ saved to @code{/etc/letsencrypt/live/@var{name}/privkey.pem}.
The @code{(gnu services dns)} module provides services related to the
@dfn{domain name system} (DNS). It provides a server service for hosting
an @emph{authoritative} DNS server for multiple zones, slave or master.
-This service uses @uref{https://www.knot-dns.cz/, Knot DNS}.
+This service uses @uref{https://www.knot-dns.cz/, Knot DNS}. And also a
+caching and forwarding DNS server for the LAN, which uses
+@uref{http://www.thekelleys.org.uk/dnsmasq/doc.html, dnsmasq}.
+
+@subsubheading Knot Service
An example configuration of an authoritative server for two zones, one master
and one slave, is:
@@ -16800,6 +16804,59 @@ The list of knot-zone-configuration used by this configuration.
@end table
@end deftp
+@subsubheading Dnsmasq Service
+
+@deffn {Scheme Variable} dnsmasq-service-type
+This is the type of the dnsmasq service, whose value should be an
+@code{dnsmasq-configuration} object as in this example:
+
+@example
+(service dnsmasq-service-type
+ (dnsmasq-configuration
+ (no-resolv? #t)
+ (servers '("192.168.1.1"))))
+@end example
+@end deffn
+
+@deftp {Data Type} dnsmasq-configuration
+Data type representing the configuration of dnsmasq.
+
+@table @asis
+@item @code{package} (default: @var{dnsmasq})
+Package object of the dnsmasq server.
+
+@item @code{no-hosts?} (default: @code{#f})
+When true, don't read the hostnames in /etc/hosts.
+
+@item @code{port} (default: @code{53})
+The port to listen on. Setting this to zero completely disables DNS
+funtion, leaving only DHCP and/or TFTP.
+
+@item @code{local-service?} (default: @code{#t})
+Accept DNS queries only from hosts whose address is on a local subnet,
+ie a subnet for which an interface exists on the server.
+
+@item @code{listen-addresses} (default: @code{'()})
+Listen on the given IP addresses.
+
+@item @code{resolv-file} (default: @code{"/etc/resolv.conf"})
+The file to read the IP address of the upstream nameservers from.
+
+@item @code{no-resolv?} (default: @code{#f})
+When true, don't read @var{resolv-file}.
+
+@item @code{servers} (default: @code{'()})
+Specify IP address of upstream servers directly.
+
+@item @code{cache-size} (default: @code{150})
+Set the size of dnsmasq's cache. Setting the cache size to zero
+disables caching.
+
+@item @code{no-negcache?} (default: @code{#f})
+When true, disable negative caching.
+
+@end table
+@end deftp
@node VPN Services
@subsubsection VPN Services
diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm
index 673ab1a98..d0913e90e 100644
--- a/gnu/services/dns.scm
+++ b/gnu/services/dns.scm
@@ -27,6 +27,7 @@
#:use-module (guix records)
#:use-module (guix gexp)
#:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-26)
#:use-module (srfi srfi-34)
#:use-module (srfi srfi-35)
#:use-module (ice-9 match)
@@ -41,7 +42,10 @@
knot-configuration
define-zone-entries
zone-file
- zone-entry))
+ zone-entry
+
+ dnsmasq-service-type
+ dnsmasq-configuration))
;;;
;;; Knot DNS.
@@ -591,3 +595,76 @@
knot-activation)
(service-extension account-service-type
(const %knot-accounts))))))
+
+
+;;;
+;;; Dnsmasq.
+;;;
+
+(define-record-type* <dnsmasq-configuration>
+ dnsmasq-configuration make-dnsmasq-configuration
+ dnsmasq-configuration?
+ (package dnsmasq-configuration-package
+ (default dnsmasq)) ;package
+ (no-hosts? dnsmasq-configuration-no-hosts?
+ (default #f)) ;boolean
+ (port dnsmasq-configuration-port
+ (default 53)) ;integer
+ (local-service? dnsmasq-configuration-local-service?
+ (default #t)) ;boolean
+ (listen-addresses dnsmasq-configuration-listen-address
+ (default '())) ;list of string
+ (resolv-file dnsmasq-configuration-resolv-file
+ (default "/etc/resolv.conf")) ;string
+ (no-resolv? dnsmasq-configuration-no-resolv?
+ (default #f)) ;boolean
+ (servers dnsmasq-configuration-servers
+ (default '())) ;list of string
+ (cache-size dnsmasq-configuration-cache-size
+ (default 150)) ;integer
+ (no-negcache? dnsmasq-configuration-no-negcache?
+ (default #f))) ;boolean
+
+(define dnsmasq-shepherd-service
+ (match-lambda
+ (($ <dnsmasq-configuration> package
+ no-hosts?
+ port local-service? listen-addresses
+ resolv-file no-resolv? servers
+ cache-size no-negcache?)
+ (shepherd-service
+ (provision '(dnsmasq))
+ (requirement '(networking))
+ (documentation "Run the dnsmasq DNS server.")
+ (start #~(make-forkexec-constructor
+ '(#$(file-append package "/sbin/dnsmasq")
+ "--keep-in-foreground"
+ "--pid-file=/run/dnsmasq.pid"
+ #$@(if no-hosts?
+ '("--no-hosts")
+ '())
+ #$(format #f "--port=~a" port)
+ #$@(if local-service?
+ '("--local-service")
+ '())
+ #$@(map (cut format #f "--listen-address=~a" <>)
+ listen-addresses)
+ #$(format #f "--resolv-file=~a" resolv-file)
+ #$@(if no-resolv?
+ '("--no-resolv")
+ '())
+ #$@(map (cut format #f "--server=~a" <>)
+ servers)
+ #$(format #f "--cache-size=~a" cache-size)
+ #$@(if no-negcache?
+ '("--no-negcache")
+ '()))
+ #:pid-file "/run/dnsmasq.pid"))
+ (stop #~(make-kill-destructor))))))
+
+(define dnsmasq-service-type
+ (service-type
+ (name 'dnsmasq)
+ (extensions
+ (list (service-extension shepherd-root-service-type
+ (compose list dnsmasq-shepherd-service))))))
--
2.13.3
Reply sent
to
iyzsong <at> member.fsf.org (宋文武)
:
You have taken responsibility.
(Tue, 05 Jun 2018 12:09:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
宋文武 <iyzsong <at> member.fsf.org>
:
bug acknowledged by developer.
(Tue, 05 Jun 2018 12:09:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 31687-done <at> debbugs.gnu.org (full text, mbox):
Pushed as commit 97f6e9133a03f37c79e60678dd5670a805cdf693.
Information forwarded
to
guix-patches <at> gnu.org
:
bug#31687
; Package
guix-patches
.
(Fri, 08 Jun 2018 14:44:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 31687 <at> debbugs.gnu.org (full text, mbox):
Hello!
Thanks for this patch, that looks like a useful service to have!
宋文武 <iyzsong <at> member.fsf.org> skribis:
> +@item @code{no-negcache?} (default: @code{#f})
> +When true, disable negative caching.
Minor issues:
• The general guideline is to avoid abbreviations in identifiers—we’re
using the language that comes with ‘call-with-current-continuation’,
after all. ;-)
• Another guideline is to avoid double-negations and the likes.
So in this example, I would recommend:
‘negative-caching?’ (default: #t)
I think there’s a couple of other abbreviations.
Ludo’.
Information forwarded
to
guix-patches <at> gnu.org
:
bug#31687
; Package
guix-patches
.
(Fri, 08 Jun 2018 15:47:01 GMT)
Full text and
rfc822 format available.
Message #16 received at 31687 <at> debbugs.gnu.org (full text, mbox):
ludo <at> gnu.org (Ludovic Courtès) writes:
> Hello!
>
> Thanks for this patch, that looks like a useful service to have!
>
> 宋文武 <iyzsong <at> member.fsf.org> skribis:
>
>> +@item @code{no-negcache?} (default: @code{#f})
>> +When true, disable negative caching.
>
> Minor issues:
>
> • The general guideline is to avoid abbreviations in identifiers—we’re
> using the language that comes with ‘call-with-current-continuation’,
> after all. ;-)
>
> • Another guideline is to avoid double-negations and the likes.
>
> So in this example, I would recommend:
>
> ‘negative-caching?’ (default: #t)
>
Agree, I like this naming guideline, pushed :-)
> I think there’s a couple of other abbreviations.
It’s not clear to me whether other options are abbreviations or not or
worth to expand. eg: ‘no-hosts?’ and ‘no-resolv?’, they’re refer to the
well-known ‘/etc/hosts’ and ‘/etc/resolv.conf’ files, what could we use
instead?
Information forwarded
to
guix-patches <at> gnu.org
:
bug#31687
; Package
guix-patches
.
(Fri, 08 Jun 2018 19:38:01 GMT)
Full text and
rfc822 format available.
Message #19 received at 31687 <at> debbugs.gnu.org (full text, mbox):
iyzsong <at> member.fsf.org (宋文武) skribis:
> ludo <at> gnu.org (Ludovic Courtès) writes:
[...]
>> Minor issues:
>>
>> • The general guideline is to avoid abbreviations in identifiers—we’re
>> using the language that comes with ‘call-with-current-continuation’,
>> after all. ;-)
>>
>> • Another guideline is to avoid double-negations and the likes.
>>
>> So in this example, I would recommend:
>>
>> ‘negative-caching?’ (default: #t)
>>
>
> Agree, I like this naming guideline, pushed :-)
Thank you!
>> I think there’s a couple of other abbreviations.
>
> It’s not clear to me whether other options are abbreviations or not or
> worth to expand. eg: ‘no-hosts?’ and ‘no-resolv?’, they’re refer to the
> well-known ‘/etc/hosts’ and ‘/etc/resolv.conf’ files, what could we use
> instead?
Oh you’re right, these are fine.
Ludo’.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 07 Jul 2018 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 67 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.