X-Git-Url: http://www.average.org/gitweb/?p=pdns-pipe-nmc.git;a=blobdiff_plain;f=PowerDns.hs;h=77c514994d3afa6a8dbce6ae8e71237688688edf;hp=7e2d9cc8d440a5dcdd8adf4708e6b415ab1b76c7;hb=52f46690b44be5d8e40fd7865d78b71559572ccc;hpb=37084c2c7ca994c3690cc8729e7849a6c7177ea4 diff --git a/PowerDns.hs b/PowerDns.hs index 7e2d9cc..77c5149 100644 --- a/PowerDns.hs +++ b/PowerDns.hs @@ -9,7 +9,7 @@ import NmcDom data RRType = RRTypeSRV | RRTypeA | RRTypeAAAA | RRTypeCNAME | RRTypeDNAME | RRTypeSOA | RRTypeRP | RRTypeLOC - | RRTypeNS | RRTypeDS + | RRTypeNS | RRTypeDS | RRTypeMX | RRTypeANY | RRTypeError String deriving (Show) @@ -38,6 +38,7 @@ pdnsParse ver s = "LOC" -> RRTypeLOC "NS" -> RRTypeNS "DS" -> RRTypeDS + "MX" -> RRTypeMX "ANY" -> RRTypeANY _ -> RRTypeError qt getLIp ver xs @@ -85,14 +86,15 @@ pdnsOut ver id name rrtype edom = nmc2pdns :: String -> RRType -> NmcDom -> [(String, String, String)] nmc2pdns name RRTypeANY dom = foldr (\r accum -> (nmc2pdns name r dom) ++ accum) [] - [RRTypeA, RRTypeAAAA, RRTypeCNAME, RRTypeDNAME, -- no SRV here! - RRTypeSOA, RRTypeRP, RRTypeLOC, RRTypeNS, RRTypeDS] -nmc2pdns name RRTypeSRV dom = [] -- FIXME + [RRTypeSRV, RRTypeA, RRTypeAAAA, RRTypeCNAME, RRTypeDNAME, + RRTypeSOA, RRTypeRP, RRTypeLOC, RRTypeNS, RRTypeDS, RRTypeMX] +nmc2pdns name RRTypeSRV dom = makesrv name "SRV" $ domService dom +nmc2pdns name RRTypeMX dom = mapto name "MX" $ domMx dom 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 @@ -116,3 +118,12 @@ mapto name rrstr maybel = case maybel of takejust name rrstr maybestr = case maybestr of Nothing -> [] Just str -> [(name, rrstr, str)] + +makesrv name rrstr mayberl = case mayberl of + Nothing -> [] + Just srl -> map (\x -> (name, rrstr, fmtsrv x)) srl + where + fmtsrv rl = (show (srvPrio rl)) ++ " " + ++ (show (srvWeight rl)) ++ " " + ++ (show (srvPort rl)) ++ " " + ++ (srvHost rl)