X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/71420f8bc34bbe2c76bd368613d4e024072e9817..e9f528ab975ac28c16b2c370e69206a48f584d78:/src/plugins/bind.sml diff --git a/src/plugins/bind.sml b/src/plugins/bind.sml index 9c72152..f08367e 100644 --- a/src/plugins/bind.sml +++ b/src/plugins/bind.sml @@ -31,15 +31,15 @@ val () = Slave.registerPreHandler (fn () => (namedChanged := false; zoneChanged := false; didDomain := "")) -val dns : TextIO.outstream option ref = ref NONE +val dns : Domain.files option ref = ref NONE val _ = Domain.registerBefore - (fn _ => dns := Option.map (fn node => Domain.domainFile {node = node, - name = "dns"}) + (fn _ => dns := Option.map (fn node => Domain.domainsFile {node = node, + name = "dns"}) (Domain.dnsMaster ())) val _ = Domain.registerAfter - (fn _ => (Option.app TextIO.closeOut (!dns); + (fn _ => (Option.app (fn files => #close files ()) (!dns); dns := NONE)) val dl = ErrorMsg.dummyLoc @@ -49,6 +49,7 @@ datatype dns_record = | CNAME of string * string | MX of int * string | NS of string + | DefaultA of string val record = fn (EApp ((EApp ((EVar "dnsA", _), e1), _), e2), _) => (case (Env.string e1, Domain.ip e2) of @@ -64,41 +65,52 @@ val record = fn (EApp ((EApp ((EVar "dnsA", _), e1), _), e2), _) => | _ => NONE) | (EApp ((EVar "dnsNS", _), e), _) => Option.map NS (Env.string e) + | (EApp ((EVar "dnsDefaultA", _), e), _) => + Option.map DefaultA (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" - | SOME file => + | SOME files => let - fun write s = TextIO.output (file, s) + fun write s = #write files s + fun writeDom () = #writeDom files () val ttl = Env.env Env.int (evs, "TTL") in case r of A (from, to) => (write from; write "."; - write (Domain.currentDomain ()); + writeDom (); write ".\t"; write (Int.toString ttl); write "\tIN\tA\t"; write to; write "\n") + | DefaultA to => (writeDom (); + write ".\t"; + write (Int.toString ttl); + write "\tIN\tA\t"; + write to; + write "\n") | CNAME (from, to) => (write from; write "."; - write (Domain.currentDomain ()); + writeDom (); write ".\t"; write (Int.toString ttl); write "\tIN\tCNAME\t"; write to; write ".\n") - | MX (num, host) => (write "\t"; + | MX (num, host) => (writeDom (); + write ".\t"; write (Int.toString ttl); write "\tIN\tMX\t"; write (Int.toString num); write "\t"; write host; write ".\n") - | NS host => (write "\t"; + | NS host => (writeDom (); + write ".\t"; write (Int.toString ttl); write "\tIN\tNS\t"; write host; @@ -151,7 +163,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"} @@ -270,4 +282,12 @@ val () = Slave.registerPostHandler val () = Domain.registerResetLocal (fn () => ignore (OS.Process.system (Config.rm ^ " -rf /var/domtool/zones/*"))) +val () = Domain.registerDescriber (Domain.considerAll + [Domain.Filename {filename = "named.conf", + heading = "named.conf addition", + showEmpty = false}, + Domain.Filename {filename = "dns", + heading = "DNS zonefile contents", + showEmpty = false}]) + end