clash-meta-proxy
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseClash-Meta 配置更新
Update Clash-Meta Configuration
更新服务器的 clash-meta 代理配置。
Update the clash-meta proxy configuration on the server.
环境信息
Environment Information
- 默认工作目录:
./ - 现配置文件:
config.yaml - 新代理配置:
.proxies.yaml
- Default Working Directory:
./ - Current Configuration File:
config.yaml - New Proxy Configuration:
.proxies.yaml
使用脚本自动化(推荐)
Automated Script Usage (Recommended)
提供 PEP 723 内联元数据脚本,支持 直接运行,无需手动安装依赖。
uv runA script with PEP 723 inline metadata is provided, supporting direct execution via without manual dependency installation.
uv run运行方式
Execution Methods
方式一:直接运行(推荐)
bash
undefinedMethod 1: Direct Execution (Recommended)
bash
undefinedIn the work_dir
In the work_dir
uv run scripts/update_clash_config.py
**方式二:指定工作目录运行**
```bash
uv run --cwd ./ scripts/update_clash_config.py脚本自动完成:
- 文件备份(+ 时间戳备份 +
config.yaml.bak)config.yaml.editing - 读取 并完整覆盖
.proxies.yamlproxies - 核验 ,注释失效代理
proxy-groups - 生成 diff 到控制台和
.update.diff
uv run scripts/update_clash_config.py
**Method 2: Execute with Specified Working Directory**
```bash
uv run --cwd ./ scripts/update_clash_config.pyThe script automatically performs the following:
- File backup (creates , timestamped backup, and
config.yaml.bak)config.yaml.editing - Reads and fully overwrites the
.proxies.yamlsectionproxies - Verifies and comments out invalid proxies
proxy-groups - Generates a diff output to the console and file
.update.diff
人工确认与生效(关键步骤)
Manual Confirmation and Activation (Critical Step)
脚本不会自动重命名文件,需人工确认后执行:
- 检查 diff 输出
bash
cat ./.update.diff- 确认无误后生效
bash
mv ./config.yaml.editing ./config.yamlThe script will not automatically rename files; manual confirmation is required before execution:
- Check Diff Output
bash
cat ./.update.diff- Activate After Confirmation
bash
mv ./config.yaml.editing ./config.yaml手动操作流程
Manual Operation Process
若脚本无法使用,按以下步骤手动操作:
-
备份配置
- 复制 为
config.yamlconfig.yaml.bak - 复制 为
config.yamlconfig.yaml.editing
- 复制
-
更新 proxies 配置
- 读取 获取新代理节点
.proxies.yaml - 用新代理列表完整覆盖 中的
config.yaml.editing字段proxies
- 读取
-
核验 proxy-groups
- 检查 引用的 name 是否存在于
proxy-groups[*].proxies列表proxies - 若发现失效代理,注释掉而非删除
- 检查
-
diff 确认并重命名
- 执行 对比
diff config.yaml.bak config.yaml.editing - 确认无误后,将 重命名为
config.yaml.editingconfig.yaml
- 执行
If the script cannot be used, follow these steps manually:
-
Backup Configuration
- Copy to
config.yamlconfig.yaml.bak - Copy to
config.yamlconfig.yaml.editing
- Copy
-
Update Proxies Configuration
- Read to obtain new proxy nodes
.proxies.yaml - Fully overwrite the field in
proxieswith the new proxy listconfig.yaml.editing
- Read
-
Verify Proxy-Groups
- Check if the names referenced in exist in the
proxy-groups[*].proxieslistproxies - Comment out invalid proxies instead of deleting them
- Check if the names referenced in
-
Diff Confirmation and Rename
- Execute to compare changes
diff config.yaml.bak config.yaml.editing - After confirmation, rename to
config.yaml.editingconfig.yaml
- Execute
配置示例
Configuration Examples
.proxies.yaml 结构
.proxies.yaml Structure
yaml
proxies:
- name: hy2.node.proxychain.top
type: hysteria2
server: IP
port: PORT
password: PASSWORD
sni: hy2.node.proxychain.top
skip-cert-verify: falseyaml
proxies:
- name: hy2.node.proxychain.top
type: hysteria2
server: IP
port: PORT
password: PASSWORD
sni: hy2.node.proxychain.top
skip-cert-verify: falseproxy-groups 结构
Proxy-Groups Structure
yaml
proxy-groups:
- name: G-SELECT
type: select
proxies:
# - 失效节点名 # 已失效,需注释
- hy2.node.proxychain.top # 有效节点yaml
proxy-groups:
- name: G-SELECT
type: select
proxies:
# - 失效节点名 # 已失效,需注释
- hy2.node.proxychain.top # 有效节点注意事项
Notes
- 引用的 name 必须与
proxy-groups[*].proxies严格对应proxies[*].name - 仅注释失效代理名,保留配置结构完整
- 始终保留 以便回滚
config.yaml.bak - 最终重命名操作必须由人工确认后执行
- The names referenced in must strictly match
proxy-groups[*].proxiesproxies[*].name - Only comment out invalid proxy names; keep the configuration structure intact
- Always retain for rollback purposes
config.yaml.bak - The final rename operation must be performed manually after confirmation