mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-13 11:01:50 +00:00
Add bypass by mac and fixes
This commit is contained in:
parent
eee9719e96
commit
a8119764dd
3 changed files with 65 additions and 3 deletions
|
@ -21,12 +21,12 @@ hn.rmempty = true
|
||||||
ifd = s:option(Value, "interface", translate("Interface"))
|
ifd = s:option(Value, "interface", translate("Interface"))
|
||||||
ifd.rmempty = true
|
ifd.rmempty = true
|
||||||
|
|
||||||
s = m:section(TypedSection, "ip", translate("IPs and Networks"))
|
s = m:section(TypedSection, "ips", translate("IPs and Networks"))
|
||||||
s.addremove = true
|
s.addremove = true
|
||||||
s.anonymous = true
|
s.anonymous = true
|
||||||
s.template = "cbi/tblsection"
|
s.template = "cbi/tblsection"
|
||||||
|
|
||||||
ip = s:option(Value, "ips", translate("IP"))
|
ip = s:option(Value, "ip", translate("IP"))
|
||||||
ip.datatype = "ipaddr"
|
ip.datatype = "ipaddr"
|
||||||
ip.rmempty = true
|
ip.rmempty = true
|
||||||
ip.optional = false
|
ip.optional = false
|
||||||
|
@ -34,6 +34,30 @@ ip.optional = false
|
||||||
ifi = s:option(Value, "interface", translate("Interface"))
|
ifi = s:option(Value, "interface", translate("Interface"))
|
||||||
ifi.rmempty = true
|
ifi.rmempty = true
|
||||||
|
|
||||||
|
s = m:section(TypedSection, "macs", translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address"))
|
||||||
|
s.addremove = true
|
||||||
|
s.anonymous = true
|
||||||
|
s.template = "cbi/tblsection"
|
||||||
|
|
||||||
|
mac = s:option(Value, "mac", translate("MAC-Address"))
|
||||||
|
mac.datatype = "list(macaddr)"
|
||||||
|
mac.rmempty = true
|
||||||
|
mac.optional = false
|
||||||
|
|
||||||
|
function mac.cfgvalue(self, option)
|
||||||
|
local val = Value.cfgvalue(self, section)
|
||||||
|
return ipc.checkmac(val) or val
|
||||||
|
end
|
||||||
|
|
||||||
|
sys.net.host_hints(function(m, v4, v6, name)
|
||||||
|
if m then
|
||||||
|
mac:value(m, "%s (%s)" %{m, name or v4 or v6})
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
ifm = s:option(Value, "interface", translate("Interface"))
|
||||||
|
ifm.rmempty = true
|
||||||
|
|
||||||
s = m:section(TypedSection, "dpis", translate("Protocols"))
|
s = m:section(TypedSection, "dpis", translate("Protocols"))
|
||||||
s.addremove = true
|
s.addremove = true
|
||||||
s.anonymous = true
|
s.anonymous = true
|
||||||
|
@ -60,14 +84,17 @@ ifp.rmempty = true
|
||||||
ifd.default = "all"
|
ifd.default = "all"
|
||||||
ifi.default = "all"
|
ifi.default = "all"
|
||||||
ifp.default = "all"
|
ifp.default = "all"
|
||||||
|
ifm.default = "all"
|
||||||
ifd:value("all",translate("Default"))
|
ifd:value("all",translate("Default"))
|
||||||
ifi:value("all",translate("Default"))
|
ifi:value("all",translate("Default"))
|
||||||
ifp:value("all",translate("Default"))
|
ifp:value("all",translate("Default"))
|
||||||
|
ifm:value("all",translate("Default"))
|
||||||
for _, iface in ipairs(ifaces) do
|
for _, iface in ipairs(ifaces) do
|
||||||
if iface:is_up() then
|
if iface:is_up() then
|
||||||
ifd:value(iface:name(),"%s" % iface:name())
|
ifd:value(iface:name(),"%s" % iface:name())
|
||||||
ifi:value(iface:name(),"%s" % iface:name())
|
ifi:value(iface:name(),"%s" % iface:name())
|
||||||
ifp:value(iface:name(),"%s" % iface:name())
|
ifp:value(iface:name(),"%s" % iface:name())
|
||||||
|
ifm:value(iface:name(),"%s" % iface:name())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,40 @@ _bypass_domain() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_bypass_mac() {
|
||||||
|
local mac
|
||||||
|
local intf
|
||||||
|
config_get mac $1 mac
|
||||||
|
config_get intf $1 interface
|
||||||
|
local intfid="$(uci -q get omr-bypass.$intf.id)"
|
||||||
|
|
||||||
|
[ -z "$intf" ] && intf="all"
|
||||||
|
[ -z "$mac" ] && return
|
||||||
|
if [ "$intf" = "all" ]; then
|
||||||
|
iptables-restore --wait=60 --noflush <<-EOF
|
||||||
|
*mangle
|
||||||
|
-A PREROUTING -m mac --mac-source $mac -j MARK --set-mark 0x539
|
||||||
|
COMMIT
|
||||||
|
EOF
|
||||||
|
ip6tables-restore --wait=60 --noflush <<-EOF
|
||||||
|
*mangle
|
||||||
|
-A PREROUTING -m mac --mac-source $mac -j MARK --set-mark 0x6539
|
||||||
|
COMMIT
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
iptables-restore --wait=60 --noflush <<-EOF
|
||||||
|
*mangle
|
||||||
|
-A PREROUTING -m mac --mac-source $mac -j MARK --set-mark 0x539$intfid
|
||||||
|
COMMIT
|
||||||
|
EOF
|
||||||
|
ip6tables-restore --wait=60 --noflush <<-EOF
|
||||||
|
*mangle
|
||||||
|
-A PREROUTING -m mac --mac-source $mac -j MARK --set-mark 0x6539$intfid
|
||||||
|
COMMIT
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
_bypass_proto() {
|
_bypass_proto() {
|
||||||
local proto
|
local proto
|
||||||
local intf
|
local intf
|
||||||
|
@ -165,6 +199,7 @@ start_service() {
|
||||||
local ndpi_rules=""
|
local ndpi_rules=""
|
||||||
config_load omr-bypass
|
config_load omr-bypass
|
||||||
config_foreach _bypass_ip_set ips
|
config_foreach _bypass_ip_set ips
|
||||||
|
config_foreach _bypass_mac macs
|
||||||
uci -q del dhcp.@dnsmasq[0].ipset
|
uci -q del dhcp.@dnsmasq[0].ipset
|
||||||
config_foreach _bypass_domain domains
|
config_foreach _bypass_domain domains
|
||||||
uci -q commit dhcp
|
uci -q commit dhcp
|
||||||
|
|
|
@ -27,7 +27,7 @@ if [ -n "$(uci -q get omr-bypass.ips)" ]; then
|
||||||
for ip in $ips; do
|
for ip in $ips; do
|
||||||
uci -q batch <<-EOF >/dev/null
|
uci -q batch <<-EOF >/dev/null
|
||||||
set omr-bypass.ips[-1]=ips
|
set omr-bypass.ips[-1]=ips
|
||||||
set omr-bypass.ips[-1].name=$ip
|
set omr-bypass.ips[-1].ip=$ip
|
||||||
set omr-bypass.ips[-1].interface=all
|
set omr-bypass.ips[-1].interface=all
|
||||||
EOF
|
EOF
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue