X-Git-Url: http://www.average.org/gitweb/?p=pdns-pipe-nmc.git;a=blobdiff_plain;f=PowerDns.hs;h=9a2a4987443c9d052a40257f005a04dcd1aa8343;hp=d93214f98d33352cfc2702ea8ba9e4e1889c7bb8;hb=0d59aa176c8ca6665f59426a436671099a393d3f;hpb=26b23d266b588ea4b5bc4d53cbf479f9b40d26a0 diff --git a/PowerDns.hs b/PowerDns.hs index d93214f..9a2a498 100644 --- a/PowerDns.hs +++ b/PowerDns.hs @@ -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