This commit is contained in:
Hannes Mehnert 2019-05-27 23:42:15 +02:00
parent 648ff6df6d
commit c906f2c5d3
2 changed files with 10 additions and 2 deletions

View file

@ -204,7 +204,7 @@ jfuLKkCfGcw9A8o=
|} in
X509.Encoding.Pem.Certificate.of_pem_cstruct1 data
let create s ?(port = 8093) ?hostname ?(interval = 10) certificates =
let create_tls ?(port = 8093) ?hostname ?(interval = 10) s certificates =
Metrics.enable_all ();
let flows = I.create ~interval ?hostname () in
Lwt.async (L.collect (fun () -> T.sleep_ns (Duration.of_sec interval)));
@ -217,6 +217,13 @@ jfuLKkCfGcw9A8o=
TLS.server_of_flow server flow >|= function
| Ok tls -> I.add_flow flows tls
| Error e -> Log.err (fun m -> m "TLS error %a" TLS.pp_write_error e))
module TC = Pull(T)(C)(S.TCPV4)
let create_tcp ?(port = 8093) ?hostname ?(interval = 10) s =
Metrics.enable_all ();
let flows = TC.create ~interval ?hostname () in
Lwt.async (L.collect (fun () -> T.sleep_ns (Duration.of_sec interval)));
S.listen_tcpv4 s ~port (fun flow -> Lwt.return (TC.add_flow flows flow))
end
end

View file

@ -38,6 +38,7 @@ module M : sig
end
module S (T : Mirage_time_lwt.S) (P : Mirage_clock.PCLOCK) (C : Mirage_clock.MCLOCK) (S : Mirage_stack_lwt.V4) : sig
val create : S.t -> ?port:int -> ?hostname:string -> ?interval:int -> Tls.Config.own_cert -> unit
val create_tls : ?port:int -> ?hostname:string -> ?interval:int -> S.t -> Tls.Config.own_cert -> unit
val create_tcp : ?port:int -> ?hostname:string -> ?interval:int -> S.t -> unit
end
end