X-Git-Url: http://average.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=PowerDns.hs;h=9a2a4987443c9d052a40257f005a04dcd1aa8343;hb=0d59aa176c8ca6665f59426a436671099a393d3f;hp=7ed76e8a24bc046dcb42a96382d932f20c4210cb;hpb=adf1eff6277a0f1fb69f505285a20554a9ecabd6;p=pdns-pipe-nmc.git diff --git a/PowerDns.hs b/PowerDns.hs index 7ed76e8..9a2a498 100644 --- a/PowerDns.hs +++ b/PowerDns.hs @@ -1,4 +1,11 @@ -module PowerDns where +module PowerDns ( RRType(..) + , PdnsRequest(..) + , pdnsParse + , pdnsReport + , pdnsOut + ) where + +import NmcJson data RRType = RRTypeSRV | RRTypeA | RRTypeAAAA | RRTypeCNAME | RRTypeDNAME | RRTypeSOA | RRTypeRP | RRTypeLOC @@ -55,18 +62,18 @@ pdnsParse ver s = , localIpAddress = getLIp ver xs , ednsSubnetAddress = getRIp ver xs }) - _ -> Left s + _ -> Left $ "Unparseable PDNS Request: " ++ s + +pdnsReport :: String -> String +pdnsReport err = + "LOG\tError: " ++ err ++ "\nFAIL\n" + +pdnsOut :: Int -> String -> RRType -> Either String NmcDom -> String +pdnsOut ver id rrtype edom = + case edom of + Left err -> pdnsReport err + Right dom -> pdnsAmend ver id rrtype dom "END\n" -{- -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" --} +pdnsAmend :: Int -> String -> RRType -> NmcDom -> String -> String +pdnsAmend ver id rrtype dom accum = + "DATA\t" ++ (show dom) ++ "\n" ++ accum --FIXME