通过代理更新 Clash 配置的网络资源, 所以前提是可以翻墙后, 再使用该工具。通常是有一个可以翻墙的 Clash 配置, 再使用该工具。
写这个工具的原因:
- Clash 更新这些资源是不走代理的。
- [Feature] 让providers可以通过代理来更新
- windows11 error
- [Feature] rule-providers 和 proxy-providers 能不能提供选择直连或代理选项
太多以上的之类的问题了。
我写的一个 clash-auto 可以通过自身代理来更新 Clash 配置依赖的资源。
平台: Linux/Windows
依赖:
pip install ruamel.yaml requests
git clone https://github.com/JohanChane/update-clash-resources.git --depth 1
cd update-clash-resources/update_clashcfg_res
python ./update_clashcfg_res.py -h
更新 Windows 平台的 Clash for Windows 的配置:
# 更新 list 所选的配置的资源。当加载出错时,list 的 index 会是 -1,所以要在没有出错前,运行该程序。
update_clashcfg_res.py -d 'C:/Users/johan/.config/clash' -p 'C:/Users/johan/.config/clash/profiles' -P 'https://127.0.0.1:7890' --is-cfw -n 'config.yaml' -r
更新 Linux 平台的 Clash 的配置:
update_clashcfg_res.py -d ~/.config/clash -p ~/.config/clash -P 'https://127.0.0.1:7890' -n 'config.yaml' -r
update_clashcfg_res.py -d ~/.config/clash -p ~/.config/clash -P 'https://127.0.0.1:7890' -n 'config.yaml' -u '<url>' -r
update_clashcfg_res.py -d ~/.config/clash -p ~/.config/clash -P 'https://127.0.0.1:7890' -n 'config.yaml' -u '$(cat ~/.config/clash_tun/config_url)' -r
更新 Linux 平台的 Clash Tun 的配置:
# 将更新的文件安装到 tun_dir
update_clashcfg_res.py -d 'C:/Users/johan/.config/clash' -n 'myconfig' -P 'https://127.0.0.1:7890' -T '/srv/clash' -r
使用 SubConverter Host (订阅转换的后端地址): 如果发现 url 的内容不是 Clash 的配置, 则使用订阅转换。
update_clashcfg_res.py -d 'C:/Users/johan/.config/clash' -n 'myconfig' -P 'https://127.0.0.1:7890' -H 'sub.xeton.dev' -r
该脚本的作用: 使用 update_clashcfg_res
时需要输入太多的参数, 而通常每次参数都是一样的, 所以可以在该脚本可以设置一些自己常用的参数。
是会使用 cfg_dir
的默认位置更新资源。
# In Linux
./my_up_clashcfg_res.py -n config.yaml -r
# In Windows
python ./my_up_clashcfg_res.py -n config.yaml -r
如果参数有空格:
# In PowerShell
python ./my_up_clashcfg_res.py -n '\"my config\"' -r