-module PowerDns where
+module PowerDns ( RRType(..)
+ , PdnsRequest(..)
+ , pdnsParse
+ , pdnsOut
+ ) where
+
+import NmcJson
data RRType = RRTypeSRV | RRTypeA | RRTypeAAAA | RRTypeCNAME
| RRTypeDNAME | RRTypeSOA | RRTypeRP | RRTypeLOC
, 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