module PowerDns ( RRType(..)
, PdnsRequest(..)
, pdnsParse
+ , pdnsReport
, pdnsOut
) where
})
_ -> Left $ "Unparseable PDNS Request: " ++ s
-pdnsOut :: Int -> RRType -> Either String NmcDom -> String
-pdnsOut ver rrtype edom =
+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 -> "LOG Error: " ++ err ++ "\nFAIL\n"
- Right dom -> "DATA\n" ++ (show dom) ++ "\nEND\n" --FIXME
+ Left err -> pdnsReport err
+ Right dom -> pdnsAmend ver id rrtype dom "END\n"
+
+pdnsAmend :: Int -> String -> RRType -> NmcDom -> String -> String
+pdnsAmend ver id rrtype dom accum =
+ "DATA\t" ++ (show dom) ++ "\n" ++ accum --FIXME
forever $ do
l <- getLine
case pdnsParse ver l of
- Left e -> putStrLn $ "FAIL\t" ++ e
+ Left e -> putStr $ pdnsReport e
Right preq -> do
case preq of
PdnsRequestQ qname qtype id _ _ _ ->
- queryNmc mgr cfg qname id >>= putStr . (pdnsOut ver qtype)
+ queryNmc mgr cfg qname id >>= putStr . (pdnsOut ver id qtype)
PdnsRequestAXFR xfrreq ->
- putStrLn ("FAIL\tNo support for AXFR " ++ xfrreq)
+ putStr $ pdnsReport ("No support for AXFR " ++ xfrreq)
PdnsRequestPing -> putStrLn "END"
-- for testing
ask str = do
cfg <- readConfig confFile
mgr <- newManager def
- queryNmc mgr cfg str "test-req-id" >>= putStr . (pdnsOut 1 RRTypeANY)
+ queryNmc mgr cfg str "askid" >>= putStr . (pdnsOut 1 "askid" RRTypeANY)