diff options
| author | Joey Hess <joey@kitenet.net> | 2014-06-05 16:52:45 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-06-05 16:52:45 -0400 |
| commit | f8bad2726760268f1daae2a3329be5db310727b8 (patch) | |
| tree | ab5db4785fee3c7e919213b97975e727e7724907 /src/Propellor/Property/Dns.hs | |
| parent | 383548956354a00cf24323310e9981ccea6a1ddf (diff) | |
| parent | dbffd982bac47cebd3fc67e51b46182f7e43392d (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Property/Dns.hs')
| -rw-r--r-- | src/Propellor/Property/Dns.hs | 13 |
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 |
