Merge pull request #2413 from rosysong/nft-qos
luci-app-nft-qos: rework _action_rate function
This commit is contained in:
commit
8374aa2bad
1 changed files with 13 additions and 14 deletions
|
@ -17,18 +17,18 @@ function index()
|
||||||
end
|
end
|
||||||
|
|
||||||
function _action_rate(rv, n)
|
function _action_rate(rv, n)
|
||||||
local has_ipv6 = nixio.fs.access("/proc/net/ipv6_route")
|
local c = nixio.fs.access("/proc/net/ipv6_route") and
|
||||||
if has_ipv6 then
|
io.popen("nft list chain inet nft-qos-monitor " .. n .. " 2>/dev/null") or
|
||||||
local c = io.popen("nft list chain inet nft-qos-monitor " .. n .. " 2>/dev/null")
|
io.popen("nft list chain ip nft-qos-monitor " .. n .. " 2>/dev/null")
|
||||||
else
|
|
||||||
local c = io.popen("nft list chain ip nft-qos-monitor " .. n .. " 2>/dev/null")
|
|
||||||
end
|
|
||||||
if c then
|
if c then
|
||||||
for l in c:lines() do
|
for l in c:lines() do
|
||||||
local _, i, p, b = l:match('^%s+ip ([^%s]+) ([^%s]+) counter packets (%d+) bytes (%d+)')
|
local _, i, p, b = l:match(
|
||||||
|
'^%s+ip ([^%s]+) ([^%s]+) counter packets (%d+) bytes (%d+)'
|
||||||
|
)
|
||||||
if i and p and b then
|
if i and p and b then
|
||||||
-- handle expression
|
-- handle expression
|
||||||
local r = {
|
rv[#rv + 1] = {
|
||||||
rule = {
|
rule = {
|
||||||
family = "inet",
|
family = "inet",
|
||||||
table = "nft-qos-monitor",
|
table = "nft-qos-monitor",
|
||||||
|
@ -40,7 +40,6 @@ function _action_rate(rv, n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rv[#rv + 1] = r
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
c:close()
|
c:close()
|
||||||
|
|
Loading…
Reference in a new issue