Allow user to force certain macs to be accepted

This commit is contained in:
Tim Wilkinson 2022-06-12 21:01:12 -07:00 committed by Joe AE6XE
parent c57d384ca6
commit 28f25cf951
3 changed files with 26 additions and 4 deletions

View File

@ -64,7 +64,8 @@ function get_config()
min_quality = tonumber(c:get("aredn", "@lqm[0]", "min_quality")), min_quality = tonumber(c:get("aredn", "@lqm[0]", "min_quality")),
margin_quality = tonumber(c:get("aredn", "@lqm[0]", "margin_quality")), margin_quality = tonumber(c:get("aredn", "@lqm[0]", "margin_quality")),
ping_penalty = tonumber(c:get("aredn", "@lqm[0]", "ping_penalty")), ping_penalty = tonumber(c:get("aredn", "@lqm[0]", "ping_penalty")),
user_blocks = c:get("aredn", "@lqm[0]", "user_blocks") or "" user_blocks = c:get("aredn", "@lqm[0]", "user_blocks") or "",
user_allows = c:get("aredn", "@lqm[0]", "user_allows") or ""
} }
end end
@ -87,7 +88,9 @@ function is_pending(track)
end end
function should_block(track) function should_block(track)
if is_pending(track) then if track.user_allow then
return false
elseif is_pending(track) then
return track.blocks.dtd or track.blocks.user return track.blocks.dtd or track.blocks.user
else else
return track.blocks.dtd or track.blocks.signal or track.blocks.distance or track.blocks.user or track.blocks.dup or track.blocks.quality return track.blocks.dtd or track.blocks.signal or track.blocks.distance or track.blocks.user or track.blocks.dup or track.blocks.quality
@ -635,6 +638,16 @@ function lqm()
track.blocks.quality = false track.blocks.quality = false
end end
end end
-- Always allow if user requested it
track.user_allow = false;
for val in string.gmatch(config.user_allows, "([^,]+)")
do
if val:gsub("%s+", ""):gsub("-", ":"):upper() == track.mac then
track.user_allow = true
break
end
end
end end
-- Eliminate link pairs, where we might have links to multiple radios at the same site -- Eliminate link pairs, where we might have links to multiple radios at the same site

View File

@ -335,7 +335,15 @@ local settings = {
desc = "Comma separated list of blocked MACs", desc = "Comma separated list of blocked MACs",
default = "", default = "",
condition = "lqm_enabled()" condition = "lqm_enabled()"
} },
{
category = "Link Quality",
key = "aredn.@lqm[0].user_allows",
type = "string",
desc = "Comma separated list of always allowed MACs",
default = "",
condition = "lqm_enabled()"
}
} }
local msgs = {} local msgs = {}

View File

@ -177,7 +177,8 @@ if string.find(nixio.getenv("QUERY_STRING"):lower(),"lqm=1") then
min_quality = tonumber(ctx:get("aredn", "@lqm[0]", "min_quality")), min_quality = tonumber(ctx:get("aredn", "@lqm[0]", "min_quality")),
margin_quality = tonumber(ctx:get("aredn", "@lqm[0]", "margin_quality")), margin_quality = tonumber(ctx:get("aredn", "@lqm[0]", "margin_quality")),
ping_penalty = tonumber(ctx:get("aredn", "@lqm[0]", "ping_penalty")), ping_penalty = tonumber(ctx:get("aredn", "@lqm[0]", "ping_penalty")),
user_blocks = ctx:get("aredn", "@lqm[0]", "user_blocks") or {} user_blocks = ctx:get("aredn", "@lqm[0]", "user_blocks"),
user_allows = ctx:get("aredn", "@lqm[0]", "user_allows")
} }
lqm.info = {} lqm.info = {}
if nixio.fs.stat("/tmp/lqm.info") then if nixio.fs.stat("/tmp/lqm.info") then