123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263(*
* Copyright (c) 2018-2022 Tarides <contact@tarides.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)openIrmin_servermoduleError=ErrormoduleIO=IOmoduleInfo(I:Irmin.Info.S)=structincludeIletinit=vletv?authorfmt=Fmt.kstr(funmessage()->letdate=Int64.of_float(Unix.gettimeofday())ininit?author~messagedate)fmtendletnormalize_uri?hostnameuri=letscheme=Uri.schemeuri|>Option.value~default:"tcp"inletaddr=Uri.host_with_default~default:"127.0.0.1"uriinletscheme_lower=String.lowercase_asciischemeinleturi=ifscheme_lower="tcp"||scheme_lower="ws"||scheme_lower="wss"thenletip=Unix.gethostbynameaddrinletport=Uri.porturi|>Option.value~default:9181inletip=ip.h_addr_list.(0)|>Unix.string_of_inet_addrinUri.make~scheme:scheme_lower~port~host:ip()elseuriin(uri,Option.value~default:addrhostname)letconfig?tls?hostnameuri=leturi,addr=normalize_uri?hostnameuriinIrmin_client.config?tls~hostname:(Option.value~default:addrhostname)urimoduleMake_codec(Codec:Conn.Codec.S)(Store:Irmin.Generic_key.S)=structincludeIrmin_client.Make_codec(IO)(Codec)(Store)letconnect?tls?hostnameuri=leturi,hostname=normalize_uri?hostnameuriinconnect?tls~hostnameuriendmoduleMake(Store:Irmin.Generic_key.S)=Make_codec(Conn.Codec.Bin)(Store)moduleMake_json(Store:Irmin.Generic_key.S)=Make_codec(Conn.Codec.Json)(Store)