1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-15 03:51:51 +00:00

Add an option to disable 6in4 (#491)

This commit is contained in:
suyuan 2024-05-24 21:43:18 +08:00 committed by GitHub
commit 3dcbc77a18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 53 additions and 32 deletions

View file

@ -1332,6 +1332,11 @@ function settings_add()
ucic:set("openmptcprouter","settings","disable_ipv6",disable_ipv6)
--local dump = require("luci.util").ubus("openmptcprouter", "disableipv6", { disable_ipv6 = tonumber(disable_ipv6)})
-- Disable 6in4
local disable_6in4 = luci.http.formvalue("enable6in4") or "1"
ucic:set("openmptcprouter","settings","disable_6in4",disable_6in4)
-- Enable/disable external check
local externalcheck = luci.http.formvalue("externalcheck") or "1"
ucic:set("openmptcprouter","settings","external_check",externalcheck)

View file

@ -189,6 +189,12 @@
<input type="checkbox" name="enableipv6" class="cbi-input-checkbox" value="0" <% if luci.model.uci.cursor():get("openmptcprouter","settings","disable_ipv6") == "0" then %>checked<% end %>>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title"><%:Enable 6in4%></label>
<div class="cbi-value-field">
<input type="checkbox" name="enable6in4" class="cbi-input-checkbox" value="0" <% if luci.model.uci.cursor():get("openmptcprouter","settings","disable_6in4") == "0" then %>checked<% end %>>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title"><%:Disable external check%></label>
<div class="cbi-value-field">

View file

@ -18,6 +18,7 @@ set_shadowsocks_rust_address() {
}
set_ipv6_state() {
local disable_6in4="$(uci -q get openmptcprouter.settings.disable_6in4)"
local disable_ipv6="$(uci -q get openmptcprouter.settings.disable_ipv6)"
[ -z "$disable_ipv6" ] && disable_ipv6="1"
#previous=$(sysctl -qn net.ipv6.conf.all.disable_ipv6 | tr -d "\n")
@ -34,12 +35,14 @@ set_ipv6_state() {
if [ "$disable_ipv6" = "1" ]; then
logger -t "omr-6in4" "Disable IPv6"
if [ "$disable_6in4" != "1" ]; then
uci -q batch <<-EOF >/dev/null
set unbound.@unbound[-1].protocol='ip4_only'
commit unbound
del_list v2ray.main.inbounds="omr6"
commit v2ray
EOF
fi
config_load shadowsocks-libev
config_foreach set_shadowsocks_address ss_redir "0.0.0.0"
config_load shadowsocks-rust
@ -51,6 +54,7 @@ set_ipv6_state() {
[ ! -f /etc/wgetrc ] && cp /etc/wgetrc4 /etc/wgetrc
else
logger -t "omr-6in4" "Enable IPv6"
if [ "$disable_6in4" != "1" ]; then
uci -q batch <<-EOF >/dev/null
set network.lan.delegate="0"
set network.omr6in4.force_link=1
@ -65,7 +69,7 @@ set_ipv6_state() {
r3=$(dd if=/dev/urandom bs=2 count=1 |hexdump -e '2/1 "%02x"')
uci -q set network.globals.ula_prefix=fd$r1:$r2:$r3::/48
fi
fi
config_load shadowsocks-libev
config_foreach set_shadowsocks_address ss_redir "::"
config_load shadowsocks-rust
@ -140,20 +144,25 @@ set_ipv6_state_intf() {
start_service() {
[ "$(uci -q get openmptcprouter.settings.disable_ipv6)" != "1" ] && {
if [ "$(uci -q get openmptcprouter.settings.disable_6in4)" != "1" ]; then
config_load network
config_foreach set_ipv6_state_intf interface
fi
set_ipv6_state
}
[ "$(uci -q get openmptcprouter.settings.disable_ipv6)" != "0" ] && {
if [ "$(uci -q get openmptcprouter.settings.disable_6in4)" != "1" ]; then
config_load network
config_foreach set_ipv6_state_intf interface
fi
ifdown omr6in4
[ -z "$(/etc/init.d/odhcpd status | grep inactive)" ] && /etc/init.d/odhcpd stop
return
}
[ "$(ifstatus omr6in4 | jsonfilter -e '@.up' | tr -d '\n')" != "true" ] && ifup omr6in4
[ "$(uci -q get openmptcprouter.settings.disable_6in4)" != "1" ] && [ "$(ifstatus omr6in4 | jsonfilter -e '@.up' | tr -d '\n')" != "true" ] && ifup omr6in4
multipath 6in4-omr6in4 off 2>&1 >/dev/null
if [ "$(uci -q get openmptcprouter.settings.disable_6in4)" != "1" ]; then
procd_open_instance
# shellcheck disable=SC2086
procd_set_param command /bin/omr-6in4
@ -161,6 +170,7 @@ start_service() {
procd_set_param respawn 0 10 0
procd_set_param stderr 1
procd_close_instance
fi
}
service_triggers() {