1 module PowerDns ( RRType(..)
10 data RRType = RRTypeSRV | RRTypeA | RRTypeAAAA | RRTypeCNAME
11 | RRTypeDNAME | RRTypeSOA | RRTypeRP | RRTypeLOC
13 | RRTypeANY | RRTypeError String
16 data PdnsRequest = PdnsRequestQ
20 , remoteIpAddress :: String
21 , localIpAddress :: Maybe String
22 , ednsSubnetAddress :: Maybe String
24 | PdnsRequestAXFR String
34 "CNAME" -> RRTypeCNAME
35 "DNAME" -> RRTypeDNAME
44 | ver >= 2 = case xs of
49 | ver >= 3 = case xs of
55 "PING":[] -> Right PdnsRequestPing
56 "AXFR":x:[] -> Right (PdnsRequestAXFR x)
57 "Q":qn:"IN":qt:id:rip:xs -> Right (PdnsRequestQ
61 , remoteIpAddress = rip
62 , localIpAddress = getLIp ver xs
63 , ednsSubnetAddress = getRIp ver xs
65 _ -> Left $ "Unparseable PDNS Request: " ++ s
67 pdnsReport :: String -> String
69 "LOG\tError: " ++ err ++ "\nFAIL\n"
71 pdnsOut :: Int -> String -> RRType -> Either String NmcDom -> String
72 pdnsOut ver id rrtype edom =
74 Left err -> pdnsReport err
75 Right dom -> pdnsAmend ver id rrtype dom "END\n"
77 pdnsAmend :: Int -> String -> RRType -> NmcDom -> String -> String
78 pdnsAmend ver id rrtype dom accum =
79 "DATA\t" ++ (show dom) ++ "\n" ++ accum --FIXME