覆写文件(Override)
覆写文件(Override)允许用户修改配置文件的部分字段,常用于修改托管、订阅的配置的内容。Stash 允许同时启用多个覆写文件,会从上到下覆盖了原来配置中。
一个最佳实践是,为了便于单独控制开关和分享,通常以单个功能点划分覆写文件。
语法参考
- 覆写文件使用 YAML 格式,后缀名为
stoverride
; - 通常地,使用
name
与desc
字段作为覆写文件的名称和描述,这两个字段仅用于展示; - 覆写文件对配置文件的修改,采用如下规则:
- 对于简单类型的同名 key,例如 string、number、boolean,会直接覆盖;
- 对于字典类型的同名 key,采用递归按 key 合并;
- 对于数组类型的同名 key,采用覆写文件的数组会插入在配置文件数组的前面。
- 对于字典类型和数组类型的 key 后面新增注释(line comment)
#!replace
,则会采用覆盖方式合并
⚠️
暂时不支持修改数组中的元素,后续会提供其他语法进行修改。
常见的覆写样例:
name: '📺 BiliBili: 🔀 Redirect'
desc: |-
哔哩哔哩:重定向
中国站CDN自定义
openUrl: 'http://boxjs.com/#/app/BiliBili.Redirect'
author: |-
VirgilClyne[https://github.com/VirgilClyne]
homepage: 'https://Redirect.BiliUniverse.io'
icon: 'https://github.com/BiliUniverse/Redirect/raw/main/src/assets/icon_rounded.png'
category: '🪐 BiliUniverse'
date: '2024-12-10 07:13:21'
version: '0.2.12'
http:
force-http-engine:
- '*.bilivideo.cn:80'
- '*.bilivideo.com:80'
- upos-hz-mirrorakam.akamaized.net:80
- '*:4480'
- '*:8000'
- '*:8082'
- '*.mcdn.bilivideo.cn:9102'
mitm:
- '*.bilivideo.cn:443'
- '*.bilivideo.com:443'
- '*.mcdn.bilivideo.com:4483'
- '*.mcdn.bilivideo.cn:4483'
- '*.mcdn.bilivideo.cn:8082'
- '*.mcdn.bilivideo.com:8082'
- 'upos-*-mirrorakam.akamaized.net:443'
script:
- match: ^https?:\/\/.+\.bilivideo\.com\/upgcxcode\/
name: '📺 BiliBili.Redirect.request'
type: request
- match: ^https?:\/\/(.+):(8000|8082)\/v1\/resource\/
name: '📺 BiliBili.Redirect.request'
type: request
argument:
- match: ^https?:\/\/[xy0-9]+\.mcdn\.bilivideo\.(cn|com):(4483|9102)\/upgcxcode\/
name: '📺 BiliBili.Redirect.request'
type: request
argument:
- match: ^https?:\/\/(.+):4480\/upgcxcode\/
name: '📺 BiliBili.Redirect.request'
type: request
argument:
- match: ^https?:\/\/upos-(hz|bstar1)-mirrorakam\.akamaized\.net/upgcxcode\/
name: '📺 BiliBili.Redirect.request'
type: request
argument:
script-providers:
'📺 BiliBili.Redirect.request':
url: https://github.com/BiliUniverse/Redirect/releases/download/v0.2.12/request.bundle.js
interval: 86400
采用了 #!replace
语法的覆写样例:
name: 仅使用 CloudFlare DNS
dns:
# 将会完整覆盖原有 default-nameserver
default-nameserver: #!replace
- system
- 223.5.5.5
- 1.0.0.1
# 将会完整覆盖原有 nameserver
nameserver: #!replace
- https://1.0.0.1/dns-query # CF IPv4
- https://[2606:4700:4700::1111]/dns-query # CF IPv6
下面为一个简单的合并实例:
# 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