English
Configuration
How YAML text turns into ours_api::config::Config — the value the kernel gets (ours_kernel::Instance::new, Instance::reload). The section syntax for users is described in docs/usage/config; here — the mechanism.
Overview
.yaml file ─► ours_yaml::parse ─► ours_json::Node (a tree with spans)
│
▼
ours_native_config::load_with(text, &Decoders) crates/native-config
├─ envelope: names, defaults, final, order (the loader)
├─ section ─► Decoders::decode_section ─► module (Provide::Section)
├─ entity ─► Decoders::decode_protocol ─► module (Provide::Inbound/Outbound)
├─ block ─► Decoders::decode / decode_side ─► module (Provide::Block)
├─ source ─► Decoders::expand ─► module (Provide::Source) ─► new entities
└─ checks ─► Decoders::check(&dyn View) (Provide::Check)
│
▼
Loaded { config: Config, origins, warnings } ─► kernel: graph, plan, buildThe loader does not know the formats of protocols, transports, rules and DNS: it parses the document's envelope, hands nodes to modules and collects their answers (Decoded) into a Config. Decoders is the table of module decoders of a particular build; the kernel builds it (Modules::decoders).
Contents
The loading path:
- Loading — where the text comes from (
-c,-C,-D), the order of thelowersteps, reloading for the sake of subscriptions. - Document envelope — the top level, what the loader and the kernel read themselves.
- Sections —
Provide::Section,route.<key>, "not built in". - Entities — inbounds, outbounds, groups, rule_sets: name, type, blocks,
outbounds.defaults. - Blocks and variants —
tls,dial,mux,transport,reload; points,Provide::Block,Provide::Blocks. - Nesting and shared blocks — the rules of form: a dependent field one level down, the kind is a key, shared blocks depend on the side but not on the protocol.
Contract and codec:
ours_api::configtypes —Decoded,Given,Part,Blocks,Config,Decoders,Scope,View,Entity.- Codec —
libs/codec,libs/codec-derive:Decode/Encode/References,Cx,Fields. - YAML and JSON —
libs/yaml,libs/json: a tree with spans, YAML restrictions.
Links between the parts:
- Names and references — the namespace, group member patterns, cycles,
RefKind/References. - Rules —
route.rules,dns.rules,match/do/to, theconditionspoint,Written/flat, rule-sets. - The
dnssection — what the DNS module gives to other parts: resolvers, listeners. - Subscriptions —
Provide::Source, namespaces, vanished groups.
The result:
- Canonical form and reload —
canonical,cold, parts, the fingerprint, theours_config::defaultsdefaults. - JSON Schema —
Provide::Schema,ours_config::schema,json_schema, theschemacommand. - Errors and warnings —
line:columnpositions,located,first, warnings. - Dashboard view —
runtime,objects,Origin, text editing,check --view.
Related sections
- Module contract —
Module,Provide, points and extensions in full. - Kernel — what the kernel does with
Config: the graph, the plan, reload. - Modules — what each module decodes.