Successfully indented all of standard lib with domtool-mode
[hcoop/domtool2.git] / src / plugins / bind.sml
index 46ecbc3..89b3938 100644 (file)
@@ -50,6 +50,8 @@ datatype dns_record =
        | MX of int * string
        | NS of string
        | DefaultA of string
+       | AAAA of string * string
+       | DefaultAAAA of string
 
 val record = fn (EApp ((EApp ((EVar "dnsA", _), e1), _), e2), _) =>
                (case (Env.string e1, Domain.ip e2) of
@@ -66,12 +68,19 @@ val record = fn (EApp ((EApp ((EVar "dnsA", _), e1), _), e2), _) =>
              | (EApp ((EVar "dnsNS", _), e), _) =>
                Option.map NS (Env.string e)
              | (EApp ((EVar "dnsDefaultA", _), e), _) =>
-               Option.map DefaultA (Env.string e)
+               Option.map DefaultA (Domain.ip e)
+             | (EApp ((EApp ((EVar "dnsAAAA", _), e1), _), e2), _) =>
+               (case (Env.string e1, Env.string e2) of
+                    (SOME v1, SOME v2) => SOME (AAAA (v1, v2))
+                  | _ => NONE)
+             | (EApp ((EVar "dnsDefaultAAAA", _), e), _) =>
+               Option.map DefaultAAAA (Env.string e)
              | _ => NONE
 
 fun writeRecord (evs, r) =
     case !dns of
-       NONE => print "Warning: DNS directive ignored because no master DNS server is configured for this domain\n"
+       NONE => print ("Warning: DNS directive for " ^ Domain.currentDomain ()
+                      ^ " ignored because no master DNS server is configured for this domain\n")
       | SOME files =>
        let
            fun write s = #write files s
@@ -115,6 +124,20 @@ fun writeRecord (evs, r) =
                            write "\tIN\tNS\t";
                            write host;
                            write ".\n")
+             | AAAA (from, to) => (write from;
+                                   write ".";
+                                   writeDom ();
+                                   write ".\t";
+                                   write (Int.toString ttl);
+                                   write "\tIN\tAAAA\t";
+                                   write to;
+                                   write "\n")
+             | DefaultAAAA to => (writeDom ();
+                                  write ".\t";
+                                  write (Int.toString ttl);
+                                  write "\tIN\tAAAA\t";
+                                  write to;
+                                  write "\n")
        end
 
 val () = Env.actionV_one "dns"
@@ -163,7 +186,7 @@ val () = Slave.registerFileHandler (fn fs =>
                                           fun dnsChanged () =
                                               if #domain fs = !didDomain then
                                                   ()
-                                              else if #action fs = Slave.Delete then
+                                              else if Slave.isDelete (#action fs) then
                                                   let
                                                       val fname = OS.Path.joinBaseExt {base = #domain fs,
                                                                                        ext = SOME "zone"}
@@ -284,10 +307,10 @@ val () = Domain.registerResetLocal (fn () =>
 
 val () = Domain.registerDescriber (Domain.considerAll
                                   [Domain.Filename {filename = "named.conf",
-                                                    heading = "named.conf addition",
+                                                    heading = "named.conf addition:",
                                                     showEmpty = false},
                                    Domain.Filename {filename = "dns",
-                                                    heading = "DNS zonefile contents",
+                                                    heading = "DNS zonefile contents:",
                                                     showEmpty = false}])
 
 end