Skip to content

Build your own ​

Every protocol, transport and subsystem of ours is a separate feature, and the inbound and outbound of a protocol build separately. build.toml in the repository root lists them all, everything on. Turn off what you don't need and the code is left out of the binary: a router that only connects to one VLESS server needs a fraction of it.

You don't need a build machine: a fork of the repository builds release binaries with GitHub Actions.

Pick the features ​

Untick what you don't need; the file below follows, ready to copy. Ticking a key ticks what it needs, unticking one unticks what needs it (What needs what); build.py pulls in the same whatever the file says.

toml
# What `python3 dist/build.py` builds into ours: everything, as the `default` features do.
# A key set to false leaves its code out of the binary. A key that is on pulls in what it needs
# (trojan pulls tls, dns.quic pulls tls and QUIC), whatever that key says.

[allocator]
kind = "jemalloc" # jemalloc | mimalloc | system

# Inbound and outbound of a protocol build separately; a protocol with one side lists only it.
[protocols]
anytls = { inbound = true, outbound = true }
hysteria = { inbound = true, outbound = true }
hysteria2 = { inbound = true, outbound = true }
shadowsocks = { inbound = true, outbound = true, v2ray-plugin = true }
shadowtls = { inbound = true, outbound = true }
trojan = { inbound = true, outbound = true }
tuic = { inbound = true, outbound = true }
vless = { inbound = true, outbound = true, vlessenc = true, mux-cool = true }
http = { inbound = true, outbound = true }
socks = { inbound = true, outbound = true }
direct = { inbound = true, outbound = true }
mixed = { inbound = true }
mtproto = { inbound = true }
tproxy = { inbound = true, auto-nft = true }
redirect = { inbound = true }
tun = { inbound = true }
block = { outbound = true }
wireguard = { endpoint = true, awg = true, ciphers = true }

[tls]
enabled = true
ktls = false

[mux]
smux = true
yamux = true
h2 = true
xray = true
brutal = true
padding = true

[transports]
grpc = true
http = true
httpupgrade = true
ws = true
xhttp = true

[sniff]
enabled = true

[routing]
router = true
group = { enabled = true, probe = true }

[routing.rules]
metadata = true
ip = true
domain = true
dns = true
port = true
process = true
network = true
neighbor = true

[routing.rule-sets]
inline = true
local = true
remote = true
binary = true
dat = true

[dns]
enabled = true
udp = true
tcp = true
tls = true
https = true
quic = true
h3 = true
local = true
mdns = true
hosts = true
fakeip = true

[subscriptions]
links = true
xray = true
clash = true

[system]
ntp = true
cache = true

[app]
api = true
adblock = true
dashboard = true
clients = true
tools = true

A configuration that uses something the build leaves out fails ours check with ... is not built in and the list of what is built. ours version prints the features of a binary.

What needs what ​

A key that is on needs the keys of its row, and they need theirs in turn: dns.udp needs dns.enabled, which needs routing.router. A key not in the table needs nothing. The picker above follows this table.

KeyNeeds
protocols.anytls.inbound, protocols.anytls.outbound, protocols.hysteria.inbound, protocols.hysteria.outbound, protocols.hysteria2.inbound, protocols.hysteria2.outbound, protocols.shadowtls.inbound, protocols.shadowtls.outbound, protocols.trojan.inbound, protocols.trojan.outbound, protocols.tuic.inbound, protocols.tuic.outbound, tls.ktlstls.enabled
protocols.shadowsocks.v2ray-plugintls.enabled, transports.ws, mux.xray
protocols.vless.mux-coolprotocols.vless.inbound
protocols.tproxy.auto-nftprotocols.tproxy.inbound, routing.router
protocols.wireguard.awg, protocols.wireguard.ciphers, app.clientsprotocols.wireguard.endpoint
routing.group.proberouting.group.enabled
routing.rules.metadata, routing.rules.ip, routing.rules.domain, routing.rules.dns, routing.rules.port, routing.rules.process, routing.rules.network, routing.rules.neighbor, routing.rule-sets.inline, routing.rule-sets.local, routing.rule-sets.remote, routing.rule-sets.binary, routing.rule-sets.dat, dns.enabledrouting.router
dns.udp, dns.tcp, dns.tls, dns.https, dns.quic, dns.h3, dns.local, dns.mdns, dns.hosts, dns.fakeip, app.adblockdns.enabled
app.dashboardapp.api

Build in your fork ​

  1. Fork the repository on GitHub.
  2. Open the Actions tab of the fork and enable workflows: GitHub keeps them off in a new fork.
  3. Replace build.toml in the fork with yours and commit it to the default branch.
  4. Actions → Release → Run workflow.
  5. When the run finishes, the binaries are in the fork's Releases.
FileFor
ours-x86_64-linuxServers and PCs
ours-x86_64-linux-upxThe same, packed with UPX for small disks
ours-aarch64-linuxARM routers, Raspberry Pi, ARM servers
ours-aarch64-linux-upxRouters with little flash
SHA256SUMSChecksums of the files above

A UPX binary takes about a third of the flash but unpacks into RAM on every start: use it when flash is what you are short of.

sh
sha256sum -c --ignore-missing SHA256SUMS
install -m 755 ours-aarch64-linux /usr/bin/ours
ours version

Build on your machine ​

With the toolchain from Install, dist/build.py turns a profile into Cargo features and runs the build:

sh
cp build.toml router.toml   # set what you don't need to false
python3 dist/build.py --config router.toml --target x86_64-unknown-linux-musl
python3 dist/build.py --config router.toml --print   # only the feature list

How keys map to features and what every feature enables: Building the binary.

GPL-3.0-or-later