X-Git-Url: http://www.average.org/gitweb/?p=pdns-pipe-nmc.git;a=blobdiff_plain;f=pdns-pipe-nmc.hs;h=a933c9ca70ade2f57d3c3a46b91b80923bf41d90;hp=f61d7baecf5ae61faa20d39adeb62a0e208e7699;hb=26b23d266b588ea4b5bc4d53cbf479f9b40d26a0;hpb=e8fbbca8429c42f84bab9e1ab14bb1ff52c5e4cd diff --git a/pdns-pipe-nmc.hs b/pdns-pipe-nmc.hs index f61d7ba..a933c9c 100644 --- a/pdns-pipe-nmc.hs +++ b/pdns-pipe-nmc.hs @@ -83,18 +83,17 @@ main = do putStrLn $ "OK\tDnsNmc ready to serve, protocol v." ++ (show ver) mgr <- newManager def - - print $ qReq cfg "d/nosuchdomain" "query-nmc" - rsp <- runResourceT $ httpLbs (qReq cfg "d/nosuchdomain" "query-nmc") mgr - print $ (statusCode . responseStatus) rsp - putStrLn "===== complete response is:" - print rsp - let rbody = responseBody rsp - putStrLn "===== response body is:" - print rbody - let result = parseJsonRpc rbody :: Either JsonRpcError NmcRes - putStrLn "===== parsed response is:" - print result --- print $ parseJsonRpc (responseBody rsp) - - --forever $ getLine >>= (pdnsOut uri) . (pdnsParse ver) + forever $ do + l <- getLine + case pdnsParse ver l of + Left e -> putStrLn $ "ERROR\t" ++ e + Right preq -> do + case preq of + PdnsRequestQ qn qt id lip rip eip -> do + ncres <- queryNmc mgr cfg (qName preq) (qType preq) (iD preq) + case ncres of + Left e -> putStrLn $ "ERROR\t" ++ e + Right dom -> putStrLn $ pdnsOut dom + PdnsRequestAXFR xfrreq -> + putStrLn ("ERROR\t No support for AXFR " ++ xfrreq) + PdnsRequestPing -> putStrLn "OK"