Install
openclaw skills install silas-clashClash/Mihomo 代理管理。安装配置、查看状态、切换模式/节点、测速、外网失败时自动代理。
openclaw skills install silas-clash通过 Clash RESTful API 管理本地代理(Mihomo/Clash Meta)。
# 检查架构
uname -m
# 下载对应版本(以 amd64 为例)
curl -Lo /tmp/mihomo.gz https://github.com/MetaCubeX/mihomo/releases/download/v1.19.21/mihomo-linux-amd64-v1.19.21.gz
gunzip /tmp/mihomo.gz
chmod +x /tmp/mihomo
sudo mv /tmp/mihomo /usr/local/bin/mihomo
询问用户订阅地址,然后下载配置:
# 方式一:订阅链接直接下载
curl -Lo ~/.config/mihomo/config.yaml "用户提供的订阅地址"
# 方式二:Clash 仪表盘配置(推荐)
# 访问 https://yacd.haishan.me 或 https://metacubexd.github.io/metacubexd
# 在仪表盘中粘贴订阅地址,自动生成 config.yaml
检查 ~/.config/mihomo/config.yaml 中有:
external-controller: 127.0.0.1:9090
# secret: "你的密码" # 可选,建议空
mihomo -d ~/.config/mihomo
curl -s http://127.0.0.1:9090/version
# 应返回 {"meta":true,"version":"v1.x.x"}
将连接信息保存到 memory/clash-config.json:
{
"api_url": "http://127.0.0.1:9090",
"api_secret": "",
"proxy_http": "http://127.0.0.1:7890",
"proxy_socks5": "socks5://127.0.0.1:7891",
"proxy_all": "socks5://127.0.0.1:7891",
"install_path": "/usr/local/bin/mihomo",
"config_path": "~/.config/mihomo/config.yaml"
}
⚠️ 代理端口(7890/7891)以实际 config.yaml 中的 mixed-port / port 为准。
curl -s http://127.0.0.1:9090/version
curl -s http://127.0.0.1:9090/configs | python3 -c "import json,sys;d=json.load(sys.stdin);print(f\"模式: {d.get('mode')}\")"
curl -s http://127.0.0.1:9090/proxies/%F0%9F%9A%80%20%E8%8A%82%E7%82%B9%E9%80%89%E6%8B%A9 | python3 -c "
import json,sys
d=json.load(sys.stdin)
print(f\"当前节点: {d.get('now','?')}\")
"
# rule(规则分流,推荐日常)
curl -X PATCH http://127.0.0.1:9090/configs -H "Content-Type: application/json" -d '{"mode":"rule"}'
# global(全局代理)
curl -X PATCH http://127.0.0.1:9090/configs -H "Content-Type: application/json" -d '{"mode":"global"}'
# direct(直连)
curl -X PATCH http://127.0.0.1:9090/configs -H "Content-Type: application/json" -d '{"mode":"direct"}'
# 先列出节点名
curl -s http://127.0.0.1:9090/proxies/%F0%9F%9A%80%20%E8%8A%82%E7%82%B9%E9%80%89%E6%8B%A9 | python3 -c "
import json,sys
d=json.load(sys.stdin)
for n in d.get('all',[]): print(n)
"
# 切换到指定节点
curl -X PUT "http://127.0.0.1:9090/proxies/%F0%9F%9A%80%20%E8%8A%82%E7%82%B9%E9%80%89%E6%8B%A9" \
-H "Content-Type: application/json" \
-d '{"name":"节点名称"}'
# 测所有节点
curl -X GET "http://127.0.0.1:9090/group/%F0%9F%9A%80%20%E8%8A%82%E7%82%B9%E9%80%89%E6%8B%A9/delay?timeout=5000&url=https://www.google.com/generate_204"
# 测当前节点
curl -X GET "http://127.0.0.1:9090/proxies/%F0%9F%9A%80%20%E8%8A%82%E7%82%B9%E9%80%89%E6%8B%A9/delay?timeout=5000&url=https://www.google.com/generate_204"
当 web_search / web_fetch / Serper / Tavily 等外网工具失败时:
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890
export all_proxy=socks5://127.0.0.1:7891
⚠️ 订阅更新不要通过技能自动执行,手动操作更安全:
# 备份当前配置
cp ~/.config/mihomo/config.yaml ~/.config/mihomo/config.yaml.bak
# 下载最新订阅
curl -Lo ~/.config/mihomo/config.yaml "订阅地址"
# 重启
pkill mihomo && mihomo -d ~/.config/mihomo
pgrep mihomo),端口是否正确/opt/homebrew/bin/mihomo,其余操作相同