123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990(*****************************************************************************)(* *)(* 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. *)(* *)(*****************************************************************************)openTezos_rpc_httpopenTezos_rpc_http_servertypet={server:RPC_server.server;host:string;node:Conduit_lwt_unix.server;acl:Resto_acl.Acl.t;}moduleAcl=structopenResto_acl.Aclletallow_all=RPC_server.Acl.allow_allletsecure=Allow_all{except=List.mapparse["GET /global/block/*/durable/wasm_2_0_0/subkeys";"/local/batcher/**";"/admin/**";"/stats/**";"/config";];}letdefault(address:P2p_addr.t)=letopenIpaddrinifV6.scopeaddress=Interfacethenallow_allelsesecureendletstart~rpc_addr~rpc_port~acl~corsdir=letopenLwt_result_syntaxinletrpc_addr=P2p_addr.of_string_exnrpc_addrinlethost=Ipaddr.V6.to_stringrpc_addrinletnode=`TCP(`Portrpc_port)inlet*!acl_policy=RPC_server.Acl.resolve_domain_namesaclinletacl=RPC_server.Acl.find_policyacl_policy(host,Somerpc_port)|>Option.value_f~default:(fun()->Acl.defaultrpc_addr)inletserver=RPC_server.init_serverdir~cors~acl~media_types:Media_type.all_media_typesinprotect@@fun()->let*!()=RPC_server.launch~hostserver~callback:(RPC_server.resto_callbackserver)nodeinreturn{server;host;node;acl}letshutdown{server;_}=RPC_server.shutdownserver