commit 0ea992ab4f084e5a6729c2033a55b067ae22923e
parent f81a7f0a1363b6957e753c677606c1d5a67612d0
Author: Kirill Elagin <kirelagin@gmail.com>
Date: Sun, 10 Mar 2019 02:23:27 +0100
parent f81a7f0a1363b6957e753c677606c1d5a67612d0
Author: Kirill Elagin <kirelagin@gmail.com>
Date: Sun, 10 Mar 2019 02:23:27 +0100
combinators: Add SPF
3 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md @@ -39,6 +39,10 @@ with dns.combinators; { CAA = letsEncrypt "admin@example.com"; # Common template combinators included + TXT = [ + (with spf; strict [google]) # SPF: only allow gmail + ]; + subdomains = { www = { A = [ (a "203.0.114.1") ];
diff --git a/dns/combinators.nix b/dns/combinators.nix @@ -8,6 +8,7 @@ let inherit (builtins) map; + inherit (pkgs) lib; in @@ -54,4 +55,15 @@ letsEncrypt = email: [ } ]; +spf = + let + toSpf = rs: + txt (lib.concatStringsSep " " (["v=spf1"] ++ rs)); + in { + soft = rs: toSpf (rs ++ ["~all"]); + strict = rs: toSpf (rs ++ ["-all"]); + + google = "include:_spf.google.com"; + }; + }
diff --git a/example.nix b/example.nix @@ -29,6 +29,10 @@ let (aaaa "4321:0:1:2:3:4:567:89ab") ]; + TXT = [ + (with spf; strict ["a:mail.example.com" google]) + ]; + CAA = letsEncrypt "admin@example.com"; subdomains = {