English
Configuration
The ours configuration is one YAML file. It is a format of its own: the protocols are compatible with sing-box and Xray, but a sing-box JSON file is neither accepted nor converted. What maps to what is in Migrating from sing-box.
How to pass the file to the process is in Command line.
Minimal configuration
yaml
inbounds:
local:
mixed:
listen: 127.0.0.1:1080
outbounds:
direct:
direct:
route:
final:
outbound: directOnly route.final is required. Without outbounds, final can only be a built-in action such as block.
Top-level sections
| Section | What it sets |
|---|---|
log | The log: level, where to write |
inbounds | Inbounds: where to accept connections |
outbounds | Outbounds: where to send connections |
endpoints | WireGuard endpoints: an inbound and an outbound in one object |
groups | Groups of outbounds: manual choice or choice by probes |
subscriptions | Provider subscriptions: servers as outbounds |
rule_sets | Sets of conditions for rules |
route | Routing rules and the default outbound |
dns | DNS: upstreams, rules, fakeip, own listeners |
adblock | DNS filtering by AdGuard / hosts lists, statistics, query log |
ntp | Time synchronization |
certificate | The root certificate store |
http_clients | HTTP clients for downloading rule-sets |
network_namespaces | Linux network namespaces by name |
reload | What a reload does to live connections |
runtime | On which CPUs the shard threads run and how many there are |
cache | The cache file |
admin | The Admin API and dashboard: address, users and their roles |
Any other top-level section is an error listing the allowed ones. The order of sections in the file does not matter.
Format version
yaml
version: 1An optional top-level field: the format version the file is written for, currently 1. Without it the file is treated as version 1. When a newer format comes out, ours converts such a file to the newer format when it loads it. A version newer than the build understands is an error even before the rest of the file is parsed: configuration format version 2 is newer than this build reads (1): update ours, …. How ours reads previous versions and previous section names is in Format migration.
Writing rules
- YAML 1.2. One document per file:
---with a second document is an error. - An unknown field is an error, a repeated key is an error pointing to the first occurrence.
- Anchors (
&x), aliases (*x), merge keys (<<) and tags (!!str) are forbidden. Repeated outbound settings go intooutbounds.defaults. - The words
yes,no,on,offare strings, not booleans: writetrueandfalse. - An error gives the line and column:
12:7: no outbound `proxy`.
Block and flow YAML styles are equal and can be mixed:
yaml
outbounds: {direct: {direct: }, proxy: {socks: {server: "192.0.2.10:1080"}}}
groups:
main:
members: [proxy, direct]
route: {final: {group: main}}A block without parameters is written as a key without a value: direct:. An empty value and {} are equivalent.
Values
| What | How it is written |
|---|---|
| Duration | A string with a unit: 300ms, 30s, 5m, 1h30m, 1d. Units ns, us, ms, s, m, h, d. Negative durations are invalid. The unit is required: timeout: 30 is an error (only adblock also takes a number of seconds) |
| Address | One host:port string: de.example.com:443, [2001:db8::1]:443, 127.0.0.1:1080. There are no server + server_port and listen + listen_port pairs |
| List | A YAML list. For protocol fields and rule conditions a single value can be written without brackets: port: 443 instead of port: [443]; a group's members is a list or a single match: element |
Entities by name
Inbounds, outbounds, groups, subscriptions, rule-sets and DNS upstreams are written as a mapping "name → description". There is no tag field: the name is the key. Only ordered things stay lists: the route.rules and dns.rules rules.
yaml
outbounds:
proxy-de: # the name
vless: # the protocol block
server: de.example.com:443
uuid: bf000d23-0752-40b4-affe-68f7707a9661
tls: # a block inside the protocol
sni: de.example.comName restrictions:
- Outbounds and groups share one namespace: the same name in
outboundsandgroupsis an error. - The characters
* ? [ ] { }are forbidden in names: they are needed for patterns. /is forbidden in names: it separates the name of a subscription from the name of its server (work/de-1).defaultsinoutboundsis a reserved name.
Blocks
An inbound and an outbound have exactly one protocol block, a key with the protocol's name (vless:, mixed:, …). A block that depends on its neighbor is nested in it: not every protocol has tls, transport and mux, so they are written inside the protocol block. dial, listener and reload do not depend on the protocol and stand next to it, at the level of the entity:
| Block | Where | Description |
|---|---|---|
tls | inside the protocol of an inbound or outbound | tls |
transport | inside the protocol of an inbound or outbound | Transports; the kind is the key: transport: {ws: …} |
mux | inside the protocol of an inbound or outbound | mux |
dial | outbound | dial |
listener | inbound | listener: the socket of an inbound, as dial is for an outbound |
reload | inbound, outbound, group | reload |
Which blocks a protocol takes is decided by its module: an extra block is an error like outbound `x`: `direct` takes no `tls` block. tls at the entity level is the error `tls` belongs inside the `vless` block. Protocol fields are in Protocols.
Where a block is chosen by a key (transport, mux, the kind of an upstream, a group's rank), the key specifies the kind. A block is on when it is present, as tls is. Only a few fields switch something on or off explicitly: dns.cache.optimistic.enabled, dns.cache.disabled, log.disabled.
References to entities
Where a value can be either a name or a built-in action, the kind of the name is written explicitly:
yaml
groups:
main:
members: [proxy, direct]
route:
rules:
- match:
domain_suffix: example.org
to:
group: main # a group
- match:
port: 25
to: block # a built-in action
final:
outbound: direct # an outboundA string without a kind is always a built-in action, so an outbound named block is not confused with anything. A wrong kind is an error with a hint: `direct` is an outbound, use `outbound: direct`.
Where only one kind of entity is possible, just the name is written: a group's members, dial.detour, the via of a rule-set, a subscription and an upstream (an outbound or a group), inbound in conditions.
A reference to an outbound, group, rule-set or upstream that does not exist is an error with the position of the reference. An inbound name that does not exist in an inbound condition is an error too, at the name (route names inbound `typo`, which is not in the configuration). A subscription server cannot be referenced directly, only through a group (more in Subscriptions).
Name patterns
In a group's members (a match: element) and in the outbound condition of DNS rules a glob can be written:
| Pattern | Matches |
|---|---|
* | any string |
? | one character |
[a-d], [!x] | a character from the set or not from it |
{de,nl} | any of the alternatives |
Example: proxy-{de,nl}-*. A pattern that matched no name is an error, except for patterns over subscription servers: their membership changes, so there it is a warning.
Checking
sh
ours check -c config.yamlReady-made configurations are in examples: client.yaml, server.yaml, router.yaml. Check one with ours check examples/client.yaml.
For an editor there is a JSON Schema: ours schema schema.json (see Command line).