3 data RRType = RRTypeSRV | RRTypeA | RRTypeAAAA | RRTypeCNAME
4 | RRTypeDNAME | RRTypeSOA | RRTypeRP | RRTypeLOC
6 | RRTypeANY | RRTypeError String
9 data PdnsRequest = PdnsRequestQ
13 , remoteIpAddress :: String
14 , localIpAddress :: Maybe String
15 , ednsSubnetAddress :: Maybe String
17 | PdnsRequestAXFR String
27 "CNAME" -> RRTypeCNAME
28 "DNAME" -> RRTypeDNAME
37 | ver >= 2 = case xs of
42 | ver >= 3 = case xs of
48 "PING":[] -> Right PdnsRequestPing
49 "AXFR":x:[] -> Right (PdnsRequestAXFR x)
50 "Q":qn:"IN":qt:id:rip:xs -> Right (PdnsRequestQ
54 , remoteIpAddress = rip
55 , localIpAddress = getLIp ver xs
56 , ednsSubnetAddress = getRIp ver xs
61 pdnsOut :: String -> Either String PdnsRequest -> IO ()
62 pdnsOut _ (Left e) = putStrLn ("ERROR\tUnparseable request: " ++ e)
63 pdnsOut uri (Right rq) = case rq of
64 PdnsRequestQ qn qt id lip rip eip -> do
65 dom <- queryNmc uri qn qt id
67 Left e -> putStrLn ("ERROR\tNmc query error: " ++ e)
68 Right result -> print result
69 PdnsRequestAXFR xfrreq ->
70 putStrLn ("ERROR\t No support for AXFR " ++ xfrreq)
71 PdnsRequestPing -> putStrLn "OK"