diff options
Diffstat (limited to 'src/vyconfd.ml')
| -rw-r--r-- | src/vyconfd.ml | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/vyconfd.ml b/src/vyconfd.ml index 816ca69..0b92fd1 100644 --- a/src/vyconfd.ml +++ b/src/vyconfd.ml @@ -120,9 +120,10 @@ let exit_conf_mode world token = in Hashtbl.replace sessions token session; response_tmpl -let teardown token = +let teardown world token = try - Hashtbl.remove sessions token; + let () = Hashtbl.remove sessions token in + let () = Session.cleanup_config world token in {response_tmpl with status=Success} with Not_found -> {response_tmpl with status=Fail; error=(Some "Session not found")} @@ -131,6 +132,13 @@ let session_changed world token (_req: request_session_changed) = if Session.session_changed world (find_session token) then response_tmpl else {response_tmpl with status=Fail} +let get_config world token (_req: request_get_config) = + try + let id = + Session.get_config world (find_session token) token + in {response_tmpl with output=(Some id)} + with Session.Session_error msg -> {response_tmpl with status=Fail; error=(Some msg)} + let exists world token (req: request_exists) = if Session.exists world (find_session token) req.path then response_tmpl else {response_tmpl with status=Fail} @@ -296,7 +304,7 @@ let rec handle_connection world ic oc () = | _, Reload_reftree r -> reload_reftree world r | None, _ -> {response_tmpl with status=Fail; output=(Some "Operation requires session token")} | Some t, Session_update_pid r -> session_update_pid world t r - | Some t, Teardown _ -> teardown t + | Some t, Teardown _ -> teardown world t | Some t, Enter_configuration_mode r -> enter_conf_mode r t | Some t, Exit_configuration_mode -> exit_conf_mode world t | Some t, Exists r -> exists world t r @@ -309,6 +317,7 @@ let rec handle_connection world ic oc () = | Some t, Delete r -> delete world t r | Some t, Discard r -> discard world t r | Some t, Session_changed r -> session_changed world t r + | Some t, Get_config r -> get_config world t r | Some t, Load r -> load world t r | Some t, Save r -> save world t r | _ -> failwith "Unimplemented" |
