diff options
| author | Félix Sipma <felix.sipma@no-log.org> | 2015-09-15 21:23:27 +0200 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-09-15 21:17:05 -0400 |
| commit | f3f7bb19bb6f30f48ae6d7e272bc59b7fa8efd10 (patch) | |
| tree | a09592824d8862cff4562e038842f8c1f7db19c0 /src/Propellor/Property/Unbound.hs | |
| parent | 00e824fd0460d5275fc6c6730dd701623f3492c3 (diff) | |
add PTR record type to Propellor.Types.DNS.Record
- add canonicalIP and reverseIP to Propellor.Types.Dns
- remove corresponding canonical and revIP from Propellor.Property.Unbound
- Propellor.Property.Dns: convert rValue, rField and genRecord to return
Maybe String
Signed-off-by: Félix Sipma <felix.sipma@no-log.org>
Diffstat (limited to 'src/Propellor/Property/Unbound.hs')
| -rw-r--r-- | src/Propellor/Property/Unbound.hs | 28 |
1 files changed, 1 insertions, 27 deletions
diff --git a/src/Propellor/Property/Unbound.hs b/src/Propellor/Property/Unbound.hs index 950f669e..205c9ddb 100644 --- a/src/Propellor/Property/Unbound.hs +++ b/src/Propellor/Property/Unbound.hs @@ -8,8 +8,6 @@ module Propellor.Property.Unbound , genAddress , genMX , genPTR - , revIP - , canonical , genZoneStatic , genZoneTransparent ) where @@ -18,9 +16,6 @@ import Propellor import qualified Propellor.Property.Apt as Apt import qualified Propellor.Property.Service as Service -import Data.List -import Data.String.Utils (split, replace) - installed :: Property NoInfo installed = Apt.installed ["unbound"] @@ -51,28 +46,7 @@ genMX :: BindDomain -> BindDomain -> Int -> String genMX dom dest priority = localData $ dValue dom ++ " " ++ "MX" ++ " " ++ show priority ++ " " ++ dValue dest genPTR :: BindDomain -> IPAddr -> String -genPTR dom ip = localData $ revIP ip ++ ". " ++ "PTR" ++ " " ++ dValue dom - -revIP :: IPAddr -> String -revIP (IPv4 addr) = intercalate "." (reverse $ split "." addr) ++ ".in-addr.arpa" -revIP addr@(IPv6 _) = reverse (intersperse '.' $ replace ":" "" $ fromIPAddr $ canonical addr) ++ ".ip6.arpa" - -canonical :: IPAddr -> IPAddr -canonical (IPv4 addr) = IPv4 addr -canonical (IPv6 addr) = IPv6 $ intercalate ":" $ map canonicalGroup $ split ":" $ replaceImplicitGroups addr - where - canonicalGroup g = case length g of - 0 -> "0000" - 1 -> "000" ++ g - 2 -> "00" ++ g - 3 -> "0" ++ g - _ -> g - emptyGroups n = iterate (++ ":") "" !! n - numberOfImplicitGroups a = 8 - length (split ":" $ replace "::" "" a) - replaceImplicitGroups a = concat $ aux $ split "::" a - where - aux [] = [] - aux (x : xs) = x : emptyGroups (numberOfImplicitGroups a) : xs +genPTR dom ip = localData $ reverseIP ip ++ ". " ++ "PTR" ++ " " ++ dValue dom localData :: String -> String localData conf = " local-data: \"" ++ conf ++ "\"" |
