From c5f192783f77eea1e280a50e225a05cbbf0e62bb Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Fri, 26 Jul 2019 20:10:53 +0200 Subject: [PATCH] Fix error when adding LAN ip --- .../root/etc/init.d/omr-bypass | 53 ++++++++++--------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/luci-app-omr-bypass/root/etc/init.d/omr-bypass b/luci-app-omr-bypass/root/etc/init.d/omr-bypass index 8cae24124..b87d8d37a 100755 --- a/luci-app-omr-bypass/root/etc/init.d/omr-bypass +++ b/luci-app-omr-bypass/root/etc/init.d/omr-bypass @@ -105,28 +105,36 @@ _bypass_lan_ip() { [ -z "$intf" ] && intf="all" [ -z "$ip" ] && return + valid_ip4=$( valid_subnet4 $ip) + valid_ip6=$( valid_subnet6 $ip) if [ "$intf" = "all" ]; then - iptables-restore --wait=60 --noflush <<-EOF - *mangle - -A omr-bypass -s $ip -j MARK --set-mark 0x539 - COMMIT - EOF - ip6tables-restore --wait=60 --noflush <<-EOF - *mangle - -A omr-bypass6 -s $ip -j MARK --set-mark 0x6539 - COMMIT - EOF + if [ "$valid_ip4" = "ok" ]; then + iptables-restore --wait=60 --noflush <<-EOF + *mangle + -A omr-bypass -s $ip -j MARK --set-mark 0x539 + COMMIT + EOF + elif [ "$valid_ip6" = "ok" ]; then + ip6tables-restore --wait=60 --noflush <<-EOF + *mangle + -A omr-bypass6 -s $ip -j MARK --set-mark 0x6539 + COMMIT + EOF + fi else - iptables-restore --wait=60 --noflush <<-EOF - *mangle - -A omr-bypass -s $ip -j MARK --set-mark 0x539$intfid - COMMIT - EOF - ip6tables-restore --wait=60 --noflush <<-EOF - *mangle - -A omr-bypass6 -s $ip -j MARK --set-mark 0x6539$intfid - COMMIT - EOF + if [ "$valid_ip4" = "ok" ]; then + iptables-restore --wait=60 --noflush <<-EOF + *mangle + -A omr-bypass -s $ip -j MARK --set-mark 0x539$intfid + COMMIT + EOF + elif [ "$valid_ip6" = "ok" ]; then + ip6tables-restore --wait=60 --noflush <<-EOF + *mangle + -A omr-bypass6 -s $ip -j MARK --set-mark 0x6539$intfid + COMMIT + EOF + fi fi } @@ -299,7 +307,6 @@ start_service() { create omr6_dst_bypass_all hash:net family inet6 hashsize 64 EOF } - iptables-save --counters | grep -v omr-bypass | iptables-restore --counters iptables-restore --wait=60 --noflush <<-EOF *mangle @@ -314,11 +321,9 @@ start_service() { -I PREROUTING 1 -m addrtype ! --dst-type LOCAL -j omr-bypass6 COMMIT EOF - - + config_load network config_foreach _intf_rule interface - local ndpi_rules="" config_load openmptcprouter config_foreach _bypass_omr_server server