XRAT SDK
Embed XRAT's stateless proxy tools in a Rust application:
use ;
Available APIs
model: normalizedNode,Protocol, and deduplication keys. Serializing a node produces XRAT's data representation, not runnable engine JSON.config: parse individual proxy links, subscription text, and imports.engines::xray: typed runtime/probe generators, listener settings, DNS, routing, tuning options, and compatibility targets.engines::singbox: typed runtime/probe generators, listeners, DNS, routing, and Clash API options.prober: TCP, ICMP, real delay, download, and upload checks and result types.
Default SDK builds also exclude the engine traffic-stats RPC stack; application builds retain their existing stats support.
JSON generation has no database, process, or configuration-file side effects. Unsupported settings return the existing generator errors. Xray and sing-box have different schemas and capabilities; these modules do not promise arbitrary cross-engine conversion. There is no separate V2Ray generation target yet.
Async probes require a Tokio runtime. TCP checks connect to the supplied
endpoint; ICMP uses the platform's ping command and its permissions.
Real-delay and speed checks require an explicitly supplied Xray or sing-box
binary, startup/request timeouts, and test URL. They launch a temporary local
SOCKS proxy and clean it up after completion or cancellation. They do not
download engines, initialize global logging, or persist results.
XrayGenOptions only tunes Xray probes; sing-box probes use their existing
default generator and ignore this argument.
Experimental services
Stateful service exports require an explicit opt-in:
[]
= { = "0.21", = ["services"] }
This preserves the existing xrat_sdk::services module but pulls in xrat-app
and its database/UI dependencies. SDK-only initialization, saved-config
services, and managed connect/status/disconnect APIs are deferred. These
experimental services are not a complete standalone embedding contract.
Examples and compatibility
From a checkout, run:
The TCP example creates its own loopback listener. Real-delay probing requires an actual proxy and caller-selected test endpoint. Probe requests and normalized JSON may contain proxy credentials; choose what your application logs or shares.
The SDK shares release versions with XRAT and is pre-1.0. Use the 0.21 series
for this API; commit your application's lockfile for reproducible resolution.
Xray compatibility is selected by XrayGenOptions; sing-box output uses the
existing 1.13 schema. Representative native checks are pinned to Xray 26.3.27
and sing-box 1.13.21, rather than claiming compatibility with every engine
version.
Git remains optional for unreleased development code:
See API documentation and XRAT documentation.