Skip to content

Commit

Permalink
add missing ipv6 route
Browse files Browse the repository at this point in the history
  • Loading branch information
morytyann committed Aug 2, 2024
1 parent 97ec2e9 commit e38ef4c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion luci-app-mihomo/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include $(TOPDIR)/rules.mk

PKG_VERSION:=1.4.3
PKG_VERSION:=1.4.4

LUCI_TITLE:=LuCI Support for mihomo
LUCI_DEPENDS:=+luci-base +mihomo
Expand Down
2 changes: 1 addition & 1 deletion mihomo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk

PKG_NAME:=mihomo
PKG_VERSION:=1.18.7
PKG_RELEASE:=147
PKG_RELEASE:=148
PKG_BUILD_TIME=$(shell date -u -Iseconds)

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
Expand Down
14 changes: 10 additions & 4 deletions mihomo/files/mihomo.init
Original file line number Diff line number Diff line change
Expand Up @@ -240,24 +240,28 @@ start_service() {
# transparent proxy
log "Transparent Proxy: Start hijack."
if [ "$transparent_proxy_mode" == "tproxy" ]; then
ip route add local default dev lo table "$FW_TABLE"
ip rule add fwmark "$FW_MARK" table "$FW_TABLE"
if [ "$ipv4_proxy" == 1 ]; then
ip route add local default dev lo table "$FW_TABLE"
ip rule add fwmark "$FW_MARK" table "$FW_TABLE"
nft -f "$HIJACK_NFT" -D FW_MARK="$FW_MARK" -D MIHOMO_USER="$MIHOMO_USER" -D TPROXY_PORT="$tproxy_port" -D DNS_PORT="$dns_port"
fi
if [ "$ipv6_proxy" == 1 ]; then
ip -6 route add local default dev lo table "$FW_TABLE"
ip -6 rule add fwmark "$FW_MARK" table "$FW_TABLE"
nft -f "$HIJACK6_NFT" -D FW_MARK="$FW_MARK" -D MIHOMO_USER="$MIHOMO_USER" -D TPROXY_PORT="$tproxy_port" -D DNS_PORT="$dns_port"
fi
elif [ "$transparent_proxy_mode" == "tun" ]; then
ip tuntap add dev "$TUN_DEVICE" mode tun vnet_hdr
ip link set "$TUN_DEVICE" up
ip route add unicast default dev "$TUN_DEVICE" table "$FW_TABLE"
ip rule add fwmark "$FW_MARK" table "$FW_TABLE"
$TUN_SH
if [ "$ipv4_proxy" == 1 ]; then
ip route add unicast default dev "$TUN_DEVICE" table "$FW_TABLE"
ip rule add fwmark "$FW_MARK" table "$FW_TABLE"
nft -f "$HIJACK_TUN_NFT" -D FW_MARK="$FW_MARK" -D TUN_DEVICE="$TUN_DEVICE" -D MIHOMO_USER="$MIHOMO_USER" -D TPROXY_PORT="$tproxy_port" -D DNS_PORT="$dns_port"
fi
if [ "$ipv6_proxy" == 1 ]; then
ip -6 route add unicast default dev "$TUN_DEVICE" table "$FW_TABLE"
ip -6 rule add fwmark "$FW_MARK" table "$FW_TABLE"
nft -f "$HIJACK6_TUN_NFT" -D FW_MARK="$FW_MARK" -D TUN_DEVICE="$TUN_DEVICE" -D MIHOMO_USER="$MIHOMO_USER" -D TPROXY_PORT="$tproxy_port" -D DNS_PORT="$dns_port"
fi
fi
Expand Down Expand Up @@ -385,6 +389,8 @@ cleanup() {
# delete hijack
ip rule del table "$FW_TABLE" > /dev/null 2>&1
ip route flush table "$FW_TABLE" > /dev/null 2>&1
ip -6 rule del table "$FW_TABLE" > /dev/null 2>&1
ip -6 route flush table "$FW_TABLE" > /dev/null 2>&1
ip tuntap del dev "$TUN_DEVICE" mode tun > /dev/null 2>&1
nft delete table ip mihomo > /dev/null 2>&1
nft delete table ip6 mihomo > /dev/null 2>&1
Expand Down

0 comments on commit e38ef4c

Please sign in to comment.