X-Git-Url: http://www.average.org/gitweb/?p=pdns-pipe-nmc.git;a=blobdiff_plain;f=PowerDns.hs;h=1c1e420c6e13c0c61d25e1dc98537933f802bad0;hp=7ed76e8a24bc046dcb42a96382d932f20c4210cb;hb=1ee19d546701efde4b4b2f2f70bedae907a5266d;hpb=adf1eff6277a0f1fb69f505285a20554a9ecabd6 diff --git a/PowerDns.hs b/PowerDns.hs index 7ed76e8..1c1e420 100644 --- a/PowerDns.hs +++ b/PowerDns.hs @@ -1,4 +1,10 @@ -module PowerDns where +module PowerDns ( RRType(..) + , PdnsRequest(..) + , pdnsParse + , pdnsOut + ) where + +import NmcJson data RRType = RRTypeSRV | RRTypeA | RRTypeAAAA | RRTypeCNAME | RRTypeDNAME | RRTypeSOA | RRTypeRP | RRTypeLOC @@ -55,18 +61,10 @@ pdnsParse ver s = , localIpAddress = getLIp ver xs , ednsSubnetAddress = getRIp ver xs }) - _ -> Left s + _ -> Left $ "Unparseable PDNS Request: " ++ s -{- -pdnsOut :: String -> Either String PdnsRequest -> IO () -pdnsOut _ (Left e) = putStrLn ("ERROR\tUnparseable request: " ++ e) -pdnsOut uri (Right rq) = case rq of - PdnsRequestQ qn qt id lip rip eip -> do - dom <- queryNmc uri qn qt id - case dom of - Left e -> putStrLn ("ERROR\tNmc query error: " ++ e) - Right result -> print result - PdnsRequestAXFR xfrreq -> - putStrLn ("ERROR\t No support for AXFR " ++ xfrreq) - PdnsRequestPing -> putStrLn "OK" --} +pdnsOut :: Int -> RRType -> Either String NmcDom -> String +pdnsOut ver rrtype edom = + case edom of + Left err -> "LOG Error: " ++ err ++ "\nFAIL\n" + Right dom -> "DATA\n" ++ (show dom) ++ "\nEND\n" --FIXME