Skip to main content

Crate singbox_driver

Crate singbox_driver 

Source
Expand description

Engine driver for the sing-box core.

The driver owns the engine-specific control API client, outbound/routing observation, readiness probe, native configuration codec and process supervision. It carries no product type, platform host or UI dependency.

Feature slices: http (Clash API, readiness, outbound, routing intent), process (process supervision) and codec (native JSON codec, which drives the process command boundary). Binary version probing is always available.

§Example

use singbox_driver::codec::profile_document_codec::{
    PROFILE_FORMAT, PROFILE_SCHEMA_VERSION, SingBoxProfileDocumentCodec,
};
use lurker_core_ports::profile_document_codec::ProfileDocumentCodecPort;

let codec = SingBoxProfileDocumentCodec;

// The codec is pure: it inspects exact bytes and never touches storage.
assert_eq!(codec.scope().format_id.as_str(), PROFILE_FORMAT);
assert_eq!(codec.scope().schema_version.value(), PROFILE_SCHEMA_VERSION);

// A valid document is a JSON object ...
assert!(matches!(
    codec.inspect(br#"{"outbounds": []}"#).expect("inspection never fails"),
    lurker_core_contract::profile_document::DocumentValidation::Valid
));

// ... and a syntactically broken document is reported, not guessed.
assert!(matches!(
    codec.inspect(b"{").expect("inspection never fails"),
    lurker_core_contract::profile_document::DocumentValidation::Invalid { .. }
));

Modules§

api
sing-box Clash API boundaries: HTTP transport, typed client, controller preflight and the CoreScope fence shared by the runtime adapters.
backend
Ready-made sing-box engine backend provider.
codec
sing-box native JSON document codec, validation and native check transaction.
driver
Owner-local sing-box process lifecycle: spawn, stop, child polling and pid readback behind the neutral CoreProcess port.
outbound
CoreScope-fenced sing-box outbound inventory, selector switching and probe.
process
Injectable native command boundary for sing-box checks and child startup.
readiness
Loopback-only readiness and live version observation for sing-box.
routing_intent
Typed, CoreScope-fenced sing-box routing intent observation.
version
Native sing-box binary version probing.