From: Pieter Lexis Date: Wed, 15 Apr 2015 20:57:05 +0000 (+0200) Subject: Allow comments in the forward-zones-file X-Git-Tag: dnsdist-1.0.0-alpha1~33^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fa2909dcc4cbdd010a591bcceed731b790649ce0;p=pdns Allow comments in the forward-zones-file * Closes #2430 * Lines starting with a '#' get skipped. * Everything after a '#' symbol on a line is ignored * Document this change --- diff --git a/docs/markdown/recursor/settings.md b/docs/markdown/recursor/settings.md index f63f5d9d3..cb0e01564 100644 --- a/docs/markdown/recursor/settings.md +++ b/docs/markdown/recursor/settings.md @@ -268,12 +268,13 @@ setting is intended to forward queries to authoritative servers. Same as [`forward-zones`](#forward-zones), parsed from a file. Only 1 zone is allowed per line, specified as follows: `example.org=203.0.113.210, 192.0.2.4:5300`. -No comments are allowed. Since version 3.2, zones prefixed with a '+' are forwarded with the recursion-desired bit set to one, for which see ['forward-zones-recurse'](#forward-zones-recurse). Default behaviour without '+' is as with [`forward-zones`](#forward-zones). +Comments are allowed since version 4.0.0. Everything behind '#' is ignored. + ## `forward-zones-recurse` * 'zonename=IP' pairs, comma separated * Available since: 3.2 diff --git a/pdns/reczones.cc b/pdns/reczones.cc index e665c569a..17c9e202d 100644 --- a/pdns/reczones.cc +++ b/pdns/reczones.cc @@ -449,8 +449,12 @@ SyncRes::domainmap_t* parseAuthAndForwards() int linenum=0; uint64_t before = newMap->size(); while(linenum++, stringfgets(fp.get(), line)) { + trim(line); + if (line[0] == '#') // Comment line, skip to the next line + continue; string domain, instructions; tie(domain, instructions)=splitField(line, '='); + instructions = splitField(instructions, '#').first; // Remove EOL comments trim(domain); trim(instructions); if(domain.empty() && instructions.empty()) { // empty line