sing-box configuration (AsteriskBOX)
AsteriskBOX compiles the groups, outbounds, selectors, endpoints, DNS, and routing you set up in the UI into a complete sing-box JSON configuration. You can inspect the result in Settings → Tools → Configuration preview and make final changes with an override script.
Pipeline
Modules in the UI
│
├─ ① Compile: log / inbounds / endpoints / outbounds / services / dns / route / experimental
│
├─ ② Override script main(config) (when enabled)
│
├─ ②′ Compile plugin outbounds (when using protocol plugins)
│
├─ ③ Validate the final config with the core
│
└─ ④ Run by the coreThe override script runs after compilation and can change any part of the configuration. If validation fails, the service does not start.
Modules and config sections
| Section | Source |
|---|---|
log | Log level |
inbounds | The current run mode and Local proxy settings |
outbounds | Outbounds in your groups, Selector / URLTest groups from Selector management, and the direct outbound |
endpoints | Endpoint management |
dns | DNS management |
route | Routing management, Protocol sniffing, and rule sets from Resource management |
services, experimental | API and cache settings used internally by the app |
Managed tags
Every tag in the config is generated by the app in a fixed format, so you can reference it from an override script:
| Tag | Meaning |
|---|---|
inbound_tun | The TUN inbound for VPN Service (without Hev TUN) and TUN (ROOT) modes |
inbound_root | Traffic inbound for TPROXY and eBPF. TUN2SOCKS and BPF2SOCKS also generate it as a SOCKS inbound |
inbound_local | Local proxy inbound |
asterisk-bridge | Receives traffic with app ownership information in VPN Service with Use Hev TUN on, and in TUN2SOCKS and BPF2SOCKS modes |
outbound_direct | Direct outbound |
selector_global | The selector all traffic uses in Home's "Global" mode |
outbound_<id>_<remarks> | An outbound (server) |
outbound_group_<id>_<group name> | The selector that belongs to a group |
selector_<id>_<remarks> | A Selector / URLTest created in Selector management |
endpoint_<id>_<remarks> | An endpoint |
dns_server_<id>_<remarks> | A DNS server |
dns_evaluation_<id>_<remarks> | The tag used by DNS rules with the Evaluate action |
dns_fakeip | The FakeIP DNS server |
rule_set_<id>_<file name> | A custom rule set added in resource management |
rule_set_<file name> | A bundled rule set |
service_api | The api service the app uses in ROOT modes |
Special characters in names are replaced; check Configuration preview for the actual tags.
Routing rule order
route.rules is matched in order, and the first match wins. The app generates them in this order:
- Sniffing:
action: sniff(when Protocol sniffing is on) - DNS hijacking: connections to port 53 get
action: hijack-dns(when DNS is enabled) - Proxy mode: with
clash_mode: Globaleverything goes toselector_global; withclash_mode: Directeverything goes tooutbound_direct - The enabled rules from Routing management
- If nothing matches,
route.final(the default outbound) is used
Home's Rule / Global / Direct switch works through the clash_mode rules in step 3.
Override scripts
Enable Override script under Settings → Advanced settings → Override script and write your script. It must define a synchronous main(config) function:
configis the compiled sing-box configuration object.- Return the modified object; if you return
undefinedornull, theconfigyou mutated in place is used. The return value must be an object, not an array. - No async: returning a Promise from
mainis an error. - Limits: at most 3 seconds per run and 64 MB of memory; no network or file access.
console.logand friends are available; output is shown in Debug (up to 500 entries).
Error details are only shown in Debug
If the script fails, starting the service only reports that the override failed, without details, so that secrets in the configuration don't end up in notifications or logs. Use Debug to see the full error, console output, and validation warnings.
Example: route a domain directly
Insert new rules after the sniffing, DNS hijacking, and proxy mode rules injected by the app (see Routing rule order). Before sniffing, sniffed domains are not available yet; before the proxy mode rules, your rule would break "Global / Direct" mode.
function main(config) {
config.route = config.route || {}
const rules = config.route.rules || (config.route.rules = [])
const injected = (rule) =>
rule.action === 'sniff' || rule.action === 'hijack-dns' || rule.clash_mode !== undefined
let index = 0
while (index < rules.length && injected(rules[index])) {
index++
}
rules.splice(index, 0, {
domain_suffix: ['example.com'],
outbound: 'outbound_direct',
})
return config
}Example: change the test interval of every URLTest
function main(config) {
for (const outbound of config.outbounds || []) {
if (outbound.type === 'urltest') {
outbound.interval = '5m'
}
}
return config
}WARNING
Changing the inbound_* inbounds or the app's internal settings in services and experimental may break the current run mode, Home monitors, proxy switching, and other features.
Validation and preview
- The app validates the configuration with the core before saving rule sets and before starting the service; invalid configurations are reported instead of being started.
- Configuration preview: while the service runs, it shows the config file in use; otherwise it shows the config generated from the current settings (including the override script).
- The sing-box core bundled with AsteriskBOX includes some extensions not found upstream, such as the eBPF inbound; for those fields, what the app generates is authoritative.