Removed root domain records from SOA. Instead, use RootDomain when calling Dns.primary.

This commit is contained in:
Joey Hess 2014-04-19 10:47:38 -04:00
parent cd10b5e2ed
commit 2279979d32
5 changed files with 45 additions and 50 deletions

View File

@ -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,30 +242,23 @@ 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 =
genSOA :: SOA -> [String]
genSOA soa =
-- "@ IN SOA ns1.example.com. root ("
[ intercalate "\t"
[ dValue SOADomain
[ dValue RootDomain
, "IN"
, "SOA"
, dValue (sDomain soa)
@ -283,6 +272,7 @@ genSOA zdomain soa =
, 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 = "@"

View File

@ -43,8 +43,6 @@ data SOA = SOA
, sRetry :: Integer
, sExpire :: Integer
, sNegativeCacheTTL :: Integer
, sRecord :: [Record]
-- ^ Records for the root of the domain. Typically NS, A, TXT
}
deriving (Read, Show, Eq)
@ -76,6 +74,7 @@ type SerialNumber = Word32
-- Let's use a type to keep absolute domains straight from relative
-- domains.
--
-- The SOADomain refers to the root SOA record.
data BindDomain = RelDomain Domain | AbsDomain Domain | SOADomain
-- The RootDomain refers to the top level of the domain, so can be used
-- to add nameservers, MX's, etc to a domain.
data BindDomain = RelDomain Domain | AbsDomain Domain | RootDomain
deriving (Read, Show, Eq, Ord)

View File

@ -124,15 +124,14 @@ hosts = -- (o) `
& myDnsSecondary
& Dns.primary hosts "olduse.net"
( Dns.mkSOA "ns1.kitenet.net" 100
[ NS (AbsDomain "ns1.kitenet.net")
, NS (AbsDomain "ns6.gandi.net")
, NS (AbsDomain "ns2.kitenet.net")
, MX 0 (AbsDomain "kitenet.net")
, TXT "v=spf1 a -all"
(Dns.mkSOA "ns1.kitenet.net" 100)
[ (RootDomain, NS $ AbsDomain "ns1.kitenet.net")
, (RootDomain, NS $ AbsDomain "ns6.gandi.net")
, (RootDomain, NS $ AbsDomain "ns2.kitenet.net")
, (RootDomain, MX 0 $ AbsDomain "kitenet.net")
, (RootDomain, TXT "v=spf1 a -all")
, (RelDomain "article", CNAME $ AbsDomain "virgil.koldfront.dk")
]
)
[ (RelDomain "article", CNAME $ AbsDomain "virgil.koldfront.dk") ]
& Apt.installed ["ntop"]

7
debian/changelog vendored
View File

@ -1,3 +1,10 @@
propellor (0.5.0) UNRELEASED; urgency=medium
* Removed root domain records from SOA. Instead, use RootDomain
when calling Dns.primary.
-- Joey Hess <joeyh@debian.org> Sat, 19 Apr 2014 10:46:35 -0400
propellor (0.4.0) unstable; urgency=medium
* Propellor can configure primary DNS servers, including generating

View File

@ -1,5 +1,5 @@
Name: propellor
Version: 0.4.0
Version: 0.5.0
Cabal-Version: >= 1.6
License: GPL
Maintainer: Joey Hess <joey@kitenet.net>