Skip to main content

bind

Function bind 

Source
pub async fn bind(repo: Repo, opts: ServeOptions) -> Result<Server>
Expand description

Binds the listeners of opts and returns a server over repo.

The function checks the options and builds the TLS configuration of opts. Then it binds each listen address of opts, in order. The server serves the archive view of repo. With ServeOptions::receive, it also serves the receive endpoint over repo.

ยงErrors

The checks run in this order:

  • Error::Options if listen is empty, or if body_timeout is zero.
  • Error::Options if trusted_proxy_client_cert is not a header name (ostrya::access::is_header_name).
  • Error::Options if trusted_proxy_client_cert is set and client_ca_pem is None, or trusted_proxies is empty.
  • Error::Options if trusted_proxies is not empty and trusted_proxy_header is None, or the reverse.
  • Error::Options if client_ca_pem is set, and tls and trusted_proxy_client_cert are None.
  • Error::Options if a client group of receive carries a tls:*, tls:NAME, or tls-sha256:HEX item and client_ca_pem is None. The message names the group and the item.
  • Error::Tls if client_ca_pem gives no verifier: it does not decode as PEM, holds no certificate, or holds a certificate that rustls refuses as a trust anchor.
  • Error::Options if receive is set and parallel_uploads is outside 1..=31, or session_idle_timeout or max_sessions is zero.
  • Error::Tls if the TLS files give no server configuration.
  • Error::Bind if a listen address cannot be bound, or if its local address cannot be read.