@@ -141,7 +141,7 @@ type vchan_flow = { domid : int; port : string } [@@deriving sexp]
141
141
142
142
type flow =
143
143
| TCP of tcp_flow
144
- | Tunnel
144
+ | Tunnel of string * ic * oc
145
145
| Domain_socket of domain_flow
146
146
| Vchan of vchan_flow
147
147
[@@ deriving sexp ]
@@ -294,10 +294,10 @@ let connect_with_tls_native ~ctx (`Hostname hostname, `IP ip, `Port port) =
294
294
295
295
let connect_with_tls_tunnel ~ctx (`Hostname hostname , ic , oc ) =
296
296
certificates ~ctx >> = fun certificates ->
297
- let hostname = domain_name hostname in
297
+ let host = domain_name hostname in
298
298
Conduit_lwt_tls.Client. tunnel ?certificates
299
- ~authenticator: ctx.tls_authenticator hostname (ic, oc)
300
- > |= fun (ic , oc ) -> (Tunnel , ic, oc)
299
+ ~authenticator: ctx.tls_authenticator host (ic, oc)
300
+ > |= fun (ic' , oc' ) -> (Tunnel (hostname , ic, oc), ic', oc' )
301
301
302
302
let connect_with_openssl ~ctx (`Hostname host_addr , `IP ip , `Port port ) =
303
303
let sa = Unix. ADDR_INET (Ipaddr_unix. to_inet_addr ip, port) in
@@ -427,15 +427,17 @@ let serve ?backlog ?timeout ?stop ~on_exn ~(ctx : ctx) ~(mode : server) callback
427
427
let fn s = Sockaddr_server. init ~on: (`Socket s) ?timeout ?stop callback in
428
428
Conduit_lwt_launchd. activate fn name
429
429
430
+ type endp = [ Conduit .endp | `TLS_tunnel of string * ic * oc ] [@@ deriving sexp ]
431
+
430
432
let endp_of_flow = function
431
433
| TCP { ip; port; _ } -> `TCP (ip, port)
432
- | Tunnel -> `Unknown " TLS tunnel "
434
+ | Tunnel ( hostname , ic , oc ) -> `TLS_tunnel (hostname, ic, oc)
433
435
| Domain_socket { path; _ } -> `Unix_domain_socket path
434
436
| Vchan { domid; port } -> `Vchan_direct (domid, port)
435
437
436
438
(* * Use the configuration of the server to interpret how to handle a particular
437
439
endpoint from the resolver into a concrete implementation of type [client] *)
438
- let endp_to_client ~ctx :_ (endp : Conduit. endp ) : client Lwt.t =
440
+ let endp_to_client ~ctx :_ (endp : [< endp ] ) : client Lwt.t =
439
441
match endp with
440
442
| `TCP (ip , port ) -> Lwt. return (`TCP (`IP ip, `Port port))
441
443
| `Unix_domain_socket file -> Lwt. return (`Unix_domain_socket (`File file))
@@ -449,6 +451,8 @@ let endp_to_client ~ctx:_ (endp : Conduit.endp) : client Lwt.t =
449
451
Printf. ksprintf failwith
450
452
" TLS to non-TCP currently unsupported: host=%s endp=%s" host
451
453
(Sexplib0.Sexp. to_string_hum (Conduit. sexp_of_endp endp))
454
+ | `TLS_tunnel (host , ic , oc ) ->
455
+ Lwt. return (`TLS_tunnel (`Hostname host, ic, oc))
452
456
| `Unknown err -> failwith (" resolution failed: " ^ err)
453
457
454
458
let endp_to_server ~ctx (endp : Conduit.endp ) =
0 commit comments