10.3 Mihomo(Clash)
mihomo
mihomo 在 ports 中就有提供。
安装 mihomo
使用 pkg 安装:
# pkg install net/mihomo或者使用 Ports 安装:
# cd /usr/ports/net/mihomo/
# make install clean如果觉得麻烦可以在 Linux 兼容层中使用,FreeBSD 网络一样可受其控制。
未竟事宜
我们需要有一个 RC 脚本以及一款 GUI 程序来做代理!如果你会请 RP!
Clash for FreeBSD
目前该项目不支持某些订阅类型,会报错:
判断订阅内容是否符合clash配置文件标准:
解码后的内容不符合clash标准,尝试将其转换为标准格式
ELF binary type "0" not known.
配置文件转换标准格式失败如果你遇到了类似问题,请使用其他解决方案。
下载项目
$ git clone https://github.com/wenyinos/clash-for-freebsd启动程序
直接运行脚本文件 start.sh
进入项目目录
$ cd clash-for-freebsd
$ chmod +x start.sh shutdown.sh restart.sh编辑
.env文件,修改变量CLASH_URL的值(即把你的 Clash 订阅链接放进去)。
$ ee .env注意:
.env文件中的变量CLASH_SECRET为自定义 Clash 的 Secret,当值为空时,脚本将自动生成随机字符串。
安装并将 bash 设置为 root 用户及当前登录用户的 shell。请参照其他文章。
运行启动脚本
# bash start.sh
正在检测订阅地址...
Clash订阅地址可访问! [ OK ]
正在下载Clash配置文件...
配置文件config.yaml下载成功! [ OK ]
正在启动Clash服务...
服务启动成功! [ OK ]
Clash Dashboard 访问地址:http://<ip>:9090/ui
Secret:xxxxxxxxxxxxx
请执行以下命令加载环境变量: source /etc/profile.d/clash.sh
请执行以下命令开启系统代理: proxy_on
若要临时关闭系统代理,请执行: proxy_off
加载环境变量并启用系统代理
$ source /etc/profile.d/clash.sh
$ proxy_on检查服务端口
# sockstat -l | egrep '9090|789'
root clash-free 2706 7 tcp46 *:9090 *:*
root clash-free 2706 8 tcp46 *:7890 *:*
root clash-free 2706 9 tcp46 *:7891 *:*
root clash-free 2706 10 udp46 *:7891 *:*
root clash-free 2706 11 tcp46 *:7892 *:*
root clash-free 2706 12 udp46 *:7892 *:*检查环境变量
$ env | grep -E 'http_proxy|https_proxy'
http_proxy=http://127.0.0.1:7890
https_proxy=http://127.0.0.1:7890以上步骤如果你的输出类似,且可访问谷歌,说明 clash 程序启动成功。
重启程序
如果需要对 Clash 配置进行修改,请修改 conf/config.yaml 文件。然后运行 restart.sh 脚本进行重启。
注意:
重启脚本
restart.sh不会更新订阅信息。
访问 web 端
访问 http://127.0.0.1:9090/ui 在网页中输入上面输出的 Secret 值即可。
停止程序
进入项目目录
$ cd clash-for-freebsd关闭服务
# bash shutdown.sh
服务关闭成功,请执行以下命令关闭系统代理:`proxy_off`
$ proxy_off然后检查程序端口、进程以及环境变量 http_proxy|https_proxy,若均不存在则说明服务正常关闭。
参考资料
未竟事宜
需要更新支持所有类型的订阅链接。
与 bash 解耦合,支持默认的 sh。
最后更新于
这有帮助吗?