X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/fa3b6b8704aeed09045e6e1c89c775ae2332e597..7082219657be97cb63a0abc36d582b349066068a:/src/plugins/bind.sml diff --git a/src/plugins/bind.sml b/src/plugins/bind.sml index 5ba7fed..f08367e 100644 --- a/src/plugins/bind.sml +++ b/src/plugins/bind.sml @@ -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,6 +65,8 @@ 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) = @@ -84,6 +87,12 @@ fun writeRecord (evs, r) = 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 "."; writeDom (); @@ -92,14 +101,16 @@ fun writeRecord (evs, r) = 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; @@ -152,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"} @@ -271,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