Skip to content

Experimental

The experimental block carries four loosely related feature areas: the persistent cache file, the Clash-compatible RESTful API, the V2Ray gRPC stats API, and the embedded pprof / runtime-debug endpoint.

FieldTypeDefaultAllowed valuesDescription
cache_file*CacheFileOptions(unset)CacheFileOptionsPersistent state cache.
clash_api*ClashAPIOptions(unset)ClashAPIOptionsExternal controller compatible with Clash dashboards.
v2ray_api*V2RayAPIOptions(unset)V2RayAPIOptionsgRPC stats service compatible with V2Ray clients.
debug*DebugOptions(unset)DebugOptionsEmbedded pprof endpoint and GC tuning.

Source: option/experimental.go:5-10 · pinned at v1.13.11 (553cfa1)

cache_file

Persistent on-disk cache for fakeip leases, selected-proxy memory, RDRC entries, and similar runtime state.

FieldTypeDefaultAllowed valuesDescription
enabledboolfalsetrue | falseTurn the cache file on.
pathstringcache.db<file path>Where to store the cache database.
cache_idstring(unset)<string>Namespace prefix in the same cache file. Useful when one cache file is shared by multiple sing-box instances.
store_fakeipboolfalsetrue | falsePersist the fakeip lease table.
store_rdrcboolfalsetrue | falsePersist Reject-DNS-Resolution Cache (rdrc) entries.
rdrc_timeoutbadoption.Duration7d<duration>How long rdrc entries stay valid in the cache.

Source: option/experimental.go:12-19 · pinned at v1.13.11 (553cfa1)

clash_api

A drop-in implementation of the Clash RESTful API. Compatible with metacubexd, Yacd, Clash Dashboard, and other Clash-API consumers.

FieldTypeDefaultAllowed valuesDescription
external_controllerstring(unset)<host:port>RESTful API listen address.
external_uistring(unset)<dir path>Local directory served as the dashboard.
external_ui_download_urlstringhttps://github.com/MetaCubeX/metacubexd/archive/refs/heads/gh-pages.zip<URL>Tarball auto-downloaded when external_ui is empty.
external_ui_download_detourstring(direct)<outbound tag>Outbound to use for the download.
secretstring(unset)<bearer token>Bearer-token required for all API calls. Highly recommended.
default_modestringrulerule | global | direct | <custom>Initial tunnel mode reported via the API. Custom values are accepted; non-standard dashboards ignore them.
access_control_allow_originbadoption.Listable[string][]<origin>CORS allow-list for the API.
access_control_allow_private_networkboolfalsetrue | falseAllow private-network preflight requests.

Source: option/experimental.go:21-42 · pinned at v1.13.11 (553cfa1)

Five additional fields (cache_file, cache_id, store_mode, store_selected, store_fakeip) are deprecated forwards into the cache_file block — keep them out of new configs.

v2ray_api

The V2Ray-compatible gRPC stats API. Useful if you have existing tooling (v2ray api stats query ...) you want to keep using.

FieldTypeDefaultAllowed valuesDescription
listenstring(required)<host:port>gRPC listen address for the StatsService.
stats*V2RayStatsServiceOptions(unset)V2RayStatsServiceOptionsCounter selection.

Source: option/experimental.go:44-47 · pinned at v1.13.11 (553cfa1)

v2ray_api.stats

FieldTypeDefaultAllowed valuesDescription
enabledboolfalsetrue | falseTurn the stats service on.
inbounds[]string[]<inbound tag>Inbound tags to count traffic for.
outbounds[]string[]<outbound tag>Outbound tags to count traffic for.
users[]string[]<user name>Per-user counters.

Source: option/experimental.go:49-54 · pinned at v1.13.11 (553cfa1)

debug

The Go-runtime tuning block. Most fields are direct knobs for the runtime and runtime/debug packages. The listen field exposes the standard net/http/pprof handlers.

FieldTypeDefaultAllowed valuesDescription
listenstring(unset)<host:port>pprof endpoint listen address (e.g. 127.0.0.1:6060).
gc_percent*int(Go default)<int> | -1GOGC override. -1 disables garbage collection.
max_stack*int(Go default)<bytes>Per-goroutine stack ceiling.
max_threads*int(Go default)<int>GOMAXPROCS-style thread cap.
panic_on_fault*boolfalsetrue | falseConvert unrecoverable runtime faults into a panic with stack trace.
trace_backstring(Go default)none | single | all | system | crashGOTRACEBACK setting.
memory_limit*byteformats.MemoryBytes(unset)<bytes/MiB/GiB>Soft memory cap; accepts plain numbers (bytes) or suffixed values like 256MiB.
oom_killer*boolfalsetrue | falseCrash the process when memory_limit is exceeded for too long.

Source: option/debug.go:5-14 · pinned at v1.13.11 (553cfa1)

Example

json
{
  "experimental": {
    "cache_file": {
      "enabled": true,
      "path": "cache.db",
      "store_fakeip": true
    },
    "clash_api": {
      "external_controller": "127.0.0.1:9090",
      "secret": "<random>",
      "external_ui": "/etc/sing-box/ui"
    },
    "debug": {
      "listen": "127.0.0.1:6060",
      "memory_limit": "256MiB"
    }
  }
}

Notes

  • The deprecated cache-related fields on clash_api (cache_file, cache_id, store_mode, store_selected, store_fakeip) still parse, but they emit warnings on load and will be removed in a future release. All five forward into the cache_file block.
  • debug.memory_limit accepts both plain numbers (bytes) and suffixed literals like "256MiB" or "2GiB", parsed by byteformats.MemoryBytes.

Source: option/experimental.go:5-54 · v1.13.11 (553cfa1)

Core Tutorial by Argsment