X-Git-Url: http://www.average.org/gitweb/?p=pdns-pipe-nmc.git;a=blobdiff_plain;f=pdns-pipe-nmc.hs;h=9e4a72930691ab6b58e53e6220c4d6c495c5e4ce;hp=a933c9ca70ade2f57d3c3a46b91b80923bf41d90;hb=b90215dda1c086c7c288ac9d7e3d75e0516f0fd5;hpb=26b23d266b588ea4b5bc4d53cbf479f9b40d26a0 diff --git a/pdns-pipe-nmc.hs b/pdns-pipe-nmc.hs index a933c9c..9e4a729 100644 --- a/pdns-pipe-nmc.hs +++ b/pdns-pipe-nmc.hs @@ -43,15 +43,18 @@ qRsp rsp = case parseJsonRpc (responseBody rsp) :: Either JsonRpcError NmcRes of Left jerr -> Left $ "Unparseable response: " ++ (show (responseBody rsp)) Right jrsp -> - case decode (resValue jrsp) :: Maybe NmcDom of - Nothing -> Left $ "Unparseable value: " ++ (show (resValue jrsp)) - Just dom -> Right dom + case resValue jrsp of + "" -> Right emptyNmcDom + vstr -> + case decode vstr :: Maybe NmcDom of + Nothing -> Left $ "Unparseable value: " ++ (show vstr) + Just dom -> Right dom -- NMC interface -queryNmc :: Manager -> Config -> String -> RRType -> String +queryNmc :: Manager -> Config -> String -> String -> IO (Either String NmcDom) -queryNmc mgr cfg fqdn qtype qid = do +queryNmc mgr cfg fqdn qid = do case reverse (splitOn "." fqdn) of "bit":dn:xs -> do rsp <- runResourceT $ @@ -89,11 +92,11 @@ main = do 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) + PdnsRequestQ qname qtype id _ _ _ -> do + ncres <- queryNmc mgr cfg qname id case ncres of Left e -> putStrLn $ "ERROR\t" ++ e - Right dom -> putStrLn $ pdnsOut dom + Right dom -> putStrLn $ pdnsOut qtype dom PdnsRequestAXFR xfrreq -> - putStrLn ("ERROR\t No support for AXFR " ++ xfrreq) + putStrLn ("ERROR\tNo support for AXFR " ++ xfrreq) PdnsRequestPing -> putStrLn "OK"