]> www.average.org Git - pdns-pipe-nmc.git/blobdiff - PowerDns.hs
Scrap the plan to verify valid proto/port
[pdns-pipe-nmc.git] / PowerDns.hs
index 606c5ca09f0e1644715810b4d259e528327e366b..7036596fea1f324def3ae342fbbe63e967e01180 100644 (file)
@@ -58,7 +58,7 @@ data PdnsRequest = PdnsRequestQ
                    , localIpAddress     :: Maybe String
                    , ednsSubnetAddress  :: Maybe String
                    }
-                 | PdnsRequestAXFR Int
+                 | PdnsRequestAXFR Int (Maybe String)
                  | PdnsRequestPing
         deriving (Show)
 
@@ -82,7 +82,15 @@ pdnsParse ver s =
   in
     case words s of
       "PING":[]                 -> Right PdnsRequestPing
-      "AXFR":x:[]               -> Right (PdnsRequestAXFR (getInt x))
+      "AXFR":x:xs               ->
+        if ver < 4 then
+          case xs of
+            [] -> Right $ (PdnsRequestAXFR (getInt x)) Nothing
+            _  -> Left  $ "Extra arguments in AXFR (v 1-3): " ++ s
+        else
+          case xs of
+            [z] -> Right $ (PdnsRequestAXFR (getInt x)) (Just z)
+            _   -> Left  $ "Wrong arguments in AXFR (v 4+): " ++ s
       "Q":qn:"IN":qt:id:rip:xs  -> case rrType qt of
                                      RRTypeError e ->
                                        Left $ "Unrecognized RR type: " ++ e
@@ -108,7 +116,7 @@ pdnsOutQ ver id gen name rrt edom =
     rrl = case rrt of
       RRTypeANY -> [ RRTypeSRV, RRTypeA, RRTypeAAAA, RRTypeCNAME
                    , RRTypeDNAME, RRTypeRP, RRTypeLOC, RRTypeNS
-                   , RRTypeDS, RRTypeMX -- SOA not included
+                   , RRTypeDS, RRTypeMX, RRTypeTLSA -- SOA not included
                    ]
       x         -> [x]
   in
@@ -124,7 +132,7 @@ pdnsOutXfr ver id gen name edom =
   let
     allrrs = [ RRTypeSRV, RRTypeA, RRTypeAAAA, RRTypeCNAME
              , RRTypeDNAME, RRTypeRP, RRTypeLOC, RRTypeNS
-             , RRTypeDS, RRTypeMX, RRTypeSOA
+             , RRTypeDS, RRTypeMX, RRTypeTLSA, RRTypeSOA
              ]
     walkDom f acc name dom =
       f name dom $ case domSubmap dom of
@@ -146,9 +154,7 @@ formatRR ver id gen name dom rrtype =
               ++ "\t" ++ ttl ++ "\t" ++ (show id) ++ "\t" ++ x ++ "\n" ++ a)
         "" $ dataRR rrtype gen name dom
     where
-      v3ext = case ver of
-        3 -> "0\t1\t"
-        _ -> ""
+      v3ext = if ver >= 3 then "0\t1\t" else ""
       ttl = show 3600
 
 justl accessor _ _ dom = case accessor dom of