From 28f25cf951f623cbbf43ac0e92b45ea2460d92c1 Mon Sep 17 00:00:00 2001 From: Tim Wilkinson Date: Sun, 12 Jun 2022 21:01:12 -0700 Subject: [PATCH] Allow user to force certain macs to be accepted --- files/usr/local/bin/mgr/lqm.lua | 17 +++++++++++++++-- files/www/cgi-bin/advancedconfig | 10 +++++++++- files/www/cgi-bin/sysinfo.json | 3 ++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/files/usr/local/bin/mgr/lqm.lua b/files/usr/local/bin/mgr/lqm.lua index 6a4305b6..9bc0cfd3 100755 --- a/files/usr/local/bin/mgr/lqm.lua +++ b/files/usr/local/bin/mgr/lqm.lua @@ -64,7 +64,8 @@ function get_config() min_quality = tonumber(c:get("aredn", "@lqm[0]", "min_quality")), margin_quality = tonumber(c:get("aredn", "@lqm[0]", "margin_quality")), 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 @@ -87,7 +88,9 @@ function is_pending(track) end 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 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 @@ -635,6 +638,16 @@ function lqm() track.blocks.quality = false 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 -- Eliminate link pairs, where we might have links to multiple radios at the same site diff --git a/files/www/cgi-bin/advancedconfig b/files/www/cgi-bin/advancedconfig index 5827d58d..b18d9617 100755 --- a/files/www/cgi-bin/advancedconfig +++ b/files/www/cgi-bin/advancedconfig @@ -335,7 +335,15 @@ local settings = { desc = "Comma separated list of blocked MACs", default = "", 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 = {} diff --git a/files/www/cgi-bin/sysinfo.json b/files/www/cgi-bin/sysinfo.json index ea7f7f00..180cb3e0 100755 --- a/files/www/cgi-bin/sysinfo.json +++ b/files/www/cgi-bin/sysinfo.json @@ -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")), margin_quality = tonumber(ctx:get("aredn", "@lqm[0]", "margin_quality")), 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 = {} if nixio.fs.stat("/tmp/lqm.info") then