Skip to content

Commit

Permalink
feat: add mihomo default config and as-default module
Browse files Browse the repository at this point in the history
  • Loading branch information
EkkoG committed Oct 18, 2024
1 parent 11c8dd1 commit a8646c4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
26 changes: 26 additions & 0 deletions modules/mihomo-as-default/files/etc/hotplug.d/iface/99-mihomo
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

echo "iface $INTERFACE $ACTION detected..."

[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && {

sleep 3

ps | grep mihomo | grep nobody
if [ $? -eq 0 ]; then
logger "mihomo is running"
else
if [ ! -f /root/.mihomo_first_boot ]; then
logger "First boot detected, starting mihomo..."

uci -q set mihomo.config.enabled=1
uci -q commit mihomo

/etc/init.d/mihomo start

touch /root/.mihomo_first_boot
else
logger "Not first boot, mihomo start according to config"
fi
fi
}
1 change: 1 addition & 0 deletions modules/openwrt-mihomo/example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CLASH_CONFIG_URL=https://a.com/config.yml
13 changes: 13 additions & 0 deletions modules/openwrt-mihomo/files/etc/uci-defaults/99-mihomo
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
uci batch << EOF
set mihomo.config.fast_reload='0'
set mihomo.proxy.tcp_transparent_proxy_mode='tproxy'
set mihomo.proxy.udp_transparent_proxy_mode='tproxy'
set mihomo.proxy.ipv6_proxy='1'
set mihomo.proxy.bypass_china_mainland_ip='1'
set mihomo.subscription.url='$CLASH_CONFIG_URL'
set mihomo.mixin.ipv6='1'
set mihomo.mixin.dns_mode='normal'
set mihomo.mixin.dns_ipv6='1'
set mihomo.mixin.dns_system_hosts='1'
commit
EOF

0 comments on commit a8646c4

Please sign in to comment.