qmodem_ttl: remove ifname option.

This commit is contained in:
fujr 2024-11-01 04:55:40 +08:00
parent dc842c4a16
commit 542e99c468
4 changed files with 9 additions and 22 deletions

View File

@ -1,6 +1,6 @@
local uci = luci.model.uci.cursor() local uci = luci.model.uci.cursor()
m = Map("qmodem_ttl", translate("TTL Config")) m = Map("qmodem_ttl", translate("TTL Config"))
s = m:section(NamedSection, "global", "global", translate("Global Config")) s = m:section(NamedSection, "main", "main", translate("Global Config"))
enable = s:option(Flag, "enable", translate("Enable")) enable = s:option(Flag, "enable", translate("Enable"))
enable.default = "0" enable.default = "0"
@ -9,11 +9,5 @@ ttl = s:option(Value, "ttl", translate("TTL"))
ttl.default = 64 ttl.default = 64
ttl.datatype = "uinteger" ttl.datatype = "uinteger"
o = s:option(Value, "ifname", translate("Interface"))
uci:foreach("network", "interface", function(s)
if s[".name"] ~= "loopback" and s[".name"] ~= "lan" then
o:value(s[".name"])
end
end)
return m return m

View File

@ -1 +1 @@
config global 'global' config main 'main'

View File

@ -8,7 +8,7 @@ USE_PROCD=1
start_service() start_service()
{ {
config_load 'qmodem_ttl' config_load 'qmodem_ttl'
config_get enable 'global' 'enable' '0' config_get enable 'main' 'enable' '0'
if [ "$enable" == 0 ]; then if [ "$enable" == 0 ]; then
return return
fi fi
@ -17,14 +17,10 @@ start_service()
set_if_ttl() set_if_ttl()
{ {
config_get ifname 'global' 'ifname' config_get ttl 'main' 'ttl'
config_get ttl 'global' 'ttl'
iface=$(ifstatus $ifname)
json_load "$iface"
json_get_var device device
IPT="iptables" IPT="iptables"
IPT6="ip6tables" IPT6="ip6tables"
logger -t modem_ttl "Setting TTL for $device to $ttl" logger -t modem_ttl "Ovrewirte TTL from br-lan to $ttl"
comment="modem_ttl" comment="modem_ttl"
touch /etc/firewall.d/qmodem_ttl touch /etc/firewall.d/qmodem_ttl
chmod +x /etc/firewall.d/qmodem_ttl chmod +x /etc/firewall.d/qmodem_ttl
@ -44,10 +40,10 @@ set_if_ttl()
if [ -n "$IPT6_POSTROUTING" ]; then if [ -n "$IPT6_POSTROUTING" ]; then
ip6tables -t mangle -D POSTROUTING $IPT6_POSTROUTING ip6tables -t mangle -D POSTROUTING $IPT6_POSTROUTING
fi fi
echo "$IPT -t mangle -A PREROUTING -i $device -j TTL --ttl-set $ttl -m comment --comment $comment" >> /etc/firewall.d/qmodem_ttl echo "$IPT -t mangle -A PREROUTING -i br-lan -j TTL --ttl-set $ttl -m comment --comment $comment" > /etc/firewall.d/qmodem_ttl
echo "$IPT -t mangle -A POSTROUTING -o $device -j TTL --ttl-set $ttl -m comment --comment $comment" >> /etc/firewall.d/qmodem_ttl echo "$IPT -t mangle -A POSTROUTING -o !br-lan -j TTL --ttl-set $ttl -m comment --comment $comment" >> /etc/firewall.d/qmodem_ttl
echo "$IPT6 -t mangle -A PREROUTING -i $device -j HL --hl-set $ttl -m comment --comment $comment" >> /etc/firewall.d/qmodem_ttl echo "$IPT6 -t mangle -A PREROUTING -i br-lan -j HL --hl-set $ttl -m comment --comment $comment" >> /etc/firewall.d/qmodem_ttl
echo "$IPT6 -t mangle -A POSTROUTING -o $device -j HL --hl-set $ttl -m comment --comment $comment" >> /etc/firewall.d/qmodem_ttl echo "$IPT6 -t mangle -A POSTROUTING -o !br-lan -j HL --hl-set $ttl -m comment --comment $comment" >> /etc/firewall.d/qmodem_ttl
/etc/firewall.d/qmodem_ttl /etc/firewall.d/qmodem_ttl
chmod -x /etc/firewall.d/qmodem_ttl chmod -x /etc/firewall.d/qmodem_ttl
[ -d /sys/kernel/debug/ecm/ ] && /etc/init.d/qca-nss-ecm stop # disable nss offload [ -d /sys/kernel/debug/ecm/ ] && /etc/init.d/qca-nss-ecm stop # disable nss offload
@ -77,8 +73,6 @@ stop_service(){
service_triggers() service_triggers()
{ {
procd_add_reload_trigger "qmodem_ttl" procd_add_reload_trigger "qmodem_ttl"
procd_add_reload_trigger "network"
#netdev
} }
reload_service() reload_service()

View File

@ -449,7 +449,6 @@ set_if()
ifdown ${interface6_name} ifdown ${interface6_name}
ifup ${interface_name} ifup ${interface_name}
ifup ${interface6_name} ifup ${interface6_name}
/etc/init.d/qmodem_ttl start
fi fi
if [ "$firewall_reload_flag" -eq 1 ];then if [ "$firewall_reload_flag" -eq 1 ];then
uci commit firewall uci commit firewall