From: Eugene Crosser Date: Sun, 13 Apr 2014 17:54:26 +0000 (+0400) Subject: SRV hack part 2 X-Git-Tag: 0.9.0.0~74 X-Git-Url: http://average.org/gitweb/?a=commitdiff_plain;h=778903b569e2a43c43758f1ebcb3e90ba1b6032d;p=pdns-pipe-nmc.git SRV hack part 2 --- diff --git a/NmcDom.hs b/NmcDom.hs index d053954..3f6c7bc 100644 --- a/NmcDom.hs +++ b/NmcDom.hs @@ -41,8 +41,8 @@ instance Eq a => Mergeable [a] where data NmcRRService = NmcRRService { srvName :: String , srvProto :: String - , srvW1 :: Int - , srvW2 :: Int + , srvPrio :: Int + , srvWeight :: Int , srvPort :: Int , srvHost :: String } deriving (Show, Eq) @@ -222,10 +222,18 @@ mergeSelf base = Just sub -> (mergeSelf sub) `merge` base' -- recursion depth limited by the size of the record +-- | SRV case - remove everyting and filter SRV records +normalizeSrv :: String -> String -> NmcDom -> NmcDom +normalizeSrv serv proto dom = + emptyNmcDom {domService = fmap (filter needed) (domService dom)} + where + needed r = srvName r == serv && srvProto r == proto + -- | Presence of some elements require removal of some others normalizeDom :: NmcDom -> NmcDom -normalizeDom dom = foldr id dom [ translateNormalizer - -- , nsNormalizer -- FIXME retrun this +normalizeDom dom = foldr id dom [ srvNormalizer + , translateNormalizer + , nsNormalizer ] where nsNormalizer dom = case domNs dom of @@ -234,6 +242,7 @@ normalizeDom dom = foldr id dom [ translateNormalizer translateNormalizer dom = case domTranslate dom of Nothing -> dom Just tr -> dom { domMap = Nothing } + srvNormalizer dom = dom { domService = Nothing } -- | Merge imports and Selfs and follow the maps tree to get dom descendNmcDom :: @@ -246,7 +255,7 @@ descendNmcDom queryOp subdom base = do case subdom of [] -> return $ fmap normalizeDom base' -- A hack to handle SRV records: don't descend if ["_prot","_serv"] - [('_':_),('_':_)] -> return $ fmap normalizeDom base' + [('_':p),('_':s)] -> return $ fmap (normalizeSrv s p) base' d:ds -> case base' of Left err -> return base' diff --git a/PowerDns.hs b/PowerDns.hs index 7e2d9cc..8962e94 100644 --- a/PowerDns.hs +++ b/PowerDns.hs @@ -92,7 +92,7 @@ nmc2pdns name RRTypeA dom = mapto name "A" $ domIp dom nmc2pdns name RRTypeAAAA dom = mapto name "AAAA" $ domIp6 dom nmc2pdns name RRTypeCNAME dom = takejust name "CNAME" $ domAlias dom nmc2pdns name RRTypeDNAME dom = takejust name "DNAME" $ domTranslate dom -nmc2pdns name RRTypeSOA dom = +nmc2pdns name RRTypeSOA dom = -- FIXME generate only for top domain if dom == emptyNmcDom then [] else let