Limited DNS nodes
[hcoop/domtool2.git] / src / domain.sml
index f2579dd..e09f399 100644 (file)
@@ -153,6 +153,9 @@ val _ = Env.type_one "node"
        Env.string
        validNode
 
+val _ = Env.registerFunction ("web_node_to_node",
+                             fn [e] => SOME e
+                              | _ => NONE)
 open Ast
 
 val dl = ErrorMsg.dummyLoc
@@ -223,8 +226,11 @@ datatype master =
         ExternalMaster of string
        | InternalMaster of string
 
-val ip = fn (EApp ((EVar "ip_of_node", _), e), _) => Option.map nodeIp (Env.string e)
-         | e => Env.string e
+val ip = Env.string
+
+val _ = Env.registerFunction ("ip_of_node",
+                             fn [(EString node, _)] => SOME (EString (nodeIp node), dl)
+                              | _ => NONE)
 
 val master = fn (EApp ((EVar "externalMaster", _), e), _) => Option.map ExternalMaster (ip e)
              | (EApp ((EVar "internalMaster", _), e), _) => Option.map InternalMaster (Env.string e)
@@ -487,7 +493,7 @@ val _ = Env.containerV_one "domain"
                                               "master" => TextIO.output (outf, "\tallow-update { none; };\n")
                                             | _ => (TextIO.output (outf, "\tmasters { ");
                                                     TextIO.output (outf, masterIp);
-                                                    TextIO.output (outf, " };\n"));
+                                                    TextIO.output (outf, "; };\n"));
                                           TextIO.output (outf, "};\n");
                                           TextIO.closeOut outf
                                       end
@@ -604,4 +610,14 @@ val () = Env.registerPost (fn () =>
                                                     fn cl => "Temp file cleanup failed: " ^ cl))
                              end)
 
+fun hasPriv priv = Acl.query {user = getUser (), class = "priv", value = "all"}
+                  orelse Acl.query {user = getUser (), class = "priv", value = priv}
+
+val _ = Env.type_one "dns_node"
+       Env.string
+       (fn node =>
+           List.exists (fn x => x = node) Config.dnsNodes_all
+           orelse (hasPriv "dns"
+                   andalso List.exists (fn x => x = node) Config.dnsNodes_admin))
+
 end