silas_clash

Clash/Mihomo 代理管理。安装配置、查看状态、切换模式/节点、测速、外网失败时自动代理。

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "silas_clash" with this command: npx skills add aohoyo/silas-clash

Silas-Clash 代理管理

通过 Clash RESTful API 管理本地代理(Mihomo/Clash Meta)。

首次安装配置

1. 安装 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

2. 获取配置

询问用户订阅地址,然后下载配置:

# 方式一:订阅链接直接下载
curl -Lo ~/.config/mihomo/config.yaml "用户提供的订阅地址"

# 方式二:Clash 仪表盘配置(推荐)
# 访问 https://yacd.haishan.me 或 https://metacubexd.github.io/metacubexd
# 在仪表盘中粘贴订阅地址,自动生成 config.yaml

3. 确保配置开启 API

检查 ~/.config/mihomo/config.yaml 中有:

external-controller: 127.0.0.1:9090
# secret: "你的密码"  # 可选,建议空

4. 启动

mihomo -d ~/.config/mihomo

5. 验证

curl -s http://127.0.0.1:9090/version
# 应返回 {"meta":true,"version":"v1.x.x"}

6. 写入本地配置

将连接信息保存到 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 等外网工具失败时:

  1. 第一次重试:设置环境变量走代理
    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
    
  2. 第二次重试:如果还失败,切换 Clash 为 global 模式重试
  3. 恢复:成功后切回 rule 模式

订阅更新(手动操作)

⚠️ 订阅更新不要通过技能自动执行,手动操作更安全:

# 备份当前配置
cp ~/.config/mihomo/config.yaml ~/.config/mihomo/config.yaml.bak

# 下载最新订阅
curl -Lo ~/.config/mihomo/config.yaml "订阅地址"

# 重启
pkill mihomo && mihomo -d ~/.config/mihomo

踩坑指南

  • 节点名称含特殊字符:URL encode 处理,或先列出节点再选
  • API 无响应:检查 mihomo 是否运行(pgrep mihomo),端口是否正确
  • 测速超时:timeout 设 5000ms,太短会误判
  • 切节点后不生效:部分应用有 DNS 缓存,等几秒或重启应用
  • 订阅更新搞挂网络:先备份再更新,挂了用 bak 恢复
  • rule 模式足够:日常用 rule,只在需要全局代理时临时切 global
  • 代理端口:以 config.yaml 中 mixed-port / port 配置为准,不要硬编码
  • macOS 兼容:安装路径改为 /opt/homebrew/bin/mihomo,其余操作相同

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

Huo15 Openclaw Enhance

火一五·克劳德·龙虾增强插件 v5.7.8 — 全面适配 openclaw 2026.4.24:peerDep ^4.24 + build/compat 同步到 4.24 + 14 处 api.on 全部去掉 as any 改成 typed hook(hookName 联合类型 + handler 自动推断 Pl...

Registry SourceRecently Updated
General

Content Trend Analyzer

Aggregates and analyzes content trends across platforms to identify hot topics, user intent, content gaps, and generates data-driven article outlines.

Registry SourceRecently Updated
General

Prompt Debugger

Debug prompts that produce unexpected AI outputs — diagnose failure modes, identify ambiguity and conflicting instructions, test variations, compare model re...

Registry SourceRecently Updated
General

Indie Maker News

独行者 Daily - 变现雷达。读对一条新闻,少走一年弯路。每天5分钟,给创业者装上商业雷达。聚焦一人公司、副业、创业变现资讯,智能分类,行动导向。用户下载即能用,无需本地部署!

Registry SourceRecently Updated