Revision faf83b3a79b050cb8eecf865a9377c34ebd1cf47 authored by Marge Bot on 02 February 2024, 16:08:48 UTC, committed by Marge Bot on 02 February 2024, 16:08:48 UTC
Co-authored-by: Killian Delarue <killian.delarue@nomadic-labs.com> Approved-by: Arvid Jakobsson <arvid.jakobsson@nomadic-labs.com> Approved-by: Nic Volanschi <nic.volanschi@nomadic-labs.com> See merge request https://gitlab.com/tezos/tezos/-/merge_requests/11768
rpc_server.ml
(*****************************************************************************)
(* *)
(* Open Source License *)
(* Copyright (c) 2022 Nomadic Labs, <contact@nomadic-labs.com> *)
(* Copyright (c) 2022-2023 TriliTech <contact@trili.tech> *)
(* Copyright (c) 2023 Functori, <contact@functori.com> *)
(* *)
(* Permission is hereby granted, free of charge, to any person obtaining a *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)
(* and/or sell copies of the Software, and to permit persons to whom the *)
(* Software is furnished to do so, subject to the following conditions: *)
(* *)
(* The above copyright notice and this permission notice shall be included *)
(* in all copies or substantial portions of the Software. *)
(* *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)
(* DEALINGS IN THE SOFTWARE. *)
(* *)
(*****************************************************************************)
open Tezos_rpc_http
open Tezos_rpc_http_server
type t = {
server : RPC_server.server;
host : string;
node : Conduit_lwt_unix.server;
acl : Resto_acl.Acl.t;
}
let start configuration dir =
let open Lwt_result_syntax in
let Configuration.{rpc_addr; rpc_port; _} = configuration in
let rpc_addr = P2p_addr.of_string_exn rpc_addr in
let host = Ipaddr.V6.to_string rpc_addr in
let node = `TCP (`Port rpc_port) in
(* TODO: https://gitlab.com/tezos/tezos/-/issues/2885
More restrictive access control. *)
let acl = RPC_server.Acl.allow_all in
let server =
RPC_server.init_server
dir
~cors:configuration.cors
~acl
~media_types:Media_type.all_media_types
in
protect @@ fun () ->
let*! () =
RPC_server.launch
~host
server
~callback:(RPC_server.resto_callback server)
node
in
return {server; host; node; acl}
let shutdown {server; _} = RPC_server.shutdown server
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...