Skip to content

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 ​

text
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 core

The 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 ​

SectionSource
logLog level
inboundsThe current run mode and Local proxy settings
outboundsOutbounds in your groups, Selector / URLTest groups from Selector management, and the direct outbound
endpointsEndpoint management
dnsDNS management
routeRouting management, Protocol sniffing, and rule sets from Resource management
services, experimentalAPI 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:

TagMeaning
inbound_tunThe TUN inbound for VPN Service (without Hev TUN) and TUN (ROOT) modes
inbound_rootTraffic inbound for TPROXY and eBPF. TUN2SOCKS and BPF2SOCKS also generate it as a SOCKS inbound
inbound_localLocal proxy inbound
asterisk-bridgeReceives traffic with app ownership information in VPN Service with Use Hev TUN on, and in TUN2SOCKS and BPF2SOCKS modes
outbound_directDirect outbound
selector_globalThe 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_fakeipThe 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_apiThe 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:

  1. Sniffing: action: sniff (when Protocol sniffing is on)
  2. DNS hijacking: connections to port 53 get action: hijack-dns (when DNS is enabled)
  3. Proxy mode: with clash_mode: Global everything goes to selector_global; with clash_mode: Direct everything goes to outbound_direct
  4. The enabled rules from Routing management
  5. 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:

  • config is the compiled sing-box configuration object.
  • Return the modified object; if you return undefined or null, the config you mutated in place is used. The return value must be an object, not an array.
  • No async: returning a Promise from main is an error.
  • Limits: at most 3 seconds per run and 64 MB of memory; no network or file access.
  • console.log and 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.

js
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 ​

js
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.

Official documentation ​