diff --git a/luci-app-omr-bypass/luasrc/model/cbi/omr-bypass.lua b/luci-app-omr-bypass/luasrc/model/cbi/omr-bypass.lua index 640b128d6..c3ee50785 100644 --- a/luci-app-omr-bypass/luasrc/model/cbi/omr-bypass.lua +++ b/luci-app-omr-bypass/luasrc/model/cbi/omr-bypass.lua @@ -39,7 +39,7 @@ s.addremove = true s.anonymous = true s.template = "cbi/tblsection" -mac = s:option(Value, "mac", translate("MAC-Address")) +mac = s:option(Value, "mac", translate("Source MAC-Address")) mac.datatype = "list(macaddr)" mac.rmempty = true mac.optional = false @@ -58,6 +58,19 @@ end) ifm = s:option(Value, "interface", translate("Interface")) ifm.rmempty = true +s = m:section(TypedSection, "lan_ip", translate("Source lan IP address")) +s.addremove = true +s.anonymous = true +s.template = "cbi/tblsection" + +ip = s:option(Value, "ip", translate("IP Address")) +ip.datatype = "ipaddr" +ip.rmempty = true +ip.optional = false + +ifm = s:option(Value, "interface", translate("Interface")) +ifm.rmempty = true + s = m:section(TypedSection, "dpis", translate("Protocols")) s.addremove = true s.anonymous = true 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 7e9dd5f7a..371b29e00 100755 --- a/luci-app-omr-bypass/root/etc/init.d/omr-bypass +++ b/luci-app-omr-bypass/root/etc/init.d/omr-bypass @@ -78,6 +78,40 @@ _bypass_mac() { fi } +_bypass_lan_ip() { + local ip + local intf + config_get ip $1 ip + config_get intf $1 interface + local intfid="$(uci -q get omr-bypass.$intf.id)" + + [ -z "$intf" ] && intf="all" + [ -z "$ip" ] && return + if [ "$intf" = "all" ]; then + iptables-restore --wait=60 --noflush <<-EOF + *mangle + -A PREROUTING -s $ip -j MARK --set-mark 0x539 + COMMIT + EOF + ip6tables-restore --wait=60 --noflush <<-EOF + *mangle + -A PREROUTING -s $ip -j MARK --set-mark 0x6539 + COMMIT + EOF + else + iptables-restore --wait=60 --noflush <<-EOF + *mangle + -A PREROUTING -s $ip -j MARK --set-mark 0x539$intfid + COMMIT + EOF + ip6tables-restore --wait=60 --noflush <<-EOF + *mangle + -A PREROUTING -s $ip -j MARK --set-mark 0x6539$intfid + COMMIT + EOF + fi +} + _bypass_proto() { local proto local intf @@ -200,6 +234,7 @@ start_service() { config_load omr-bypass config_foreach _bypass_ip_set ips config_foreach _bypass_mac macs + config_foreach _bypass_lan_ip lan_ip uci -q del dhcp.@dnsmasq[0].ipset config_foreach _bypass_domain domains uci -q commit dhcp