mirror of
https://github.com/eycorsican/leaf.git
synced 2026-12-05 08:01:26 +00:00
The old API handed dynamic libraries Rust trait objects, tying every plugin to leaf's exact compiler and crate versions and ruling out other languages. It is removed, along with its shadowsocks sample, which returns on the new ABI in a later commit. The host loads plugins over leaf-plugin-abi instead. It validates the descriptor, dials the endpoint, and drives the engines as sans-io codecs over its own transport, exposing them as ordinary outbound handlers. Datagram engines are either unreliable, with a UDP socket of their own, or reliable, framed over the stream transport. Plugin failures carry the plugin's last error string, and plugin logs join the session's tracing span. Everything crossing the boundary is treated as untrusted: counts are checked against the buffers they describe, reported strings are bounded and escaped, engines get an opaque id rather than a pointer for host_ctx, and an engine that takes no input is backpressure rather than failure. A poll does a bounded amount of work, and a datagram the receiver cannot take is dropped instead of the session. An outbound names its path, host and port, and may pin the sha256 of the library it loads -- the only check on this path that still holds against someone who can write the file. `leaf --verify-plugin <path>` runs the same checks without a config file and prints what the plugin declares: its ABI version, its engines, whether the outbound must carry host and port, and the digest to pin it to. A build can then be vetted before it is in the path of any traffic.