Configuration
Override

Override

Override allows users to modify certain fields of configuration files, commonly used to modify the content of hosted and subscribed configurations. Stash allows multiple override files to be enabled at the same time, which will override the original configuration from top to bottom.

A best practice is to divide override files into single feature points for easy control and sharing.

Syntax Reference

  • Override files use YAML format with the suffix stoverride.
  • Typically, use the name and desc fields as the name and description of the override file, which are only used for display.
  • The override file modifies the configuration file according to the following rules:
    • For simple types of the same name key, such as string, number, boolean, it will be directly overridden.
    • For dictionary types of the same name key, it will be merged recursively according to the key.
    • For array types of the same name key, the override file's array will be inserted at the beginning of the configuration file array.
    • For dictionary and array type keys with the line comment #!replace added at the end, it will be merged by overriding.
⚠️

Modifying elements in an array is not supported at this time. Other syntax will be provided for modification in the future.

Common override examples:

name: Redirect BiliBili MCDN / PCDN to Regular CDN
desc: Loading smoother BiliBili is worth a toast 🍻!
 
http:
  force-http-engine:
    - 'upos-*.bilivideo.com:80'
    - '*:4480'
    - '*:9102'
  url-rewrite:
    - https?:\/\/(.*):4480\/upgcxcode http://upos-sz-mirrorcos.bilivideo.com/upgcxcode 302
    - https?:\/\/(.*):9102\/upgcxcode http://upos-sz-mirrorcos.bilivideo.com/upgcxcode 302
    - https?:\/\/upos-.*-.*oss\d*\.bilivideo\.com\/upgcxcode http://upos-sz-mirrorcos.bilivideo.com/upgcxcode 302
    - https?:\/\/upos-sz-mirror(?!cos\.).*bilivideo\.com\/upgcxcode http://upos-sz-mirrorcos.bilivideo.com/upgcxcode 302
    # alternative:
    # upos-sz-mirrorhw.bilivideo.com
    # upos-sz-mirrorcos.bilivideo.com
    # upos-sz-mirrorcoso1.bilivideo.com
    # upos-sz-mirrorcoso2.bilivideo.com
    # upos-sz-mirrorbs.bilivideo.com
    # upos-sz-mirrorali.bilivideo.com
script:
  shortcuts:
    bilibili-quic: network == 'udp' and geoip(dst_ip) == 'CN' and dst_port == 3478
rules:
  - SCRIPT,bilibili-quic,REJECT

Override example using #!replace syntax:

name: Use Only CloudFlare DNS
dns:
  # Will completely replace the original default-nameserver
  default-nameserver: #!replace
    - system
    - 223.5.5.5
    - 1.0.0.1
  # Will completely replace the original nameserver
  nameserver: #!replace
    - https://1.0.0.1/dns-query # CF IPv4
    - https://[2606:4700:4700::1111]/dns-query # CF IPv6

Here is a simple merge example:

# config.yaml
dict:
  k1: true
  k2: 1
  k3:
    - 1
    - 2
    - 3
  k4:
    - 1
    - 2
    - 3
# override file
key: value
dict:
  k3:
    - 0
  k4: #!replace
    - 1
  k5: null
# after override
key: value
dict:
  k1: true
  k2: 1
  k3:
    - 0
    - 1
    - 2
    - 3
  k4:
    - 1
  k5: null

Override Hub

Stash has a built-in list of override files that users can browse and install within the Stash app. If you have also written an override file and want to share your configuration with the community, please modify the source.json file and submit a pull request to STASH-NETWORKS-LIMITED/stoverride-list (opens in a new tab).

⚠️

This list is maintained by the community and does not represent the position of Stash Network Limited. Users should carefully review the content of any override file before using it, as malicious override files may damage your device and cause financial loss. Stash Network Limited is not responsible for any of its functionality or security.

If you believe that any content that should not appear in this list, please contact [email protected].