diff options
author | John Estabrook <jestabro@vyos.io> | 2024-10-23 18:50:46 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2024-10-27 21:47:33 -0500 |
commit | bd17726d30991619eca09bfe478659915bc12fe4 (patch) | |
tree | ea957c5f2b154e4661c88baf50074f17488a9c58 /src/vyconfd.ml | |
parent | 75441a50c50f65f580d6919ed6c4f282fd842e49 (diff) | |
download | vyconf-bd17726d30991619eca09bfe478659915bc12fe4.tar.gz vyconf-bd17726d30991619eca09bfe478659915bc12fe4.zip |
T6718: add independent validate field and methods
Diffstat (limited to 'src/vyconfd.ml')
-rw-r--r-- | src/vyconfd.ml | 8 |
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 |