Removed root domain records from SOA. Instead, use RootDomain when calling Dns.primary.
This commit is contained in:
parent
cd10b5e2ed
commit
2279979d32
|
@ -149,18 +149,14 @@ namedConfFile = "/etc/bind/named.conf.local"
|
||||||
-- You do not need to increment the SerialNumber when making changes!
|
-- You do not need to increment the SerialNumber when making changes!
|
||||||
-- Propellor will automatically add the number of commits in the git
|
-- Propellor will automatically add the number of commits in the git
|
||||||
-- repository to the SerialNumber.
|
-- repository to the SerialNumber.
|
||||||
--
|
mkSOA :: Domain -> SerialNumber -> SOA
|
||||||
-- Handy trick: You don't need to list IPAddrs in the [Record],
|
mkSOA d sn = SOA
|
||||||
-- just make some Host set its `alias` to the root of domain.
|
|
||||||
mkSOA :: Domain -> SerialNumber -> [Record] -> SOA
|
|
||||||
mkSOA d sn rs = SOA
|
|
||||||
{ sDomain = AbsDomain d
|
{ sDomain = AbsDomain d
|
||||||
, sSerial = sn
|
, sSerial = sn
|
||||||
, sRefresh = hours 4
|
, sRefresh = hours 4
|
||||||
, sRetry = hours 1
|
, sRetry = hours 1
|
||||||
, sExpire = 2419200 -- 4 weeks
|
, sExpire = 2419200 -- 4 weeks
|
||||||
, sNegativeCacheTTL = hours 8
|
, sNegativeCacheTTL = hours 8
|
||||||
, sRecord = rs
|
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
hours n = n * 60 * 60
|
hours n = n * 60 * 60
|
||||||
|
@ -168,7 +164,7 @@ mkSOA d sn rs = SOA
|
||||||
dValue :: BindDomain -> String
|
dValue :: BindDomain -> String
|
||||||
dValue (RelDomain d) = d
|
dValue (RelDomain d) = d
|
||||||
dValue (AbsDomain d) = d ++ "."
|
dValue (AbsDomain d) = d ++ "."
|
||||||
dValue (SOADomain) = "@"
|
dValue (RootDomain) = "@"
|
||||||
|
|
||||||
rField :: Record -> String
|
rField :: Record -> String
|
||||||
rField (Address (IPv4 _)) = "A"
|
rField (Address (IPv4 _)) = "A"
|
||||||
|
@ -246,43 +242,37 @@ readZonePropellorFile f = catchDefaultIO Nothing $
|
||||||
-- | Generating a zone file.
|
-- | Generating a zone file.
|
||||||
genZoneFile :: Zone -> String
|
genZoneFile :: Zone -> String
|
||||||
genZoneFile (Zone zdomain soa rs) = unlines $
|
genZoneFile (Zone zdomain soa rs) = unlines $
|
||||||
header : genSOA zdomain soa ++ map genr rs
|
header : genSOA soa ++ map (genRecord zdomain) rs
|
||||||
where
|
where
|
||||||
header = com $ "BIND zone file for " ++ zdomain ++ ". Generated by propellor, do not edit."
|
header = com $ "BIND zone file for " ++ zdomain ++ ". Generated by propellor, do not edit."
|
||||||
|
|
||||||
genr (d, r) = genRecord zdomain (Just d, r)
|
genRecord :: Domain -> (BindDomain, Record) -> String
|
||||||
|
genRecord zdomain (domain, record) = intercalate "\t"
|
||||||
genRecord :: Domain -> (Maybe BindDomain, Record) -> String
|
[ domainHost zdomain domain
|
||||||
genRecord zdomain (mdomain, record) = intercalate "\t"
|
|
||||||
[ hn
|
|
||||||
, "IN"
|
, "IN"
|
||||||
, rField record
|
, rField record
|
||||||
, rValue record
|
, rValue record
|
||||||
]
|
]
|
||||||
where
|
|
||||||
hn = maybe "" (domainHost zdomain) mdomain
|
|
||||||
|
|
||||||
genSOA :: Domain -> SOA -> [String]
|
genSOA :: SOA -> [String]
|
||||||
genSOA zdomain soa =
|
genSOA soa =
|
||||||
header ++ map (genRecord zdomain) (zip (repeat Nothing) (sRecord soa))
|
-- "@ IN SOA ns1.example.com. root ("
|
||||||
where
|
[ intercalate "\t"
|
||||||
header =
|
[ dValue RootDomain
|
||||||
-- "@ IN SOA ns1.example.com. root ("
|
, "IN"
|
||||||
[ intercalate "\t"
|
, "SOA"
|
||||||
[ dValue SOADomain
|
, dValue (sDomain soa)
|
||||||
, "IN"
|
, "root"
|
||||||
, "SOA"
|
, "("
|
||||||
, dValue (sDomain soa)
|
|
||||||
, "root"
|
|
||||||
, "("
|
|
||||||
]
|
|
||||||
, headerline sSerial "Serial"
|
|
||||||
, headerline sRefresh "Refresh"
|
|
||||||
, headerline sRetry "Retry"
|
|
||||||
, headerline sExpire "Expire"
|
|
||||||
, headerline sNegativeCacheTTL "Negative Cache TTL"
|
|
||||||
, inheader ")"
|
|
||||||
]
|
]
|
||||||
|
, 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
|
headerline r comment = inheader $ show (r soa) ++ "\t\t" ++ com comment
|
||||||
inheader l = "\t\t\t" ++ l
|
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.
|
-- suitable for using in a zone file.
|
||||||
domainHost :: Domain -> BindDomain -> String
|
domainHost :: Domain -> BindDomain -> String
|
||||||
domainHost _ (RelDomain d) = d
|
domainHost _ (RelDomain d) = d
|
||||||
domainHost _ SOADomain = "@"
|
domainHost _ RootDomain = "@"
|
||||||
domainHost base (AbsDomain d)
|
domainHost base (AbsDomain d)
|
||||||
| dotbase `isSuffixOf` d = take (length d - length dotbase) d
|
| dotbase `isSuffixOf` d = take (length d - length dotbase) d
|
||||||
| base == d = "@"
|
| base == d = "@"
|
||||||
|
|
|
@ -43,8 +43,6 @@ data SOA = SOA
|
||||||
, sRetry :: Integer
|
, sRetry :: Integer
|
||||||
, sExpire :: Integer
|
, sExpire :: Integer
|
||||||
, sNegativeCacheTTL :: Integer
|
, sNegativeCacheTTL :: Integer
|
||||||
, sRecord :: [Record]
|
|
||||||
-- ^ Records for the root of the domain. Typically NS, A, TXT
|
|
||||||
}
|
}
|
||||||
deriving (Read, Show, Eq)
|
deriving (Read, Show, Eq)
|
||||||
|
|
||||||
|
@ -76,6 +74,7 @@ type SerialNumber = Word32
|
||||||
-- Let's use a type to keep absolute domains straight from relative
|
-- Let's use a type to keep absolute domains straight from relative
|
||||||
-- domains.
|
-- domains.
|
||||||
--
|
--
|
||||||
-- The SOADomain refers to the root SOA record.
|
-- The RootDomain refers to the top level of the domain, so can be used
|
||||||
data BindDomain = RelDomain Domain | AbsDomain Domain | SOADomain
|
-- to add nameservers, MX's, etc to a domain.
|
||||||
|
data BindDomain = RelDomain Domain | AbsDomain Domain | RootDomain
|
||||||
deriving (Read, Show, Eq, Ord)
|
deriving (Read, Show, Eq, Ord)
|
||||||
|
|
|
@ -124,15 +124,14 @@ hosts = -- (o) `
|
||||||
|
|
||||||
& myDnsSecondary
|
& myDnsSecondary
|
||||||
& Dns.primary hosts "olduse.net"
|
& Dns.primary hosts "olduse.net"
|
||||||
( Dns.mkSOA "ns1.kitenet.net" 100
|
(Dns.mkSOA "ns1.kitenet.net" 100)
|
||||||
[ NS (AbsDomain "ns1.kitenet.net")
|
[ (RootDomain, NS $ AbsDomain "ns1.kitenet.net")
|
||||||
, NS (AbsDomain "ns6.gandi.net")
|
, (RootDomain, NS $ AbsDomain "ns6.gandi.net")
|
||||||
, NS (AbsDomain "ns2.kitenet.net")
|
, (RootDomain, NS $ AbsDomain "ns2.kitenet.net")
|
||||||
, MX 0 (AbsDomain "kitenet.net")
|
, (RootDomain, MX 0 $ AbsDomain "kitenet.net")
|
||||||
, TXT "v=spf1 a -all"
|
, (RootDomain, TXT "v=spf1 a -all")
|
||||||
]
|
, (RelDomain "article", CNAME $ AbsDomain "virgil.koldfront.dk")
|
||||||
)
|
]
|
||||||
[ (RelDomain "article", CNAME $ AbsDomain "virgil.koldfront.dk") ]
|
|
||||||
|
|
||||||
& Apt.installed ["ntop"]
|
& Apt.installed ["ntop"]
|
||||||
|
|
||||||
|
|
|
@ -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 (0.4.0) unstable; urgency=medium
|
||||||
|
|
||||||
* Propellor can configure primary DNS servers, including generating
|
* Propellor can configure primary DNS servers, including generating
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Name: propellor
|
Name: propellor
|
||||||
Version: 0.4.0
|
Version: 0.5.0
|
||||||
Cabal-Version: >= 1.6
|
Cabal-Version: >= 1.6
|
||||||
License: GPL
|
License: GPL
|
||||||
Maintainer: Joey Hess <joey@kitenet.net>
|
Maintainer: Joey Hess <joey@kitenet.net>
|
||||||
|
|
Loading…
Reference in New Issue