A plugin outbound can now give a url instead of a path. With the new
plugin-fetch feature, a start downloads what the cache is missing into
<cache>/<sha256>/<file> before any outbound is built, and points the
outbounds at it; a reload, and testing an outbound, resolve from the cache
only and refuse what they would have to download.
- https only, redirects included, and only together with a sha256 pin.
- Downloads go to a temporary file, are hashed as they arrive, and are
renamed into place only once the digest matches, under the url's own
name, with the platform's library suffix added when it has no
extension, which is what Windows needs to load it. A download past the
declared size, or past 64 MiB without one, is stopped.
- The cache directory comes from FetchOptions or PLUGIN_CACHE_DIR, with
no default: whether a directory is safe to load code from is the
embedding app's call.
- prefetch() reports QUEUED/CACHED for every plugin before any download,
then STARTED, PROGRESS (at most every 100 ms) and exactly one DONE or
FAILED each, on the calling thread; the callback can cancel. A download
that has not finished gets a PROGRESS heartbeat at least once a second,
before STARTED too, so that one stuck connecting or in the handshake
can be cancelled as well as one stuck mid-body.
conf gains a [Plugin] section that declares each plugin once (path, url,
sha256, size) and a `plugin` proxy protocol that refers to it by name,
with args= or args-b64= for arguments that contain commas. Proxy
parameters are now split at the first `=` only, which used to drop any
value that contained one.
leaf-ffi gains leaf_prefetch_plugins, so that an app can download the
plugins as soon as it has the config, and show progress, and the start
that follows finds everything in the cache. Events arrive as a
LeafFetchEvent whose first field is its size, on the calling thread and
never after the call returns. Adds ERR_PLUGIN_FETCH, ERR_CANCELLED and
ERR_UNSUPPORTED, and the plugin and plugin-fetch features. It is tested
by unit tests rather than end to end: the library is a Rust dylib, which
does not link in a Windows debug build (LNK1189).
Twenty-three fetch/ e2e cases download from a per-case https server
whose routes can announce a wrong length, omit it, fail, redirect, or
hold a body at a gate until the case opens it. Every case checks its
events against one statement of the progress contract, and every
failure, cancel and timeout case checks that the cache is left empty.
One checks that testing an outbound reads the cache, including a file
put there by hand, and never downloads.
The READMEs describe plugins in conf files and downloading them, and
plugin-test and CI run the new unit tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`make e2e` runs the end-to-end suite with `--strict`, minus the soak lane;
`make soak` is that lane plus the slow cost meters. `make plugin-test` covers
what an end-to-end run cannot reach -- the host's own loader and wrapper
tests, the ABI parity test, and each plugin's unit tests, one language at a
time -- and `make plugin-test-san` builds the C plugin's tests under address
and undefined-behaviour sanitizers, kept separate because not every toolchain
ships the runtimes.
CI grows a plugin job on Linux and macOS that runs the suite and
`make plugin-test`, and checks that `leaf-cli` still builds with plugin
support, since nothing else in the matrix compiles that feature. The same lane
exists for Windows but is started by hand: the suite has been through Windows
green on ARM64, and this runner is x86-64. A sanitizer lane runs the hostile
cases with the runtime exported so a plugin loads against it, and uploads the
artifact directory when a case fails. The soak workflow is the one that is
nightly: it runs the long lane out of hours with a longer timeout scale and
more meter repetitions, so its numbers are worth comparing between nights.
`.gitignore` learns the artifacts the plugin builds leave in the tree.
* Added WebSocket inbound
* Added trojan inbound
* Added chain inbound
Similar to the chain outbound, chain inbound can be used to chain
multiple inbounds. The Nginx/CDN (TLS) + WebSocket + trojan setup is tested.
There are also breaking changes to the JSON config format.
Fake DNS now can operate in either Include or Exclude mode.
SOCKS inbound settings no longer has the `bind` option, the local_addr of
the TCP socket is used as the UDP relay address.
* Added OpenSSL AEAD support
* Added OpenSSL TLS support
* Added mips/mipsel support
OpenSSL features can be conditinally compiled, targets not supported
by ring should use OpenSSL, e.g. mips/mipsel, while other targets
should use ring and rustls for crypto and TLS for better performance.
Crypto functions from Shadowsocks and VMess are unified in common/crypto.