This commit is contained in:
swrup 2025-11-04 18:45:30 +01:00
parent 09a76fa8c1
commit 00f66c36ac

View file

@ -229,7 +229,6 @@ struct
} }
let run_with_tls ~ctx ~authenticator ~tls http_server tls_port tcpv4v6 = let run_with_tls ~ctx ~authenticator ~tls http_server tls_port tcpv4v6 =
let open Lwt.Infix in
let alpn_service = let alpn_service =
HTTP_server.alpn_service ~tls (alpn_handler ~ctx ~authenticator) HTTP_server.alpn_service ~tls (alpn_handler ~ctx ~authenticator)
in in
@ -237,10 +236,12 @@ struct
HTTP_server.http_service ~error_handler:Server.http_1_1_error_handler HTTP_server.http_service ~error_handler:Server.http_1_1_error_handler
(http_1_1_request_handler ~ctx ~authenticator) (http_1_1_request_handler ~ctx ~authenticator)
in in
HTTP_server.init ~port:tls_port tcpv4v6 >|= Paf.serve alpn_service let open Lwt.Syntax in
>>= fun (`Initialized th0) -> let* server = HTTP_server.init ~port:tls_port tcpv4v6 in
Paf.serve http_1_1_service http_server |> fun (`Initialized th1) -> let (`Initialized th0) = Paf.serve alpn_service server in
Lwt.both th0 th1 >>= fun ((), ()) -> Lwt.return_unit let (`Initialized th1) = Paf.serve http_1_1_service http_server in
let+ (), () = Lwt.both th0 th1 in
()
let run ~ctx ~authenticator http_server = let run ~ctx ~authenticator http_server =
let http_1_1_service = let http_1_1_service =
@ -250,23 +251,24 @@ struct
Paf.serve http_1_1_service http_server |> fun (`Initialized th) -> th Paf.serve http_1_1_service http_server |> fun (`Initialized th) -> th
let start assets_ro certificate_ro key_ro tcpv4v6 ctx http_server = let start assets_ro certificate_ro key_ro tcpv4v6 ctx http_server =
let open Lwt.Infix in let open Lwt.Syntax in
let authenticator = Connect.authenticator in let authenticator = Connect.authenticator in
Assets.assets assets_ro >>= fun res -> let* assets_res = Assets.assets assets_ro in
match res with match assets_res with
| Error (`Msg m) -> Fmt.failwith "Assets configuration error: %s." m | Error (`Msg m) -> Fmt.failwith "Assets configuration error: %s." m
| Ok (terms, _privacy) -> ( | Ok (_terms, _privacy) -> (
(*
let etag, lang_l, ext_l = terms in let etag, lang_l, ext_l = terms in
Fmt.pr "ETAG: %s@\nlanguages: %a@\nextensions: %a@." etag Fmt.pr "ETAG: %s@\nlanguages: %a@\nextensions: %a@." etag
(Fmt.list ~sep:(Fmt.any ", ") Fmt.string) (Fmt.list ~sep:(Fmt.any ", ") Fmt.string)
lang_l lang_l
(Fmt.list ~sep:(Fmt.any ", ") Fmt.string) (Fmt.list ~sep:(Fmt.any ", ") Fmt.string)
ext_l; ext_l; *)
tls certificate_ro key_ro >>= fun tls -> let* tls_res = tls certificate_ro key_ro in
match use_tls () with match use_tls () with
| false -> run ~ctx ~authenticator http_server | false -> run ~ctx ~authenticator http_server
| true -> ( | true -> (
match tls with match tls_res with
| Error (`Msg m) -> | Error (`Msg m) ->
Fmt.failwith Fmt.failwith
"A TLS server requires, at least, one certificate and one \ "A TLS server requires, at least, one certificate and one \