GithubHelp home page GithubHelp logo

morytyann / openwrt-mihomo Goto Github PK

View Code? Open in Web Editor NEW
66.0 2.0 18.0 314 KB

A project contains mihomo packages for OpenWrt.

License: MIT License

Makefile 4.47% JavaScript 41.78% Shell 53.75%
mihomo openwrt proxy

openwrt-mihomo's Introduction

GitHub License GitHub Actions Workflow Status GitHub Actions Workflow Status GitHub Tag GitHub Downloads (all assets, all releases) GitHub Repo stars

OpenWrt-mihomo

A project contains mihomo packages for OpenWrt.

Feature

  • Transparent Proxy (TPROXY/TUN, IPv4 and/or IPv6)
  • Access Control
  • Compatible with Multiple WAN
  • Profile Mixin
  • Profile Editor
  • Scheduled Restart

Usage

See Wiki

How does it work

  1. Mixin and Update profile.
  2. Run mihomo.
  3. Run hijack prepare script.
  4. Add exclusions. (wan/wan6 inbound, firewall rule/redirect, UPnP)
  5. Add router hijack.
  6. Add lan hijack with access control.
  7. Set scheduled restart.

Note that the steps above may change base on config.

Compilation

# add mihomo feeds
echo "src-git mihomo https://github.com/morytyann/OpenWrt-mihomo.git;main" >> "feeds.conf.default"
# update & install feeds
./scripts/feeds update -a
./scripts/feeds install -a
# make package
make package/luci-app-mihomo/compile

The ipk file will be found under bin/packages/your_architecture/mihomo.

Dependencies

  • ca-bundle
  • curl
  • inotifywait
  • yq
  • firewall4
  • kmod-nft-tproxy
  • ip-full
  • kmod-tun

Warning

  • Only support firewall4 and will never support firewall3

openwrt-mihomo's People

Contributors

morytyann avatar h2295 avatar johnsonran avatar pmkol avatar

Stargazers

 avatar  avatar Armin avatar Kitsune2077 avatar  avatar f8f5t avatar  avatar ROWAN avatar Albert Leng avatar ade nafil firmansah avatar Malik Al avatar 悠 avatar  avatar  avatar zouyq avatar  avatar wnnnb avatar  avatar 侑 avatar  avatar Sherry avatar  avatar  avatar ling avatar  avatar qimo avatar  avatar  avatar  avatar maddie avatar FbiGun Deo avatar Zutzo avatar Keithmeum avatar  avatar  avatar  avatar  avatar  avatar  avatar Mr.Zhou avatar m0eak avatar 钟莫道 avatar  avatar ForestL avatar XTX avatar  avatar Nin avatar  avatar love4taylor avatar cnthunder avatar  avatar  avatar  avatar  avatar  avatar Ryze avatar  avatar 巷子里的猫 avatar  avatar windy avatar 佐世保时雨 avatar 夜雪痕 avatar 可莉 avatar  avatar KAYO Lee avatar  avatar

Watchers

 avatar Mr.Zhou avatar

openwrt-mihomo's Issues

文件预下载问题

看到规则有很大变化,而且文件下载的名称貌似也发生了变化,请问新的规则文件会下载到哪里,以及几个规则文件的命名是什么?

[BUG] proxy-providers 连接本地服务器超时

在 proxy-providers 里使用本地的代理集出现无法更新,格式:http://192.168.100.2:3001/YYDSS/download/CC?target=ClashMeta,与连接到本地服务器(192.168.100.2:3001)超时,试过用代理和直连都不通,但在OC是能更新正常。请教什么原因,如何正确配置参数。

time="2024-08-08T07:43:23.768146717+08:00" level=warning msg="[TCP] dial 兜底策略 (match Match/) mihomo --> 192.168.100.2:3001 error: dial tcp 192.168.100.2:3001: i/o timeout"
time="2024-08-08T07:44:49.204466963+08:00" level=warning msg="[TCP] dial DIRECT (match RuleSet/LocalAreaNetwork) mihomo --> 192.168.100.2:3001 error: dial tcp 192.168.100.2:3001: i/o timeout"

关于 TUN mode 的问题以及几个建议

  1. TUN mode

设置 tun mode 之后,在代理路由器本机流量的时候 ,对于同一个域名,会出现mihomo第一次请求的是域名,连接的是域名,但之后的连接都是mihomo连接这个域名的IP。经过排查发现,是由于chain router_dns_hijack只重定向了127.0.0.1,但实际上路由器本机发起DNS请求时同时也会向Interface LAN IP(如192.168.89.2)发起DNS请求。这种情况会导致路由器向上游DNS请求并返回了IP,于是mihomo就直接对IP发起了连接,从而导致分流不准。
example

解决方法有两种:1.劫持Interface LAN IP。2.修改dnsmasq:设置option noresolv '1',拒绝路由器本机向上游DNS发起请求。

同时应当给dnsmasq设置option dns_redirect '0',以immortalWRT为例,dnsmasq_redirect优先级高于mihomo dns_hijack,(如下所示)会导致入站DNS流量无法被mihomo劫持。

table inet dnsmasq {
        chain prerouting {
                type nat hook prerouting priority dstnat - 5; policy accept;
                meta nfproto { ipv4, ipv6 } udp dport 53 counter packets 0 bytes 0 redirect to :53 comment "DNSMASQ HIJACK"
        }
}
table ip mihomo {
        chain dstnat {
                type nat hook prerouting priority dstnat + 1; policy accept;
                jump dns_hijack
        }
}
  1. 建议把使用hosts改为覆盖hosts

一般使用hosts的话在配置文件里面可能都设置了不少的hosts规则,如果完全重头填写过于麻烦,可以直接复用配置文件中的hosts规则。如果需要覆盖的话可以通过识别hosts字段,一个输入框来输入所有Domain-IP对,而不是通过多个输入框一个个填写Domain-IP对。如下图所示:
image

覆盖 DNS 服务器覆盖 Fallback 过滤列表覆盖 DNS 服务器查询策略同理。

  1. 混入文件内容存在bug

输入框存在输入内容后保存没问题,但是把输入框中内容全部删除,再点保存不生效,内容还是存在在输入框中,同时也存在在mixin.yml文件中,只能手动清除mixin.yml文件内容。

  1. GeoX配置中可以考虑添加 ASN下载地址

openwrt下,开启后,状态任然显示未运行

版本:1.4.5

内核版本 uname -a

Linux OpenWrt 5.15.162 #0 SMP Thu Jul 25 18:03:46 2024 x86_64 GNU/Linux

开启后进程状态

[root@OpenWrt:04:15 PM ~] # ps | grep mihomo
 2450 root      1364 S    {profile_watcher} /bin/sh /etc/mihomo/scripts/profile_watcher.sh
 2469 root       928 S    inotifywait -e create,modify --include config.yaml /etc/mihomo/profiles
 2703 root      1200 S    grep mihomo
10864 root       928 S    inotifywait -e create,modify --include config.yaml /etc/mihomo/profiles
13315 root       928 S    inotifywait -e create,modify --include config.yaml /etc/mihomo/profiles
21049 root       928 S    inotifywait -e create,modify --include config.yaml /etc/mihomo/profiles
23548 root       928 S    inotifywait -e create,modify --include config.yaml /etc/mihomo/profiles
32554 root       928 S    inotifywait -e create,modify --include config.yaml /etc/mihomo/profiles

应用日志

[2024-08-04 16:18:42] App is enabled.
[2024-08-04 16:18:42] Starting...
[2024-08-04 16:18:42] Download profile.
[2024-08-04 16:18:42] Download UI.
[2024-08-04 16:18:42] Mixin is disabled, only mixin neccesary config.
[2024-08-04 16:18:42] Profile testing...
[2024-08-04 16:18:42] Profile test passed!
[2024-08-04 16:18:42] Start Core
[2024-08-04 16:18:42] Start Successful!

内核日志

time="2024-08-04T16:18:42.811434514+08:00" level=info msg="Start initial configuration in progress"
time="2024-08-04T16:18:42.816810616+08:00" level=info msg="Geodata Loader mode: memconservative"
time="2024-08-04T16:18:42.816863916+08:00" level=info msg="Geosite Matcher implementation: succinct"
time="2024-08-04T16:18:42.843879918+08:00" level=info msg="Start initial GeoIP rule cn => 🎯 全球直连, records: 7463"
time="2024-08-04T16:18:42.844156465+08:00" level=info msg="Initial configuration complete, total time: 32ms"
configuration file /etc/mihomo/run/config.yaml test is successful

QQ截图20240804162114

代理异常

半小时前的编译包更新后,一些特定的网站无法打开,如 google.com youtube.com,但是却可以打开 x.com github.com 等网站

日志中找到很多此类错误,不确定是否与此有关。

time="2024-06-27T07:40:32.902092952Z" level=debug msg="[Process] find process 91.108.56.134 error: process not found"
time="2024-06-27T07:40:32.903067377Z" level=debug msg="[Process] find process 91.108.56.134 error: process not found"
time="2024-06-27T07:40:32.903372334Z" level=debug msg="[Process] find process 91.108.56.134 error: process not found"
time="2024-06-27T07:40:32.903805775Z" level=debug msg="[Process] find process 91.108.56.134 error: process not found"

已通过iOS代理工具排除节点问题
Snipaste_2024-06-27_15-48-11

Snipaste_2024-06-27_15-48-19

请求添加只代理常用端口功能

udp dport != { 22, 53, 80, 123, 143, 194, 443, 465, 587, 853, 993, 995, 5222, 8080, 8443 } counter packets 0 bytes 0 return
tcp dport != { 22, 53, 80, 123, 143, 194, 443, 465, 587, 853, 993, 995, 5222, 8080, 8443 } counter packets 0 bytes 0 return
能不能在防火墙规则那里添加类似上面的规则

升级安装报错

使用新版包覆盖安装时会输出如下日志

Collected errors:
* resolve_conffiles: Existing conffile /etc/config/mihomo is different from the conffile in the new package. The new conffile will be placed at /etc/config/mihomo-opkg.

初次启动有概率没有网络

目前插件在首次启动时有一定的概率没有网络,而且也没办法看到日志内容。

希望可以增加插件的日志输出,以帮助排查问题。

[BUG]订阅下载的问题。

我的订阅链接在其他的平台上都可以下载出正确的配置文件,如果直接用浏览器访问这个订阅链接则会出现一串加密字符,而我用mihomo订阅这个链接得到的结果和浏览器访问这个链接的结果是一样的,都是一串加密字符而非正确的配置文件,但是用其他的任何客户端都是可以订阅出正确的配置文件的。

增加一下版本号显示

在Luci中显示mihomo核心版本号和Luci版本号,以便用户较为容易的区分当前的版本。

WAN接口获取错误

#34 我添加了一个SFP接口用来访问我的猫棒。重启之后插件似乎把SFP接口当成出口导致上面问题
是否有办法加一个选择接口的地方呢
虽然mihomo可以设置,但是会导致用同配置的其他设备出现问题吧(

希望可以提供无覆盖的纯配置文件运行模式

对于上传自己编写的配置文件的用户,只想让这个luci当作一个启动器,不想被luci的选项覆盖任何配置文件的内容。

所以,希望以下内容可以不对【上传配置文件】模式做任何覆盖修改

【全局配置】【入站配置】【DNS配置】【嗅探器配置】【GeoX配置】

麻烦了

手动更新订阅功能按钮

帮群友提的
目前更新订阅只能通过重新启用插件来实现,虽然更新配置确实需要重启mihomo,但通过一个按钮来进行会更方便一些?

无法完成安装

系统信息

root@iStoreOS:~# cat /etc/openwrt_release
DISTRIB_ID='iStoreOS'
DISTRIB_RELEASE='22.03.6'
DISTRIB_REVISION='2024051012'
DISTRIB_TARGET='x86/64'
DISTRIB_ARCH='x86_64'
DISTRIB_DESCRIPTION='iStoreOS 22.03.6 2024051012'
DISTRIB_TAINTS='busybox'

安装日志

Installing nftables-json (1.0.2-2.1) to root...
Downloading https://mirrors.cernet.edu.cn/openwrt/releases/22.03.6/packages/x86_64/base/nftables-json_1.0.2-2.1_x86_64.ipk
Installing ucode-mod-fs (2022-12-02-46d93c9c-1) to root...
Downloading https://mirrors.cernet.edu.cn/openwrt/releases/22.03.6/packages/x86_64/base/ucode-mod-fs_2022-12-02-46d93c9c-1_x86_64.ipk
Installing ucode-mod-ubus (2022-12-02-46d93c9c-1) to root...
Downloading https://mirrors.cernet.edu.cn/openwrt/releases/22.03.6/packages/x86_64/base/ucode-mod-ubus_2022-12-02-46d93c9c-1_x86_64.ipk
Installing ucode-mod-uci (2022-12-02-46d93c9c-1) to root...
Downloading https://mirrors.cernet.edu.cn/openwrt/releases/22.03.6/packages/x86_64/base/ucode-mod-uci_2022-12-02-46d93c9c-1_x86_64.ipk
Installing firewall4 (2022-10-18-7ae5e14b-1) to root...
Downloading https://mirrors.cernet.edu.cn/openwrt/releases/22.03.6/packages/x86_64/base/firewall4_2022-10-18-7ae5e14b-1_x86_64.ipk
Configuring kmod-nft-core.
Configuring kmod-nft-fib.
Configuring libucode20220812.
Configuring ucode.
Configuring ucode-mod-ubus.
Configuring ucode-mod-uci.
Configuring libinotifytools.
Configuring inotifywait.
Configuring kmod-nft-nat.
Configuring jansson4.
Configuring ucode-mod-fs.
Configuring libnftnl11.
Configuring yq.
Configuring nftables-json.
Configuring kmod-nft-offload.
Collected errors:
 * check_data_file_clashes: Package firewall4 wants to install file /etc/hotplug.d/iface/20-firewall
        But that file is already provided by package  * firewall
 * check_data_file_clashes: Package firewall4 wants to install file /etc/init.d/firewall
        But that file is already provided by package  * firewall
 * check_data_file_clashes: Package firewall4 wants to install file /sbin/fw3
        But that file is already provided by package  * firewall
 * opkg_install_cmd: Cannot install package mihomo.

不知道如何安装,强制安装待会又搞得乱七八糟

[BUG] 混入文件输入框的问题

Describe the bug
混入文件输入框的问题如下:

  1. 每次升级插件的时候,输入框内容会消失,应该是每次升级mixin.yaml被覆盖成空文件。

  2. 每次修改混入文件的内容,点击保存并应用后并不会立即写入配置文件生效,luci界面显示没有要更改的内容。必须重启插件或者点击保存编辑器里的配置文件才能生效。

To Reproduce
如上

Expected behavior

  1. 每次升级插件时应保留mixin.yaml,使其不被覆盖

  2. 每次修改完混入文件内容后,点击保存应用后应立即生效

Enviroment (please complete the following information):

  • OS: [ImmortalWrt]
  • Version [23.05.3]
  • Architecture [aarch64_generic]

Additional context
对于 IPv4/IPv6 DNS 劫持 ,当选择IPv4 DNS 劫持时应当给出提示或警告:可能会产生DNS污染或分流错误

添加重启按钮

修改配置后需要在 luci 界面进行 关闭-应用-开启-应用 操作略麻烦
希望可以加一个 手动重启 的按钮

增加对geosite插件的支持

当openwrt集成多个插件时,有时会附带geodata插件,即在
/usr/share/v2ray/geoip.dat
/usr/share/v2ray/geosite.dat
包含了geoip与geosite数据文件
可以增加一个判断,当这里有文件时,在运行目录中增加一个软链

以下是根据早期版本做的修改参考

geoip_mmdb_path="$run_dir/Country.mmdb"
geoip_dat_path="$run_dir/GeoIP.dat"
geoip_v2ray_path="/usr/share/v2ray/geoip.dat"
geosite_path="$run_dir/GeoSite.dat"
geosite_v2ray_path="/usr/share/v2ray/geosite.dat"

...

	# check v2ray-geodata
	if [ ! -f "$geoip_dat_path" ]; then
		[ -f "$geoip_v2ray_path" ] && ln -s "$geoip_v2ray_path" "$geoip_dat_path"
	fi
	if [ ! -f "$geosite_path" ]; then
		[ -f "$geosite_v2ray_path" ] && ln -s "$geosite_v2ray_path" "$geosite_path"
	fi

希望作者可以考虑移植到新版本,这样解决规则文件预下载,同时也会兼容其它插件的规则,使规则不再重复下载

安装昨天的插件后luci界面报错

  1. 全新写盘的x86固件,不是升级上来的,所以不存在老系统残留问题;
  2. 使用的ipk是仓库里最新版本的;
  3. 内核版本为5.15.158
Snipaste_2024-06-23_19-12-38

启动后无规则、无节点

  1. 已确认配置文件正确无误,在 OpenClash 和 Clash Verge 上均可正常运行;
  2. 不管是覆盖升级,还是卸载重装今天的最新版,依然无法看到规则和节点被成功下载下来。节点数量为0,规则数量也是0;
  3. /etc/mihomo/run/proxy_provider 存在上次下载下来的有效的订阅文件
  4. /etc/mihomo/run/RuleSet 存在上次下载下来的有效的规则文件
  5. 尝试在WebUI上手动更新节点订阅和规则集合无效;
  6. 所涉及的版本是今天的编译产出。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.