summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Dns.hs
diff options
context:
space:
mode:
authorJoey Hess2014-06-01 07:32:16 -0400
committerJoey Hess2014-06-01 07:32:16 -0400
commit5799b89d9f5b7c9b8e00467392b72b751d2239d9 (patch)
tree5f179df11b9134151a815742f14c1b484a92d532 /src/Propellor/Property/Dns.hs
parent9ce4a434ceb78518b7e2656f6545e0b8872d5c0c (diff)
filter out dup CNAMES
This happens when a docker host has an alias defined, because all docker hosts are added to the dns, same as other hosts.
Diffstat (limited to 'src/Propellor/Property/Dns.hs')
-rw-r--r--src/Propellor/Property/Dns.hs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/Propellor/Property/Dns.hs b/src/Propellor/Property/Dns.hs
index 3e5c7828..50ce649e 100644
--- a/src/Propellor/Property/Dns.hs
+++ b/src/Propellor/Property/Dns.hs
@@ -339,7 +339,7 @@ genZone hosts zdomain soa =
, map hostrecords inzdomain
, map addcnames (M.elems m)
]
- in (Zone zdomain soa (nub zhosts), warnings)
+ in (Zone zdomain soa (simplify zhosts), warnings)
where
m = hostMap hosts
-- Known hosts with hostname located in the zone's domain.
@@ -390,6 +390,17 @@ genZone hosts zdomain soa =
l = zip (repeat $ AbsDomain $ hostName h)
(S.toList $ S.filter (\r -> isNothing (getIPAddr r) && isNothing (getCNAME r)) (_dns attr))
+ -- Simplifies the list of hosts. Remove duplicate entries.
+ -- Also, filter out any CHAMES where the same domain has an
+ -- IP address, since that's not legal.
+ simplify :: [(BindDomain, Record)] -> [(BindDomain, Record)]
+ simplify l = nub $ filter (not . dupcname ) l
+ where
+ dupcname (d, CNAME _) | any (matchingaddr d) l = True
+ dupcname _ = False
+ matchingaddr d (d', (Address _)) | d == d' = True
+ matchingaddr _ _ = False
+
inDomain :: Domain -> BindDomain -> Bool
inDomain domain (AbsDomain d) = domain == d || ('.':domain) `isSuffixOf` d
inDomain _ _ = False -- can't tell, so assume not