Skip to main content

Crate ostrya_server

Crate ostrya_server 

Source
Expand description

The HTTP server of ostrya, for the pull and the push of one repository.

A Server serves one repository to the pull of the ostree command and of ostrya. The pull reads it as an archive repository, whatever its mode (see ostrya::ArchiveView). With the client groups of the repository (ostrya::ReceivePolicies), the server identifies the client of each request by the auth items of the groups. It serves each read with the read rights of the item (ostrya::access::ReadAccess), and runs the receive endpoint of a push, which gives each session the policy of one group. With no client groups, each read gets the rights of the anonymous item under the implicit group. Behind a proxy, it reads the PROXY protocol header of a connection, and the client address, the scheme, and the client certificate that a trusted proxy forwards in the request headers. A host with its own HTTP router mounts that endpoint as a ReceiveEndpoint and authenticates the requests itself. The server also answers GET /_ostrya/refs/v1 with the bytes of ostrya::Repo::build_ref_listing for the ref patterns of its query, of the local refs and of the collection refs, and the read rights of its client. The crate builds on Linux alone.

§Entry points

§Features

  • smol (default): the smol backend of ostrya-rt.
  • tokio: the tokio backend of ostrya-rt, for a host on tokio.

§Examples

use ostrya::Repo;
use ostrya_server::{ServeOptions, bind};
let repo = Repo::open("/srv/repo".as_ref()).await?;
let mut opts = ServeOptions::default();
opts.listen = vec!["0.0.0.0:8080".parse()?];
let server = bind(repo, opts).await?;
println!("listening on {:?}", server.local_addrs());
server.run().await?;

Structs§

EndpointOptions
The options of ReceiveEndpoint::new.
ReceiveBody
The response body of ReceiveEndpoint::handle.
ReceiveEndpoint
The receive endpoint of a push, which a host mounts in its own router.
Refusal
A refusal of ReceiveAuth::authenticate or ReceiveAuth::open.
ServeOptions
The options of bind.
Server
A server with its listeners bound, ready to run.
ServerTls
The PEM bytes of the server TLS files.
SessionSetup
The receive policy and the hooks that ReceiveAuth::open gives to a session.

Enums§

Error
The error of bind and of ReceiveEndpoint::new.
RequestKind
The route of a request of the receive endpoint.
ServerEvent
An event of a server, which ServeOptions::on_event receives.

Traits§

ReceiveAuth
The authentication of the requests of the receive endpoint.

Functions§

bind
Binds the listeners of opts and returns a server over repo.
serve
Binds the listeners of opts and runs the server until the future drops.

Type Aliases§

Result
The result type of the crate.