From f3f7bb19bb6f30f48ae6d7e272bc59b7fa8efd10 Mon Sep 17 00:00:00 2001 From: Félix Sipma Date: Tue, 15 Sep 2015 21:23:27 +0200 Subject: 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 --- src/Propellor/Property/Unbound.hs | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) (limited to 'src/Propellor/Property/Unbound.hs') 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 ++ "\"" -- cgit v1.2.3