trust-dns: properly quote TXT records
This commit is contained in:
parent
8fc57c4249
commit
c5c1378f59
|
@ -7,7 +7,20 @@ with lib;
|
||||||
let
|
let
|
||||||
cfg = config.sane.services.trust-dns;
|
cfg = config.sane.services.trust-dns;
|
||||||
toml = pkgs.formats.toml { };
|
toml = pkgs.formats.toml { };
|
||||||
fmtRecord = proto: rrtype: name: value: "${name}\t${proto}\t${rrtype}\t${value}";
|
recordFormatters = {
|
||||||
|
# quote rules for zone files:
|
||||||
|
# - any character may be encoded by `\DDD`, where `DDD` represents its ascii value in base 8.
|
||||||
|
# - any non-digit `X` may be encoded by `\X`.
|
||||||
|
# - stated in: <https://www.ietf.org/rfc/rfc1035.txt>: 5.1 Format
|
||||||
|
# - visible in <trust-dns:crates/proto/src/serialize/txt/zone_lex.rs:escape_seq>
|
||||||
|
# for us, we can just replace `\` => `\\ and `"` -> `\"`
|
||||||
|
TXT = value: "\"" + (lib.escape [ "\\" "\"" ] value) + "\"";
|
||||||
|
};
|
||||||
|
fmtRecord = proto: rrtype: name: value:
|
||||||
|
let
|
||||||
|
formatter = recordFormatters."${rrtype}" or lib.id;
|
||||||
|
in
|
||||||
|
"${name}\t${proto}\t${rrtype}\t${formatter value}";
|
||||||
fmtRecordList = proto: rrtype: name: values: concatStringsSep
|
fmtRecordList = proto: rrtype: name: values: concatStringsSep
|
||||||
"\n"
|
"\n"
|
||||||
(map (fmtRecord proto rrtype name) values)
|
(map (fmtRecord proto rrtype name) values)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user