Skip to content

Instantly share code, notes, and snippets.

@paurkedal
Created June 22, 2017 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paurkedal/d41ec36b053b26f445927d954068cfce to your computer and use it in GitHub Desktop.
Save paurkedal/d41ec36b053b26f445927d954068cfce to your computer and use it in GitHub Desktop.
type 'a io = 'a Lwt.t
type ic = Lwt_io.input_channel
type oc = Lwt_io.output_channel
type tls_lib = [`OpenSSL | `Native]
module X509_key : sig
type t = private {
key: string;
key_password: (bool -> string) option;
cert: string;
}
val create :
key: string ->
?key_password: (bool -> string) ->
cert: string ->
unit -> t
end
module Context : sig
type t
val default : t
val create :
?src: string ->
?local_key: X509_key.t ->
?authenticator: x509_authenticator ->
?preferred_lib: tls_lib list ->
unit -> t
val src : t -> string option
val local_key : t -> X509_key.t option
val authenticator : t -> x509_authenticator
end
module Flow : sig
type tcp = private {
fd: Lwt_unix.file_descr sexp_opaque;
ip: Ipaddr.t;
port: int;
}
type unix_domain = private {
fd: Lwt_unix.file_descr sexp_opaque;
path: string;
}
type vchan = private {
domid: int;
port: string;
}
type t = private
| TCP of tcp
| Unix_domain of unix_domain
| Vchan of vchan
val endp : t -> t -> Conduit.endp
end
module Client : sig
type t
val create_tcp :
?context: Context.t ->
remote_ip: Ipaddr.t ->
remote_port: int ->
unit -> t
val create_tls :
?context: Context.t ->
?local_key: X509_key.t ->
?authenticator: x509_authenticator ->
remote_host: string ->
remote_ip: Ipaddr.t ->
remote_port: int ->
unit -> t
val create_unix_domain :
?context: Context.t ->
file: string ->
unit -> t
val create_vchan :
?context: Context.t ->
domain: [`Id of int | `Name of string] ->
port: string ->
unit -> t
val resolve_endp :
?context: Context.t ->
?local_key: X509_key.t ->
Conduit.endp -> t io
val connect : t -> (flow * ic * oc) io
end
module Server : sig
type t
val create_tcp :
port: int ->
unit -> t
val create_tls :
?context: Context.t ->
?local_key: X509_key.t -> (* Required if missing in context. *)
?local_ip: Ipaddr.t ->
local_port: int ->
unit -> t
val create_unix_domain :
?context: Context.t ->
file: string ->
unit -> t
val create_vchan :
?context: Context.t ->
domain: [`Id of int | `Name of string] ->
port: string ->
unit -> t
val create_launchd :
?context: Context.t ->
name: string ->
unit -> t
val resolve_endp :
?context: Context.t ->
?local_key: X509_key.t ->
Conduit.endp -> t io
val serve :
?context: Context.t ->
?backlog: int ->
?timeout: int ->
?stop: unit io ->
?on_exn: (exn -> unit) ->
?max_active_accept: int ->
t -> (flow -> ic -> oc -> unit io) -> unit io
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment