X-Git-Url: http://www.average.org/gitweb/?p=pdns-pipe-nmc.git;a=blobdiff_plain;f=PowerDns.hs;h=cbc9fb5df94babc05c9f715b7e6779aa0878e276;hp=0e8be9fe0d20a2522c747e5d8c845b3848aefc9f;hb=291b90a1ae073a9c1528a132ea14ea282dc379c1;hpb=16e20fe34fe4a0e43423c94640ed50469689dce0 diff --git a/PowerDns.hs b/PowerDns.hs index 0e8be9f..cbc9fb5 100644 --- a/PowerDns.hs +++ b/PowerDns.hs @@ -81,7 +81,7 @@ pdnsParse ver s = "AXFR":x:[] -> Right (PdnsRequestAXFR (getInt x)) "Q":qn:"IN":qt:id:rip:xs -> case rrType qt of RRTypeError e -> - Left $ "PDNS Request: " ++ e + Left $ "PDNS Request: " ++ (show qt) rt -> Right (PdnsRequestQ { qName = qn @@ -99,23 +99,29 @@ pdnsReport err = "LOG\tError: " ++ err ++ "\nFAIL\n" -- | Produce answer to the Q request pdnsOut :: Int -> Int -> String -> RRType -> Either String NmcDom -> String -pdnsOut ver id name rrtype edom = case edom of - Left err -> - pdnsReport $ err ++ " in a " ++ (show rrtype) ++ "query for " ++ name - Right dom -> - case rrtype of - RRTypeANY -> foldr (\x a -> (formatRR ver id name dom x) ++ a) "END\n" - [RRTypeSRV, RRTypeA, RRTypeAAAA, RRTypeCNAME, RRTypeDNAME, - RRTypeRP, RRTypeLOC, RRTypeNS, RRTypeDS, RRTypeMX] - _ -> (formatRR ver id name dom rrtype) ++ "END\n" +pdnsOut ver id name rrtype edom = + let + rrl = case rrtype of + RRTypeANY -> [RRTypeSRV, RRTypeA, RRTypeAAAA, RRTypeCNAME + , RRTypeDNAME, RRTypeRP, RRTypeLOC, RRTypeNS + , RRTypeDS, RRTypeMX] + rrt -> [rrt] + in + (formatDom ver id name rrl edom) ++ "END\n" -- | Produce answer to the AXFR request pdnsOutXfr :: Int -> Int -> String -> Either String NmcDom -> String pdnsOutXfr ver id name edom = "" -- FIXME +formatDom ver id name rrl edom = case edom of + Left err -> + pdnsReport $ err ++ " in the " ++ (show rrl) ++ " query for " ++ name + Right dom -> + foldr (\x a -> (formatRR ver id name dom x) ++ a) "" rrl + formatRR ver id name dom rrtype = foldr (\x a -> "DATA\t" ++ v3ext ++ name ++ "\tIN\t" ++ (show rrtype) - ++ "\t" ++ ttl ++ "\t" ++ (show id) ++ "\t" ++ x ++ "\n" ++ a) + ++ "\t" ++ ttl ++ "\t" ++ (show id) ++ "\t" ++ x ++ "\n" ++ a) "" $ dataRR rrtype name dom where v3ext = case ver of