HCoop
/
hcoop
/
domtool2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Full records for IN and MX
[hcoop/domtool2.git]
/
src
/
plugins
/
bind.sml
diff --git
a/src/plugins/bind.sml
b/src/plugins/bind.sml
index
9a05dce
..
5f37520
100644
(file)
--- a/
src/plugins/bind.sml
+++ b/
src/plugins/bind.sml
@@
-31,15
+31,15
@@
val () = Slave.registerPreHandler (fn () => (namedChanged := false;
zoneChanged := false;
didDomain := ""))
zoneChanged := false;
didDomain := ""))
-val dns :
TextIO.outstream
option ref = ref NONE
+val dns :
Domain.files
option ref = ref NONE
val _ = Domain.registerBefore
val _ = Domain.registerBefore
- (fn _ => dns := Option.map (fn node => Domain.domainFile {node = node,
- name = "dns"})
+ (fn _ => dns := Option.map (fn node => Domain.domain
s
File {node = node,
+
name = "dns"})
(Domain.dnsMaster ()))
val _ = Domain.registerAfter
(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
dns := NONE))
val dl = ErrorMsg.dummyLoc
@@
-49,6
+49,7
@@
datatype dns_record =
| CNAME of string * string
| MX of int * string
| NS of string
| 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
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)
| _ => 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"
| _ => 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 file
s
=>
let
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 ".";
val ttl = Env.env Env.int (evs, "TTL")
in
case r of
A (from, to) => (write from;
write ".";
- write
(Domain.currentDomain ()
);
+ write
Dom (
);
write ".\t";
write (Int.toString ttl);
write "\tIN\tA\t";
write to;
write "\n")
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 ".";
| CNAME (from, to) => (write from;
write ".";
- write
(Domain.currentDomain ()
);
+ write
Dom (
);
write ".\t";
write (Int.toString ttl);
write "\tIN\tCNAME\t";
write to;
write ".\n")
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")
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;
write (Int.toString ttl);
write "\tIN\tNS\t";
write host;
@@
-131,7
+143,7
@@
val monthToInt = fn Date.Jan => 1
fun padBy ch amt s =
if size s < amt then
fun padBy ch amt s =
if size s < amt then
- CharVector.tabulate (amt, fn _ => ch) ^ s
+ CharVector.tabulate (amt
- size s
, fn _ => ch) ^ s
else
s
else
s
@@
-177,13
+189,15
@@
val () = Slave.registerFileHandler (fn fs =>
val min = readILine inf
val () = TextIO.closeIn inf
val min = readILine inf
val () = TextIO.closeIn inf
+ val serialPath = OS.Path.joinDirFile {dir = Config.serialDir,
+ file = #domain fs}
+
val oldSerial = let
val oldSerial = let
- val inf = TextIO.openIn (OS.Path.joinDirFile {dir = #dir fs,
- file = "serial"})
+ val inf = TextIO.openIn serialPath
in
SOME (readLine inf)
before TextIO.closeIn inf
in
SOME (readLine inf)
before TextIO.closeIn inf
- end handle IO.Io
_
=> NONE
+ end handle IO.Io
{name, ...}
=> NONE
val newSerial =
case serial of
val newSerial =
case serial of
@@
-205,8
+219,7
@@
val () = Slave.registerFileHandler (fn fs =>
"00")
end
"00")
end
- val outf = TextIO.openOut (OS.Path.joinDirFile {dir = #dir fs,
- file = "serial"})
+ val outf = TextIO.openOut serialPath
val _ = TextIO.output (outf, newSerial)
val _ = TextIO.closeOut outf
val _ = TextIO.output (outf, newSerial)
val _ = TextIO.closeOut outf
@@
-265,4
+278,8
@@
val () = Slave.registerPostHandler
fn cl => "Error reloading bind with " ^ cl)
else
()))
fn cl => "Error reloading bind with " ^ cl)
else
()))
+
+val () = Domain.registerResetLocal (fn () =>
+ ignore (OS.Process.system (Config.rm ^ " -rf /var/domtool/zones/*")))
+
end
end