]> www.average.org Git - pdns-pipe-nmc.git/blobdiff - pdns-pipe-nmc.hs
test function to interactively ask about a domain
[pdns-pipe-nmc.git] / pdns-pipe-nmc.hs
index ee5bd3771a900dd880f2add5c7dcacff6a100ae9..e9b29690aa0a866f2e57749dc41efa14fe304d4f 100644 (file)
@@ -43,9 +43,12 @@ 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
 
@@ -97,3 +100,13 @@ main = do
           PdnsRequestAXFR xfrreq ->
             putStrLn ("ERROR\tNo support for AXFR " ++ xfrreq)
           PdnsRequestPing -> putStrLn "OK"
+
+-- for testing
+
+ask str = do
+  cfg <- readConfig confFile
+  mgr <- newManager def
+  ncres <- queryNmc mgr cfg str "test-req-id"
+  case ncres of
+    Left  e   -> putStrLn $ "ERROR\t" ++ e
+    Right dom -> putStrLn $ pdnsOut RRTypeANY dom