40 releases

0.15.19 Jan 25, 2024
0.15.18 Dec 13, 2023
0.15.17 Nov 23, 2023
0.15.2 Jul 17, 2023
0.2.0 Apr 20, 2017

#739 in Network programming

Download history 83/week @ 2023-11-01 25/week @ 2023-11-08 97/week @ 2023-11-15 195/week @ 2023-11-22 124/week @ 2023-11-29 25/week @ 2023-12-06 99/week @ 2023-12-13 64/week @ 2023-12-20 94/week @ 2023-12-27 18/week @ 2024-01-03 29/week @ 2024-01-10 41/week @ 2024-01-17 115/week @ 2024-01-24 86/week @ 2024-01-31 21/week @ 2024-02-07 393/week @ 2024-02-14

633 downloads per month
Used in 2 crates

AGPL-3.0

1MB
27K SLoC

sozu_lib, a proxy development library

sozu_lib provides tools to write a proxy that can be reconfigured without any downtime. See examples/minimal.rs for a small example of starting a HTTP proxy with one cluster.

A proxy starts as an event loop with which you communicate through a Channel. You can add or remove clusters by sending messages through that channel. Each message has an identifier that the event loop will use in its answer.

The proxy implementations handle differently the frontend and backend configurations. A single cluster could have multiple backend servers, but it can also answer to different hostnames and various TLS certificates. All those settings can be changed independently from the currently active connections. As an example, a backend server could be removed from the configuration while a client is still proxied through to that server. It should be possible later to force that connection to close if too many of those are lingering.

Exploring the source

  • parser/: only the HTTP 1.1 parser for now
  • lib/src/buffer_queue.rs: data buffering implementation
  • lib/src/protocol/: the HTTP, HTTP2, TLS handshake and piping proxies
  • lib/src/{http|https|tcp}.rs: proxies for HTTP, HTTPS and TCP
  • lib/src/server.rs: the main event loop shared by all proxies
  • lib/src/socket.rs: abstraction over normal sockets

Build with or without SIMD

SIMD stands for Single Instruction Multiple Data, and is used within the Kawa dependency to accelerate parsing.

Kawa implements SIMD with the SSE instruction set, which is specific to intel. If you wish to use Sōzu on another architecture (MacOS for instance), you can disable this feature by doing:

cargo build --no-default-features

Dependencies

~19–32MB
~599K SLoC