]> www.average.org Git - pdns-pipe-nmc.git/blobdiff - NmcTransform.hs
wip propagate
[pdns-pipe-nmc.git] / NmcTransform.hs
index 3cd37dfe314e46cbdb09918c12fb5f646bf6ef71..64210eb288f72ec1681cec5757ac7fe8035d8489 100644 (file)
@@ -102,6 +102,30 @@ expandSrv base =
                    && srvPort sr == 25
                 then Just [(show (srvPrio sr)) ++ "\t" ++ (srvHost sr)]
                 else Nothing
+{-
+-- | replace Tls with Tlsa down in the Map
+--   This function is almost, but not quite, entirely unlike expandSrv.
+expandTls :: NmcDom -> NmcDom
+expandTls base =
+  let
+    base' = base { domTls = Nothing }
+  in
+    case domTls base of
+      Nothing -> base'
+      Just sl -> foldr addTlsa base' sl
+        where
+          addTlsa sr acc = sub1 `mergeNmcDom` acc
+            where
+              sub1 = def { domMap = Just (singleton proto sub2) }
+              sub2 = def { domMap = Just (singleton port sub3) }
+              sub3 = def { domTlsa = Just [tlsStr] }
+              proto = "_" ++ (tlsProto sr)
+              port = "_" ++ (tlsName sr)
+              tlsStr =  (show (tlsPrio sr)) ++ "\t"
+                     ++ (show (tlsWeight sr)) ++ " "
+                     ++ (show (tlsPort sr)) ++ " "
+                     ++ (tlsHost sr)
+-}
 
 -- | Convert map elements of the form "subN...sub2.sub1.dom.bit"
 --   into nested map and merge it
@@ -124,6 +148,10 @@ splitSubdoms base =
               nest ([k], v)  = (k, v)
               nest (k:ks, v) =
                 nest (ks, def { domMap = Just (singleton k v) })
+
+-- | transfer some elements of `base` into `sub`, notably TLSA
+propagate :: NmcDom -> NmcDom -> NmcDom
+propagate base sub = sub -- FIXME implement it
  
 -- | Presence of some elements require removal of some others
 normalizeDom :: NmcDom -> NmcDom
@@ -157,7 +185,7 @@ descendNmcDom queryOp subdom base = do
             Just map ->
               case lookup d map of
                 Nothing  -> return $ Right def
-                Just sub -> descendNmcDom queryOp ds sub
+                Just sub -> descendNmcDom queryOp ds $ propagate base'' sub
 
 -- | Initial NmcDom populated with "import" only, suitable for "descend"
 seedNmcDom ::