summaryrefslogtreecommitdiff
path: root/Propellor/Property
diff options
context:
space:
mode:
authorJoey Hess2014-04-19 10:47:38 -0400
committerJoey Hess2014-04-19 10:47:38 -0400
commit2279979d32b252d826c23288bb90a723d6a1147d (patch)
treefb2b0699310153103660fdeb2aec4c601b53a561 /Propellor/Property
parentcd10b5e2ed2a5e4053ae733a7c8961303f2dcb35 (diff)
Removed root domain records from SOA. Instead, use RootDomain when calling Dns.primary.
Diffstat (limited to 'Propellor/Property')
-rw-r--r--Propellor/Property/Dns.hs62
1 files changed, 26 insertions, 36 deletions
diff --git a/Propellor/Property/Dns.hs b/Propellor/Property/Dns.hs
index 0813e61f..b9738e41 100644
--- a/Propellor/Property/Dns.hs
+++ b/Propellor/Property/Dns.hs
@@ -149,18 +149,14 @@ namedConfFile = "/etc/bind/named.conf.local"
-- You do not need to increment the SerialNumber when making changes!
-- Propellor will automatically add the number of commits in the git
-- repository to the SerialNumber.
---
--- Handy trick: You don't need to list IPAddrs in the [Record],
--- just make some Host set its `alias` to the root of domain.
-mkSOA :: Domain -> SerialNumber -> [Record] -> SOA
-mkSOA d sn rs = SOA
+mkSOA :: Domain -> SerialNumber -> SOA
+mkSOA d sn = SOA
{ sDomain = AbsDomain d
, sSerial = sn
, sRefresh = hours 4
, sRetry = hours 1
, sExpire = 2419200 -- 4 weeks
, sNegativeCacheTTL = hours 8
- , sRecord = rs
}
where
hours n = n * 60 * 60
@@ -168,7 +164,7 @@ mkSOA d sn rs = SOA
dValue :: BindDomain -> String
dValue (RelDomain d) = d
dValue (AbsDomain d) = d ++ "."
-dValue (SOADomain) = "@"
+dValue (RootDomain) = "@"
rField :: Record -> String
rField (Address (IPv4 _)) = "A"
@@ -246,43 +242,37 @@ readZonePropellorFile f = catchDefaultIO Nothing $
-- | Generating a zone file.
genZoneFile :: Zone -> String
genZoneFile (Zone zdomain soa rs) = unlines $
- header : genSOA zdomain soa ++ map genr rs
+ header : genSOA soa ++ map (genRecord zdomain) rs
where
header = com $ "BIND zone file for " ++ zdomain ++ ". Generated by propellor, do not edit."
- genr (d, r) = genRecord zdomain (Just d, r)
-
-genRecord :: Domain -> (Maybe BindDomain, Record) -> String
-genRecord zdomain (mdomain, record) = intercalate "\t"
- [ hn
+genRecord :: Domain -> (BindDomain, Record) -> String
+genRecord zdomain (domain, record) = intercalate "\t"
+ [ domainHost zdomain domain
, "IN"
, rField record
, rValue record
]
- where
- hn = maybe "" (domainHost zdomain) mdomain
-genSOA :: Domain -> SOA -> [String]
-genSOA zdomain soa =
- header ++ map (genRecord zdomain) (zip (repeat Nothing) (sRecord soa))
- where
- header =
- -- "@ IN SOA ns1.example.com. root ("
- [ intercalate "\t"
- [ dValue SOADomain
- , "IN"
- , "SOA"
- , dValue (sDomain soa)
- , "root"
- , "("
- ]
- , headerline sSerial "Serial"
- , headerline sRefresh "Refresh"
- , headerline sRetry "Retry"
- , headerline sExpire "Expire"
- , headerline sNegativeCacheTTL "Negative Cache TTL"
- , inheader ")"
+genSOA :: SOA -> [String]
+genSOA soa =
+ -- "@ IN SOA ns1.example.com. root ("
+ [ intercalate "\t"
+ [ dValue RootDomain
+ , "IN"
+ , "SOA"
+ , dValue (sDomain soa)
+ , "root"
+ , "("
]
+ , headerline sSerial "Serial"
+ , headerline sRefresh "Refresh"
+ , headerline sRetry "Retry"
+ , headerline sExpire "Expire"
+ , headerline sNegativeCacheTTL "Negative Cache TTL"
+ , inheader ")"
+ ]
+ where
headerline r comment = inheader $ show (r soa) ++ "\t\t" ++ com comment
inheader l = "\t\t\t" ++ l
@@ -357,7 +347,7 @@ inDomain _ _ = False -- can't tell, so assume not
-- suitable for using in a zone file.
domainHost :: Domain -> BindDomain -> String
domainHost _ (RelDomain d) = d
-domainHost _ SOADomain = "@"
+domainHost _ RootDomain = "@"
domainHost base (AbsDomain d)
| dotbase `isSuffixOf` d = take (length d - length dotbase) d
| base == d = "@"