ip_of_node support
authorAdam Chlipala <adamc@hcoop.net>
Sat, 9 Dec 2006 22:13:04 +0000 (22:13 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Sat, 9 Dec 2006 22:13:04 +0000 (22:13 +0000)
configDefault/domtool.cfg
configDefault/domtool.cfs
configDefault/webalizer.cfg
src/domain.sig
src/domain.sml
src/main.sml
src/plugins/apache.sml
src/plugins/bind.sml

index d83c398..c474ce5 100644 (file)
@@ -38,3 +38,5 @@ val certDir = "/afs/hcoop.net/common/etc/domtool/certs"
 val keyDir = "/afs/hcoop.net/common/etc/domtool/keys"
 
 val dispatcherName = "deleuze.hcoop.net"
+
+val homeBase = "/afs/hcoop.net/usr"
index 7ffc30d..f1f84af 100644 (file)
@@ -47,3 +47,5 @@ val certDir : string
 val keyDir : string
 
 val dispatcherName : string
+
+val homeBase : string
index 00ea5ba..cf087ea 100644 (file)
@@ -1,6 +1,6 @@
 structure Webalizer :> WEBALIZER_CONFIG = struct
 
 val configDir = "/etc/webalizer"
-val outputDir = "/tmp/webalizer"
+val outputDir = "/afs/hcoop.net/common/etc/domtool/webalizer"
 
 end
index 7ea6689..b85bbf7 100644 (file)
@@ -24,6 +24,8 @@ signature DOMAIN = sig
     val validHost : string -> bool
     val validDomain : string -> bool
 
+    val ip : string Env.arg
+
     val registerBefore : (string -> unit) -> unit
     val registerAfter : (string -> unit) -> unit
     (* Register handlers to run just before and after entering a domain
index e1099b4..15903a2 100644 (file)
@@ -221,8 +221,11 @@ datatype master =
         ExternalMaster of string
        | InternalMaster of string
 
-val master = fn (EApp ((EVar "externalMaster", _), e), _) => Option.map ExternalMaster (Env.string e)
-             | (EApp ((EVar "internalMaster", _), e), _) => Option.map InternalMaster (Env.string e)
+val ip = fn (EApp ((EVar "ip_of_node", _), e), _) => Option.map nodeIp (Env.string e)
+         | e => Env.string e
+
+val master = fn (EApp ((EVar "externalMaster", _), e), _) => Option.map ExternalMaster (ip e)
+             | (EApp ((EVar "internalMaster", _), e), _) => Option.map InternalMaster (ip e)
              | _ => NONE
 
 datatype dnsKind =
index 19162a3..490f66d 100644 (file)
@@ -212,21 +212,21 @@ fun service () =
                                    TextIO.closeOut outf;
                                    (eval outname;
                                     Msg.send (bio, MsgOk))
-                                    handle ErrorMsg.Error =>
-                                           (print "Compilation error\n";
-                                            Msg.send (bio,
-                                                      MsgError "Error during configuration evaluation"))
-                                         | OpenSSL.OpenSSL s =>
-                                           (print "OpenSSL error\n";
-                                            Msg.send (bio,
-                                                      MsgError
-                                                          ("Error during configuration evaluation: "
-                                                           ^ s)));
-                                   OS.FileSys.remove outname;
-                                   (ignore (OpenSSL.readChar bio);
-                                    OpenSSL.close bio)
-                                   handle OpenSSL.OpenSSL _ => ();
-                                   loop ()
+                                   handle ErrorMsg.Error =>
+                                          (print "Compilation error\n";
+                                           Msg.send (bio,
+                                                     MsgError "Error during configuration evaluation"))
+                                        | OpenSSL.OpenSSL s =>
+                                          (print "OpenSSL error\n";
+                                           Msg.send (bio,
+                                                     MsgError
+                                                         ("Error during configuration evaluation: "
+                                                          ^ s)));
+                                          OS.FileSys.remove outname;
+                                          (ignore (OpenSSL.readChar bio);
+                                           OpenSSL.close bio)
+                                          handle OpenSSL.OpenSSL _ => ();
+                                          loop ()
                                end
                              | _ =>
                                (Msg.send (bio, MsgError "Unexpected command")
@@ -237,6 +237,16 @@ fun service () =
                in
                    cmdLoop ()
                end
+                   handle OpenSSL.OpenSSL s =>
+                          (print ("OpenSSL error: " ^ s ^ "\n");
+                           OpenSSL.close bio
+                           handle OpenSSL.OpenSSL _ => ();
+                           loop ())
+                        | OS.SysErr (s, _) =>
+                          (print ("System error: " ^ s ^ "\n");
+                           OpenSSL.close bio
+                           handle OpenSSL.OpenSSL _ => ();
+                           loop ())
     in
        print "Listening for connections....\n";
        loop ();
index 13062a2..ffd18b2 100644 (file)
@@ -79,7 +79,7 @@ val _ = Defaults.registerDefault ("Group",
 
 val _ = Defaults.registerDefault ("DocumentRoot",
                                  (TBase "your_path", dl),
-                                 (fn () => (EString ("/home/" ^ Domain.getUser () ^ "/public_html"), dl)))
+                                 (fn () => (EString (Config.homeBase ^ "/" ^ Domain.getUser () ^ "/public_html"), dl)))
 
 val _ = Defaults.registerDefault ("ServerAdmin",
                                  (TBase "email", dl),
index faa8e4e..8dc1a72 100644 (file)
@@ -51,7 +51,7 @@ datatype dns_record =
        | NS of string
 
 val record = fn (EApp ((EApp ((EVar "dnsA", _), e1), _), e2), _) =>
-               (case (Env.string e1, Env.string e2) of
+               (case (Env.string e1, Domain.ip e2) of
                     (SOME v1, SOME v2) => SOME (A (v1, v2))
                   | _ => NONE)
              | (EApp ((EApp ((EVar "dnsCNAME", _), e1), _), e2), _) =>