]> www.average.org Git - pdns-pipe-nmc.git/blobdiff - PowerDns.hs
move most formatting to PowerDns
[pdns-pipe-nmc.git] / PowerDns.hs
index d93214f98d33352cfc2702ea8ba9e4e1889c7bb8..9a2a4987443c9d052a40257f005a04dcd1aa8343 100644 (file)
@@ -1,6 +1,7 @@
-module PowerDns ( RRType
+module PowerDns ( RRType(..)
                 , PdnsRequest(..)
                 , pdnsParse
+                , pdnsReport
                 , pdnsOut
                 ) where
 
@@ -61,7 +62,18 @@ pdnsParse ver s =
                                             , localIpAddress = getLIp ver xs
                                             , ednsSubnetAddress = getRIp ver xs
                                             })
-      _                         -> Left s
+      _                         -> Left $ "Unparseable PDNS Request: " ++ s
 
-pdnsOut :: NmcDom -> String
-pdnsOut d = show d
+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 -> 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