### Manual installation script for latest beta Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/installation/package-manager.md Downloads and installs the latest beta version of sing-box from GitHub releases. ```shell curl -fsSL https://sing-box.app/install.sh | sh -s -- --beta ``` -------------------------------- ### Install sing-box via Debian/APT repository Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/installation/package-manager.md Adds the sing-box APT repository and installs sing-box or sing-box-beta. Requires sudo privileges. ```bash sudo mkdir -p /etc/apt/keyrings && sudo curl -fsSL https://sing-box.app/gpg.key -o /etc/apt/keyrings/sagernet.asc && sudo chmod a+r /etc/apt/keyrings/sagernet.asc && echo ' Types: deb URIs: https://deb.sagernet.org/ Suites: * Components: * Enabled: yes Signed-By: /etc/apt/keyrings/sagernet.asc ' | sudo tee /etc/apt/sources.list.d/sagernet.sources && sudo apt-get update && sudo apt-get install sing-box # or sing-box-beta ``` -------------------------------- ### Simple build with make Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/installation/build-from-source.md Builds the sing-box binary using the default make target. Use `make install` to build and install the binary to `$GOBIN`. ```bash make ``` ```bash make install ``` -------------------------------- ### Install sing-box via Redhat/DNF 5 repository Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/installation/package-manager.md Adds the sing-box repository using DNF 5 and installs sing-box or sing-box-beta. ```bash sudo dnf config-manager addrepo --from-repofile=https://sing-box.app/sing-box.repo && sudo dnf install sing-box # or sing-box-beta ``` -------------------------------- ### Install sing-box via Redhat/DNF 4 repository Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/installation/package-manager.md Adds the sing-box repository using DNF 4 and installs sing-box or sing-box-beta. ```bash sudo dnf config-manager --add-repo https://sing-box.app/sing-box.repo && sudo dnf -y install dnf-plugins-core && sudo dnf install sing-box # or sing-box-beta ``` -------------------------------- ### Clash API example for UI download Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/experimental/clash-api.md Example configuration for downloading and serving an external UI. Requires sing-box 1.10.0 or later. The commented line shows how to set a download detour. ```json { "external_controller": "0.0.0.0:9090", "external_ui": "dashboard" // "external_ui_download_detour": "direct" } ``` -------------------------------- ### Install SagerNet gomobile and gobind Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/amnezia/build.md Install the pinned SagerNet gomobile v0.1.8 and matching gobind using Go 1.25.5. A dedicated GOPATH avoids replacing other installed mobile tools. ```sh export GOTOOLCHAIN=local GOWORK=off export GOPATH="$(mktemp -d)" go install github.com/sagernet/gomobile/cmd/gomobile@v0.1.8 go install github.com/sagernet/gomobile/cmd/gobind@v0.1.8 ``` -------------------------------- ### Path field example Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/dns/server/hosts.md Example of the 'path' field, showing a commented-out single path and a list of paths. The default is '/etc/hosts' or 'C:\Windows\System32\Drivers\etc\hosts' on Windows. ```json { // "path": "/etc/hosts" "path": [ "/etc/hosts", "$HOME/.hosts" ] } ``` -------------------------------- ### Manual installation script for specific version Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/installation/package-manager.md Downloads and installs a specific version of sing-box from GitHub releases. Replace with the desired version. ```shell curl -fsSL https://sing-box.app/install.sh | sh -s -- --version ``` -------------------------------- ### Manual installation script for latest version Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/installation/package-manager.md Downloads and installs the latest sing-box package from GitHub releases for deb/rpm based Linux, ArchLinux, and OpenWrt. ```shell curl -fsSL https://sing-box.app/install.sh | sh ``` -------------------------------- ### Predefined field example Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/dns/server/hosts.md Example of the 'predefined' field, mapping hostnames to IP addresses or lists of IPs. ```json { "predefined": { "www.google.com": "127.0.0.1", "localhost": [ "127.0.0.1", "::1" ] } } ``` -------------------------------- ### Install SFM via Homebrew Cask Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/clients/apple/index.md Install the sing-box for Apple (SFM) standalone macOS version using Homebrew Cask. ```bash brew install sfm ``` -------------------------------- ### Use hosts if available Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/dns/server/hosts.md Example configuration that uses the hosts server when available, with a rule to accept any IP and route to the 'hosts' server. ```json { "dns": { "servers": [ { ... }, { "type": "hosts", "tag": "hosts" } ], "rules": [ { "ip_accept_any": true, "server": "hosts" } ] } } ``` -------------------------------- ### Naive Inbound Configuration Example Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/inbound/naive.md Example configuration for a Naive inbound. The `network` field can be `tcp` or `udp`, and both are used if empty. The `users` field is required and contains Naive user credentials. The `tls` field is for TLS configuration. ```json { "type": "naive", "tag": "naive-in", "network": "udp", ... // Listen Fields "users": [ { "username": "sekai", "password": "password" } ], "tls": {} } ``` -------------------------------- ### ShadowTLS inbound configuration example Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/inbound/shadowtls.md Example configuration for a ShadowTLS inbound listener. Shows the structure with version, password, users, handshake, handshake_for_server_name, strict_mode, and wildcard_sni fields. ```json { "type": "shadowtls", "tag": "st-in", ... // Listen Fields "version": 3, "password": "fuck me till the daylight", "users": [ { "name": "sekai", "password": "8JCsPssfgS8tiRwiMlhARg==" } ], "handshake": { "server": "google.com", "server_port": 443, ... // Dial Fields }, "handshake_for_server_name": { "example.com": { "server": "example.com", "server_port": 443, ... // Dial Fields } }, "strict_mode": false, "wildcard_sni": "" } ``` -------------------------------- ### Split DNS only example Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/dns/server/resolved.md Configures a local DNS server and a resolved server, with a rule to send all queries to the resolved server. ```json { "dns": { "servers": [ { "type": "local", "tag": "local" }, { "type": "resolved", "tag": "resolved", "service": "resolved" } ], "rules": [ { "ip_accept_any": true, "server": "resolved" } ] } } ``` -------------------------------- ### Use as global DNS example Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/dns/server/resolved.md Configures the resolved server as the global DNS by setting 'accept_default_resolvers' to true. ```json { "dns": { "servers": [ { "type": "resolved", "service": "resolved", "accept_default_resolvers": true } ] } } ``` -------------------------------- ### Clash API example for online access Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/experimental/clash-api.md Example configuration for accessing the Clash API from a public website. Requires sing-box 1.10.0 or later. Sets allowed origins and enables private network access. ```json { "external_controller": "127.0.0.1:9090", "access_control_allow_origin": [ "http://127.0.0.1", "http://yacd.haishan.me" ], "access_control_allow_private_network": true } ``` -------------------------------- ### SSM API servers mapping example Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/service/ssm-api.md Example of the servers field, mapping an HTTP endpoint to a Shadowsocks inbound tag. The inbound must have managed enabled. ```json { "servers": { "/": "ss-in" } } ``` -------------------------------- ### NTP configuration JSON example Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/ntp/index.md Example configuration for the NTP client service. The 'enabled' field turns the service on or off, 'server' is required, 'server_port' defaults to 123, and 'interval' defaults to 30 minutes. Additional dial fields can be added as shown by the comment. ```json { "ntp": { "enabled": false, "server": "time.apple.com", "server_port": 123, "interval": "30m", ... // Dial Fields } } ``` -------------------------------- ### Hysteria Inbound Configuration Example Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/inbound/hysteria.md Example configuration for a Hysteria inbound. Shows required fields (up, down, tls) and optional fields like obfs, users, and flow control settings. The 'up' and 'down' fields accept formats like '100 Mbps' or '640 KBps'. ```json { "type": "hysteria", "tag": "hysteria-in", ... // Listen Fields "up": "100 Mbps", "up_mbps": 100, "down": "100 Mbps", "down_mbps": 100, "obfs": "fuck me till the daylight", "users": [ { "name": "sekai", "auth": "", "auth_str": "password" } ], "recv_window_conn": 0, "recv_window_client": 0, "max_conn_client": 0, "disable_mtu_discovery": false, "tls": {} } ``` -------------------------------- ### Verify clean clone with submodule and build consumer Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/amnezia/consumer.md Clones the consumer repository with submodules and builds it with the required build tags to confirm a clean setup works. Also prints the submodule HEAD to verify the pinned commit. ```sh git clone --recurse-submodules consumer-clean cd consumer-clean GOWORK=off GOTOOLCHAIN=local go build -tags with_gvisor,with_awg ./... git -C third_party/amnezia-box rev-parse HEAD ``` -------------------------------- ### VLESS Outbound Configuration Example Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/outbound/vless.md Example configuration for a VLESS outbound. The `server`, `server_port`, and `uuid` fields are required. The `flow` field supports `xtls-rprx-vision`. The `network` field can be `tcp` or `udp`; both are enabled by default. `packet_encoding` defaults to `xudp`. ```json { "type": "vless", "tag": "vless-out", "server": "127.0.0.1", "server_port": 1080, "uuid": "bf000d23-0752-40b4-affe-68f7707a9661", "flow": "xtls-rprx-vision", "network": "tcp", "tls": {}, "packet_encoding": "", "multiplex": {}, "transport": {}, ... // Dial Fields } ``` -------------------------------- ### TUIC inbound JSON configuration example Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/inbound/tuic.md Example configuration for a TUIC inbound listener. Includes a user with name, UUID, and password. The 'tls' field is required and must be configured separately. Defaults: congestion_control is 'cubic', auth_timeout is '3s', zero_rtt_handshake is false, heartbeat is '10s'. ```json { "type": "tuic", "tag": "tuic-in", ... // Listen Fields "users": [ { "name": "sekai", "uuid": "059032A9-7D40-4A96-9BB1-36823D848068", "password": "hello" } ], "congestion_control": "cubic", "auth_timeout": "3s", "zero_rtt_handshake": false, "heartbeat": "10s", "tls": {} } ``` -------------------------------- ### Use Tailscale DNS as Global DNS Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/dns/server/tailscale.md Uses Tailscale DNS as the global DNS server by enabling accept_default_resolvers, which allows fallback queries to default resolvers in addition to MagicDNS. This is the 'Use as global DNS' example. ```json { "dns": { "servers": [ { "type": "tailscale", "endpoint": "ts-ep", "accept_default_resolvers": true } ] } } ``` -------------------------------- ### Build with explicit VERSION and cross-compile Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/amnezia/build.md Build with an explicit VERSION, which takes precedence. One leading v is removed before the version is embedded in the CLI or libbox. Cross-compilation examples for Linux and Windows set GOOS, GOARCH, and CGO_ENABLED=0. ```sh make -f Makefile.amnezia build VERSION=v1.260910.0 OUTPUT=/tmp/amnezia-box GOOS=linux GOARCH=amd64 CGO_ENABLED=0 make -f Makefile.amnezia build OUTPUT=/tmp/amnezia-box-linux-amd64 GOOS=windows GOARCH=amd64 CGO_ENABLED=0 make -f Makefile.amnezia build OUTPUT=/tmp/amnezia-box-windows-amd64.exe ``` -------------------------------- ### TUN inbound configuration structure Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/inbound/tun.md Complete tun inbound configuration example showing all available fields, including deprecated options and the platform HTTP proxy block. Only supported on Linux, Windows and macOS. When tun runs in non-privileged mode, addresses and MTU are not configured automatically, so settings must be accurate. ```json { "type": "tun", "tag": "tun-in", "interface_name": "tun0", "address": [ "172.18.0.1/30", "fdfe:dcba:9876::1/126" ], "mtu": 9000, "auto_route": true, "iproute2_table_index": 2022, "iproute2_rule_index": 9000, "auto_redirect": true, "auto_redirect_input_mark": "0x2023", "auto_redirect_output_mark": "0x2024", "loopback_address": [ "10.7.0.1" ], "strict_route": true, "route_address": [ "0.0.0.0/1", "128.0.0.0/1", "::/1", "8000::/1" ], "route_exclude_address": [ "192.168.0.0/16", "fc00::/7" ], "route_address_set": [ "geoip-cloudflare" ], "route_exclude_address_set": [ "geoip-cn" ], "endpoint_independent_nat": false, "udp_timeout": "5m", "stack": "system", "include_interface": [ "lan0" ], "exclude_interface": [ "lan1" ], "include_uid": [ 0 ], "include_uid_range": [ "1000:99999" ], "exclude_uid": [ 1000 ], "exclude_uid_range": [ "1000:99999" ], "include_android_user": [ 0, 10 ], "include_package": [ "com.android.chrome" ], "exclude_package": [ "com.android.captiveportallogin" ], "platform": { "http_proxy": { "enabled": false, "server": "127.0.0.1", "server_port": 8080, "bypass_domain": [], "match_domain": [] } }, // Deprecated "gso": false, "inet4_address": [ "172.19.0.1/30" ], "inet6_address": [ "fdfe:dcba:9876::1/126" ], "inet4_route_address": [ "0.0.0.0/1", "128.0.0.0/1" ], "inet6_route_address": [ "::/1", "8000::/1" ], "inet4_route_exclude_address": [ "192.168.0.0/16" ], "inet6_route_exclude_address": [ "fc00::/7" ], ... // Listen Fields } ``` -------------------------------- ### Tor outbound configuration example Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/outbound/tor.md Example configuration for a Tor outbound proxy. The `type` is set to "tor" and `tag` to "tor-out". It specifies the executable path, extra arguments, data directory, and torrc options. The `... // Dial Fields` placeholder indicates where shared dial fields can be added. ```json { "type": "tor", "tag": "tor-out", "executable_path": "/usr/bin/tor", "extra_args": [], "data_directory": "$HOME/.cache/tor", "torrc": { "ClientOnly": 1 }, ... // Dial Fields } ``` -------------------------------- ### ShadowTLS outbound configuration Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/outbound/shadowtls.md Example configuration for a ShadowTLS outbound. The `server`, `server_port`, and `tls` fields are required; `version` defaults to 1 and `password` is only available in v2/v3. Additional Dial Fields can be appended. ```json { "type": "shadowtls", "tag": "st-out", "server": "127.0.0.1", "server_port": 1080, "version": 3, "password": "fuck me till the daylight", "tls": {}, ... // Dial Fields } ``` -------------------------------- ### Headless Rule JSON Structure Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/rule-set/headless-rule.md Example of a headless rule configuration in sing-box. It shows the available fields for matching DNS queries, network traffic, domains, IPs, ports, processes, and network conditions. The 'invert' field inverts the match result, and the 'logical' type with 'and'/'or' mode allows combining rules. ```json { "rules": [ { "query_type": [ "A", "HTTPS", 32768 ], "network": [ "tcp" ], "domain": [ "test.com" ], "domain_suffix": [ ".cn" ], "domain_keyword": [ "test" ], "domain_regex": [ "^stun\\..+" ], "source_ip_cidr": [ "10.0.0.0/24", "192.168.0.1" ], "ip_cidr": [ "10.0.0.0/24", "192.168.0.1" ], "source_port": [ 12345 ], "source_port_range": [ "1000:2000", ":3000", "4000:" ], "port": [ 80, 443 ], "port_range": [ "1000:2000", ":3000", "4000:" ], "process_name": [ "curl" ], "process_path": [ "/usr/bin/curl" ], "process_path_regex": [ "^/usr/bin/.+" ], "package_name": [ "com.termux" ], "network_type": [ "wifi" ], "network_is_expensive": false, "network_is_constrained": false, "wifi_ssid": [ "My WIFI" ], "wifi_bssid": [ "00:00:00:00:00:00" ], "invert": false }, { "type": "logical", "mode": "and", "rules": [], "invert": false } ] } ``` -------------------------------- ### Run reproducible contract checks for consumers Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/amnezia/consumer.md Runs the consumer fixture checks provided by the fork, one for remote replacement and one for submodule-based consumption. Both pass a release tag and expected commit SHA, and do not start a tunnel or require an OS TUN device. ```sh python3 scripts/amnezia/check_consumer.py remote --ref "$tag" --expected-sha "$sha" python3 scripts/amnezia/check_consumer.py submodule --ref "$tag" --expected-sha "$sha" ``` -------------------------------- ### MagicDNS only Tailscale DNS Configuration Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/dns/server/tailscale.md Configures Tailscale DNS as the only resolver for all queries by using a rule with ip_accept_any set to true and server set to the Tailscale server tag. This is the 'MagicDNS only' example. ```json { "dns": { "servers": [ { "type": "local", "tag": "local" }, { "type": "tailscale", "tag": "ts", "endpoint": "ts-ep" } ], "rules": [ { "ip_accept_any": true, "server": "ts" } ] } } ``` -------------------------------- ### VMess Outbound Configuration Structure Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/outbound/vmess.md Example configuration for a VMess outbound. Shows required fields (server, server_port, uuid) and optional settings like security, alter_id, network, tls, packet_encoding, transport, and multiplex. The '... // Dial Fields' placeholder indicates additional dial fields are available. ```json { "type": "vmess", "tag": "vmess-out", "server": "127.0.0.1", "server_port": 1080, "uuid": "bf000d23-0752-40b4-affe-68f7707a9661", "security": "auto", "alter_id": 0, "global_padding": false, "authenticated_length": true, "network": "tcp", "tls": {}, "packet_encoding": "", "transport": {}, "multiplex": {}, ... // Dial Fields } ``` -------------------------------- ### VMess Inbound Configuration Structure Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/inbound/vmess.md Example configuration for a VMess inbound. The `users` array defines a single user with a name, UUID, and alterId. The `tls`, `multiplex`, and `transport` fields are placeholders for their respective configurations. ```json { "type": "vmess", "tag": "vmess-in", ... // Listen Fields "users": [ { "name": "sekai", "uuid": "bf000d23-0752-40b4-affe-68f7707a9661", "alterId": 0 } ], "tls": {}, "multiplex": {}, "transport": {} } ``` -------------------------------- ### AnyTLS Outbound Configuration Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/outbound/anytls.md Example configuration for an AnyTLS outbound in sing-box. The `type` is set to `anytls`, with a tag `anytls-out`, server address and port, password, idle session settings, and a TLS object. The `... // Dial Fields` placeholder indicates additional dial fields can be added. ```json { "type": "anytls", "tag": "anytls-out", "server": "127.0.0.1", "server_port": 1080, "password": "8JCsPssfgS8tiRwiMlhARg==", "idle_session_check_interval": "30s", "idle_session_timeout": "30s", "min_idle_session": 5, "tls": {}, ... // Dial Fields } ``` -------------------------------- ### SSH outbound configuration structure Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/outbound/ssh.md Example SSH outbound configuration. The `server` field is required; `server_port` defaults to 22, `user` to root, and `client_version` to a random version if empty. `host_key` accepts any host key if empty. The `... // Dial Fields` placeholder indicates additional shared Dial Fields are appended. ```json { "type": "ssh", "tag": "ssh-out", "server": "127.0.0.1", "server_port": 22, "user": "root", "password": "admin", "private_key": "", "private_key_path": "$HOME/.ssh/id_rsa", "private_key_passphrase": "", "host_key": [ "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdH..." ], "host_key_algorithms": [], "client_version": "SSH-2.0-OpenSSH_7.4p1", ... // Dial Fields } ``` -------------------------------- ### verify_client_url string shorthand Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/service/derp.md Equivalent configuration when setting verify_client_url to a string __URL__. ```json { "url": __URL__ } ``` -------------------------------- ### Custom build with tags using make Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/installation/build-from-source.md Builds sing-box with custom build tags specified via the TAGS environment variable. Replace `tag_a tag_b` with the desired tags. ```bash TAGS="tag_a tag_b" make ``` -------------------------------- ### Custom build with tags using go build Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/installation/build-from-source.md Builds sing-box with custom build tags using the Go toolchain directly. Replace `tag_a tag_b` with the desired tags. ```bash go build -tags "tag_a tag_b" ./cmd/sing-box ``` -------------------------------- ### Build and test Amnezia with Makefile.amnezia Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/amnezia/build.md Run from the source root with Go 1.25.5 on PATH. The wrapper sets GOTOOLCHAIN=local and GOWORK=off, so it uses the selected toolchain and checked-in modules. Use GO=/path/to/go to select another Go executable explicitly; mobile builds also need that toolchain's bin directory on PATH. ```sh make -f Makefile.amnezia version make -f Makefile.amnezia build bin/amnezia-box version make -f Makefile.amnezia test ``` -------------------------------- ### Format and write sing-box config (Bash) Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/index.md Formats the configuration file specified by '-c' and the configuration directory specified by '-D', then writes the result back with '-w'. The command exits with an error if the config is invalid. ```bash sing-box format -w -c config.json -D config_directory ``` -------------------------------- ### Trojan inbound JSON structure Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/inbound/trojan.md Example configuration for a Trojan inbound listener with a user, TLS settings, fallback servers, and optional multiplex/transport. The fallback and fallback_for_alpn fields are disabled when empty. ```json { "type": "trojan", "tag": "trojan-in", ... // Listen Fields "users": [ { "name": "sekai", "password": "8JCsPssfgS8tiRwiMlhARg==" } ], "tls": {}, "fallback": { "server": "127.0.0.1", "server_port": 8080 }, "fallback_for_alpn": { "http/1.1": { "server": "127.0.0.1", "server_port": 8081 } }, "multiplex": {}, "transport": {} } ``` -------------------------------- ### Create and push an RC tag after preflight Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/amnezia/release.md Fetch the dev branch without upstream tags, record the reviewed SHA, run the release preflight, then create an annotated tag and push only that tag through the github-anon SSH alias. Replace FULL_REVIEWED_DEV_SHA with the actual 40-character commit hash; preflight must succeed before tag creation. ```sh git fetch --no-tags origin dev git log -1 --format='%H %s' FETCH_HEAD readonly RC_SHA=FULL_REVIEWED_DEV_SHA readonly RC_TAG=v1.260910.0-rc.1 git checkout --detach "$RC_SHA" python3 -B scripts/amnezia/release_preflight.py \ --sha "$RC_SHA" --tag "$RC_TAG" \ --output "/tmp/${RC_TAG}-preflight.json" ``` ```sh git -c user.name=FrogRocky \ -c user.email=269552296+FrogRocky@users.noreply.github.com \ -c tag.gpgSign=false tag -a "$RC_TAG" "$RC_SHA" -m "Amnezia $RC_TAG" git push git@github-anon:amnezia-vpn/amnezia-box.git \ "refs/tags/$RC_TAG:refs/tags/$RC_TAG" ``` -------------------------------- ### Build Apple library Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/amnezia/build.md Build the Apple library for iOS, tvOS, and macOS. The default output is bin/Libbox.xcframework. ```sh make -f Makefile.amnezia lib_apple VERSION=v1.260910.0 ``` ```sh make -f Makefile.amnezia lib_apple LIB_TARGET=ios OUTPUT=/tmp/Libbox.xcframework ``` -------------------------------- ### SOCKS Outbound JSON Configuration Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/outbound/socks.md Example configuration for a SOCKS outbound with server 127.0.0.1:1080, version 5, username/password, UDP network, and udp_over_tcp disabled. The '...' represents additional Dial Fields. ```json { "type": "socks", "tag": "socks-out", "server": "127.0.0.1", "server_port": 1080, "version": "5", "username": "sekai", "password": "admin", "network": "udp", "udp_over_tcp": false | {}, ... // Dial Fields } ``` -------------------------------- ### DNS over QUIC (DoQ) server configuration structure Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/dns/server/quic.md Shows the JSON structure for configuring a DNS over QUIC (DoQ) server in sing-box. The `type` field is set to `quic`, and the `server` field is required. The `server_port` defaults to 853, and `tls` is a TLS configuration object. Dial Fields are included as a placeholder. ```json { "dns": { "servers": [ { "type": "quic", "tag": "", "server": "", "server_port": 853, "tls": {}, // Dial Fields } ] } } ``` -------------------------------- ### TCP DNS Server JSON Structure Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/dns/server/tcp.md Example configuration for a TCP DNS server. The 'server' field is required; 'server_port' defaults to 53. The 'tag' field is optional. Dial Fields can be added as needed. ```json { "dns": { "servers": [ { "type": "tcp", "tag": "", "server": "", "server_port": 53, // Dial Fields } ] } } ``` -------------------------------- ### Run sing-box config check (Bash) Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/index.md Validates the current configuration. Running 'sing-box check' in a directory with a configuration file will verify its syntax and output any errors. ```bash sing-box check ``` -------------------------------- ### Hysteria2 Inbound JSON Structure Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/inbound/hysteria2.md Example configuration for a Hysteria2 inbound listener. Includes listen fields, bandwidth limits, obfuscation, users, TLS, and masquerade settings. Note that 'tls' is required and 'masquerade' can be a string or object. ```json { "type": "hysteria2", "tag": "hy2-in", ... // Listen Fields "up_mbps": 100, "down_mbps": 100, "obfs": { "type": "salamander", "password": "cry_me_a_r1ver" }, "users": [ { "name": "tobyxdd", "password": "goofy_ahh_password" } ], "ignore_client_bandwidth": false, "tls": {}, "masquerade": "", // or {} "brutal_debug": false } ``` -------------------------------- ### Hysteria2 server with local certificate Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/manual/proxy-protocol/hysteria2.md Use this configuration when you have your own certificate and key files. Replace `up_mbps` and `down_mbps` with your server's actual bandwidth, and set the correct paths for `key_path` and `certificate_path`. ```json { "inbounds": [ { "type": "hysteria2", "listen": "::", "listen_port": 8080, "up_mbps": 100, "down_mbps": 100, "users": [ { "name": "sekai", "password": "" } ], "tls": { "enabled": true, "server_name": "example.org", "key_path": "/path/to/key.pem", "certificate_path": "/path/to/certificate.pem" } } ] } ``` -------------------------------- ### DNS Configuration Structure Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/dns/index.md Shows the full DNS configuration structure with all available fields and their default values. Use as a template when configuring the DNS section in sing-box. ```json { "dns": { "servers": [], "rules": [], "final": "", "strategy": "", "disable_cache": false, "disable_expire": false, "independent_cache": false, "cache_capacity": 0, "reverse_mapping": false, "client_subnet": "", "fakeip": {} } } ``` -------------------------------- ### Experimental Configuration Structure Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/experimental/index.md Shows the top-level structure of the experimental configuration object, which contains three optional fields: cache_file, clash_api, and v2ray_api. Each field is an object that can be further configured as described in the linked documentation. ```json { "experimental": { "cache_file": {}, "clash_api": {}, "v2ray_api": {} } } ``` -------------------------------- ### VLESS inbound configuration Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/inbound/vless.md Example configuration for a VLESS inbound. The `users` array is required and must contain at least one user with a `uuid`. The `flow` field is optional and can be set to `xtls-rprx-vision`. The `tls`, `multiplex`, and `transport` fields are optional and refer to shared configurations. ```json { "type": "vless", "tag": "vless-in", ... // Listen Fields "users": [ { "name": "sekai", "uuid": "bf000d23-0752-40b4-affe-68f7707a9661", "flow": "" } ], "tls": {}, "multiplex": {}, "transport": {} } ``` -------------------------------- ### Stable tag publication and verification commands Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/amnezia/release.md Run these commands after recording the new STABLE_SHA to perform preflight, create an annotated tag, push it, and verify consumer checks. The preflight script is invoked with the stable tag and SHA; the tag is created with the FrogRocky identity and pushed to the amnezia-box repository. Consumer checks are run for both remote and submodule modes. ```sh git fetch --no-tags origin master git log -1 --format='%H %s' FETCH_HEAD readonly STABLE_SHA=FULL_REVIEWED_MASTER_MERGE_SHA readonly STABLE_TAG=v1.260910.0 git checkout --detach "$STABLE_SHA" python3 -B scripts/amnezia/release_preflight.py \ --sha "$STABLE_SHA" --tag "$STABLE_TAG" \ --output "/tmp/${STABLE_TAG}-preflight.json" git -c user.name=FrogRocky \ -c user.email=269552296+FrogRocky@users.noreply.github.com \ -c tag.gpgSign=false tag -a "$STABLE_TAG" "$STABLE_SHA" -m "Amnezia $STABLE_TAG" git push git@github-anon:amnezia-vpn/amnezia-box.git \ "refs/tags/$STABLE_TAG:refs/tags/$STABLE_TAG" python3 -B scripts/amnezia/check_consumer.py remote \ --ref "$STABLE_TAG" --expected-sha "$STABLE_SHA" python3 -B scripts/amnezia/check_consumer.py submodule \ --ref "$STABLE_TAG" --expected-sha "$STABLE_SHA" ``` -------------------------------- ### stun number shorthand Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/service/derp.md Equivalent configuration when setting stun to a number __PORT__. ```json { "enabled": true, "listen_port": __PORT__ } ``` -------------------------------- ### Basic resolved DNS server configuration Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/dns/server/resolved.md Shows the minimal configuration for a resolved DNS server, including the required 'service' field and the optional 'accept_default_resolvers' field. ```json { "dns": { "servers": [ { "type": "resolved", "tag": "", "service": "resolved", "accept_default_resolvers": false } ] } } ``` -------------------------------- ### TUIC Outbound Configuration Structure Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/outbound/tuic.md Example JSON structure showing the TUIC outbound configuration with required and optional fields. Some fields like 'tls' are required, while others like 'password' and 'congestion_control' have defaults or are optional. Network defaults to both tcp and udp if not specified. Conflicts exist between udp_relay_mode and udp_over_stream. ```json { "type": "tuic", "tag": "tuic-out", "server": "127.0.0.1", "server_port": 1080, "uuid": "2DD61D93-75D8-4DA4-AC0E-6AECE7EAC365", "password": "hello", "congestion_control": "cubic", "udp_relay_mode": "native", "udp_over_stream": false, "zero_rtt_handshake": false, "heartbeat": "10s", "network": "tcp", "tls": {}, ... // Dial Fields } ``` -------------------------------- ### Hysteria2 Outbound JSON Configuration Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/outbound/hysteria2.md Example configuration for a Hysteria2 outbound in sing-box. The 'server' and 'server_port' fields are required, while 'server_ports' can be used instead of 'server_port' for a port range. The 'tls' field is required. Note that the official Hysteria2 userpass authentication is not supported; use ':' as the password instead. ```json { "type": "hysteria2", "tag": "hy2-out", "server": "127.0.0.1", "server_port": 1080, "server_ports": [ "2080:3000" ], "hop_interval": "", "up_mbps": 100, "down_mbps": 100, "obfs": { "type": "salamander", "password": "cry_me_a_r1ver" }, "password": "goofy_ahh_password", "network": "tcp", "tls": {}, "brutal_debug": false, ... // Dial Fields } ``` -------------------------------- ### Run focused tests with TEST_PACKAGES and TEST_ARGS Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/amnezia/build.md Focus package tests or add race detection by setting TEST_PACKAGES and TEST_ARGS. The test target also runs the version helper's temporary-Git integration fixtures. Overriding TEST_TAGS replaces its default; retain with_conntrack for relevant tests. ```sh make -f Makefile.amnezia test TEST_PACKAGES='./transport/awg ./protocol/awg' TEST_ARGS=-race ``` -------------------------------- ### Generate WireGuard keys with wg(8) Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/endpoint/wireguard.md Generates a WireGuard private key and then derives the corresponding public key. The `wg(8)` utility is required; alternatively, `sing-box generate wg-keypair` can be used. ```shell wg genkey echo "private key" || wg pubkey ``` -------------------------------- ### Trojan client with valid certificate Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/manual/proxy-protocol/trojan.md Use this configuration when the server presents a valid certificate signed by a trusted CA. It enables TLS with server_name 'example.org', uTLS fingerprint 'firefox', and multiplexing. ```json { "outbounds": [ { "type": "trojan", "server": "127.0.0.1", "server_port": 8080, "password": "password", "tls": { "enabled": true, "server_name": "example.org", "utls": { "enabled": true, "fingerprint": "firefox" } }, "multiplex": { "enabled": true } } ] } ``` -------------------------------- ### gRPC Transport Configuration Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/shared/v2ray-transport.md gRPC transport configuration. Standard gRPC has good compatibility but poor performance and is not included by default (see Installation build tags). service_name is the service name of gRPC. idle_timeout and ping_timeout have different behaviors in standard vs default gRPC. permit_without_stream is disabled by default and controls keepalive pings when no active connections exist. ```json { "type": "grpc", "service_name": "TunService", "idle_timeout": "15s", "ping_timeout": "15s", "permit_without_stream": false } ``` -------------------------------- ### Legacy DNS server configuration structure Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/dns/server/legacy.md Shows the JSON structure for configuring a legacy DNS server in sing-box. All fields are optional except 'address'. The 'address' field supports various protocols like System, TCP, UDP, TLS, HTTPS, QUIC, HTTP3, RCode, DHCP, and FakeIP. ```json { "dns": { "servers": [ { "tag": "", "address": "", "address_resolver": "", "address_strategy": "", "strategy": "", "detour": "", "client_subnet": "" } ] } } ``` -------------------------------- ### DNS rule structure with all fields Source: https://github.com/amnezia-vpn/amnezia-box/blob/master/docs/configuration/dns/rule.md Shows the full DNS rule structure with all available fields, including deprecated ones. The second rule demonstrates a logical rule with type 'logical' and mode 'and'. Note that the JSON Array [] tag can be ignored when the content is only one item. ```json { "dns": { "rules": [ { "inbound": [ "mixed-in" ], "ip_version": 6, "query_type": [ "A", "HTTPS", 32768 ], "network": "tcp", "auth_user": [ "usera", "userb" ], "protocol": [ "tls", "http", "quic" ], "domain": [ "test.com" ], "domain_suffix": [ ".cn" ], "domain_keyword": [ "test" ], "domain_regex": [ "^stun\\..+" ], "source_ip_cidr": [ "10.0.0.0/24", "192.168.0.1" ], "source_ip_is_private": false, "ip_cidr": [ "10.0.0.0/24", "192.168.0.1" ], "ip_is_private": false, "ip_accept_any": false, "source_port": [ 12345 ], "source_port_range": [ "1000:2000", ":3000", "4000:" ], "port": [ 80, 443 ], "port_range": [ "1000:2000", ":3000", "4000:" ], "process_name": [ "curl" ], "process_path": [ "/usr/bin/curl" ], "process_path_regex": [ "^/usr/bin/.+" ], "package_name": [ "com.termux" ], "user": [ "sekai" ], "user_id": [ 1000 ], "clash_mode": "direct", "network_type": [ "wifi" ], "network_is_expensive": false, "network_is_constrained": false, "wifi_ssid": [ "My WIFI" ], "wifi_bssid": [ "00:00:00:00:00:00" ], "rule_set": [ "geoip-cn", "geosite-cn" ], "rule_set_ip_cidr_match_source": false, "rule_set_ip_cidr_accept_empty": false, "invert": false, "outbound": [ "direct" ], "action": "route", "server": "local", // Deprecated "rule_set_ipcidr_match_source": false, "geosite": [ "cn" ], "source_geoip": [ "private" ], "geoip": [ "cn" ] }, { "type": "logical", "mode": "and", "rules": [], "action": "route", "server": "local" } ] } } ```