fun requestApt {node, pkg} =
let
- val (_, bio) = requestBio (fn () => ())
+ val (user, context) = requestContext (fn () => ())
+ val bio = OpenSSL.connect (context, if node = Config.masterNode then
+ dispatcher
+ else
+ Domain.nodeIp node ^ ":" ^ Int.toString Config.slavePort)
- val _ = Msg.send (bio, MsgApt pkg)
+ val _ = Msg.send (bio, MsgQuery (QApt pkg))
fun loop () =
case Msg.recv bio of
fun now () = Date.toString (Date.fromTimeUniv (Time.now ()))
+fun answerQuery q =
+ case q of
+ QApt pkg => if Apt.installed pkg then MsgYes else MsgNo
+
+fun describeQuery q =
+ case q of
+ QApt pkg => "Requested installation status of package " ^ pkg
+
fun service () =
let
val () = Acl.read Config.aclFile
NONE)))
(fn () => ())
- | MsgApt pkg =>
- doIt (fn () => (Msg.send (bio, if Apt.installed pkg then
- MsgYes
- else
- MsgNo);
- ("User requested installation status of package " ^ pkg,
+ | MsgQuery q =>
+ doIt (fn () => (Msg.send (bio, answerQuery q);
+ (describeQuery q,
NONE)))
(fn () => ())
| _ => (OpenSSL.close bio;
loop ())
else
- (print "Not authorized!\n";
- OpenSSL.close bio;
- loop ())
+ case Msg.recv bio of
+ SOME (MsgQuery q) => (print (describeQuery q ^ "\n");
+ Msg.send (bio, answerQuery q);
+ ignore (OpenSSL.readChar bio);
+ OpenSSL.close bio;
+ loop ())
+ | _ => (OpenSSL.close bio;
+ loop ())
end handle OpenSSL.OpenSSL s =>
(print ("OpenSSL error: "^ s ^ "\n");
OpenSSL.close bio