summaryrefslogtreecommitdiff
path: root/src/Propellor
diff options
context:
space:
mode:
authorJoey Hess2018-06-24 11:32:46 -0400
committerJoey Hess2018-06-24 11:32:46 -0400
commit30ce1535b66f402ff8316554000f1a3dc729c26f (patch)
tree9fb2da011e6d8998abc25862e0f7bfcd03ea9286 /src/Propellor
parent7d6180a26fa2c12b1e42e0e039313c42eca0beb2 (diff)
refactor
could use zoneFileString for other things eg SSHFP. I have not yet, because AFAICS, SSHFP already splits the key up in a different way and while using zoneFileString should be ok, I'd need to test it..
Diffstat (limited to 'src/Propellor')
-rw-r--r--src/Propellor/Property/Dns.hs23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/Propellor/Property/Dns.hs b/src/Propellor/Property/Dns.hs
index c89ce271..8e38a75e 100644
--- a/src/Propellor/Property/Dns.hs
+++ b/src/Propellor/Property/Dns.hs
@@ -322,17 +322,32 @@ rValue (SSHFP x y s) = Just $ unwords
, s
]
rValue (INCLUDE f) = Just f
-rValue (TXT s) = Just $ [op] ++ [w]
- ++ (intercalate "\n\t" $
+rValue (TXT s) = Just $ zoneFileString s
+ where
+ op = '('
+ cp = ')'
+ w = ' '
+ q = '"'
+rValue (PTR _) = Nothing
+
+-- Bind has a limit on the length of a string in its zone file,
+-- but a string can be split into sections that are glued together
+-- inside parens to configure a longer value.
+--
+-- This adds quotes around each substring.
+zoneFileString :: String -> String
+zoneFileString s = concat
+ [ [op, w]
+ , (intercalate "\n\t" $
map (\x -> [q] ++ filter (/= q) x ++ [q]) $
Split.chunksOf 255 s)
- ++ [w] ++ [cp]
+ , [w, cp]
+ ]
where
op = '('
cp = ')'
w = ' '
q = '"'
-rValue (PTR _) = Nothing
-- | Adjusts the serial number of the zone to always be larger
-- than the serial number in the Zone record,