summaryrefslogtreecommitdiff
path: root/src/vyconfd.ml
diff options
context:
space:
mode:
Diffstat (limited to 'src/vyconfd.ml')
-rw-r--r--src/vyconfd.ml8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/vyconfd.ml b/src/vyconfd.ml
index 9117e46..2bb3253 100644
--- a/src/vyconfd.ml
+++ b/src/vyconfd.ml
@@ -136,6 +136,13 @@ let show_config world token (req: request_show_config) =
{response_tmpl with output=(Some conf_str)}
with Session.Session_error msg -> {response_tmpl with status=Fail; error=(Some msg)}
+let validate world token (req: request_validate) =
+ try
+ let () = (Lwt_log.debug @@ Printf.sprintf "[%s]\n" (Vyos1x.Util.string_of_list req.path)) |> Lwt.ignore_result in
+ let () = Session.validate world (find_session token) req.path in
+ response_tmpl
+ with Session.Session_error msg -> {response_tmpl with status=Fail; error=(Some msg)}
+
let send_response oc resp =
let enc = Pbrt.Encoder.create () in
let%lwt () = encode_pb_response resp enc |> return in
@@ -169,6 +176,7 @@ let rec handle_connection world ic oc fd () =
| Some t, Get_values r -> get_values world t r
| Some t, List_children r -> list_children world t r
| Some t, Show_config r -> show_config world t r
+ | Some t, Validate r -> validate world t r
| _ -> failwith "Unimplemented"
end) |> Lwt.return
in