LQM fixes 6 (#379)

This commit is contained in:
Tim Wilkinson 2022-05-31 19:54:02 -07:00 committed by GitHub
parent 0faf41072a
commit b86213a66f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 12 deletions

View File

@ -110,15 +110,14 @@ end
function update_block(track) function update_block(track)
if should_block(track) then if should_block(track) then
if not track.blocked then track.blocked = true
track.blocked = true if os.execute("/usr/sbin/iptables -C input_lqm -p udp --destination-port 698 -m mac --mac-source " .. track.mac .. " -j DROP 2> /dev/null") ~= 0 then
os.execute("/usr/sbin/iptables -D input_lqm -p udp --destination-port 698 -m mac --mac-source " .. track.mac .. " -j DROP 2> /dev/null")
os.execute("/usr/sbin/iptables -I input_lqm -p udp --destination-port 698 -m mac --mac-source " .. track.mac .. " -j DROP 2> /dev/null") os.execute("/usr/sbin/iptables -I input_lqm -p udp --destination-port 698 -m mac --mac-source " .. track.mac .. " -j DROP 2> /dev/null")
return "blocked" return "blocked"
end end
else else
if track.blocked then track.blocked = false
track.blocked = false if os.execute("/usr/sbin/iptables -C input_lqm -p udp --destination-port 698 -m mac --mac-source " .. track.mac .. " -j DROP 2> /dev/null") == 0 then
os.execute("/usr/sbin/iptables -D input_lqm -p udp --destination-port 698 -m mac --mac-source " .. track.mac .. " -j DROP 2> /dev/null") os.execute("/usr/sbin/iptables -D input_lqm -p udp --destination-port 698 -m mac --mac-source " .. track.mac .. " -j DROP 2> /dev/null")
return "unblocked" return "unblocked"
end end
@ -126,6 +125,11 @@ function update_block(track)
return "unchanged" return "unchanged"
end end
function force_remove_block(track)
track.blocked = false
os.execute("/usr/sbin/iptables -D input_lqm -p udp --destination-port 698 -m mac --mac-source " .. track.mac .. " -j DROP 2> /dev/null")
end
-- Distance in meters between two points -- Distance in meters between two points
function calc_distance(lat1, lon1, lat2, lon2) function calc_distance(lat1, lon1, lat2, lon2)
local r2 = 12742000 -- diameter earth (meters) local r2 = 12742000 -- diameter earth (meters)
@ -522,7 +526,7 @@ function lqm()
track.blocks.user = false track.blocks.user = false
for val in string.gmatch(config.user_blocks, "([^,]+)") for val in string.gmatch(config.user_blocks, "([^,]+)")
do do
if val == track.mac then if val:gsub("%s+", ""):gsub("-", ":"):upper() == track.mac then
track.blocks.user = true track.blocks.user = true
break break
end end
@ -612,9 +616,7 @@ function lqm()
-- Remove any trackers which are too old or if they disconnect when first seen -- Remove any trackers which are too old or if they disconnect when first seen
if ((now > track.lastseen + lastseen_timeout) or (not is_connected(track) and track.firstseen + pending_timeout > now)) then if ((now > track.lastseen + lastseen_timeout) or (not is_connected(track) and track.firstseen + pending_timeout > now)) then
track.blocked = true; force_remove_block(track)
track.blocks = {}
update_block(track)
tracker[track.mac] = nil tracker[track.mac] = nil
end end
end end

View File

@ -839,9 +839,6 @@ if parms.button_save and not (#port_err > 0 or #dhcp_err > 0 or #dmz_err > 0 or
if not luci.sys.init.reload("firewall") then if not luci.sys.init.reload("firewall") then
err("problem with port setup") err("problem with port setup")
end end
if os.execute("/etc/init.d/manager restart") ~= 0 then
err("problem with manager")
end
-- This "luci.sys.init.restart("olsrd")" doesnt do the same thing so we have to call restart directly -- This "luci.sys.init.restart("olsrd")" doesnt do the same thing so we have to call restart directly
if os.execute("/etc/init.d/olsrd restart") ~= 0 then if os.execute("/etc/init.d/olsrd restart") ~= 0 then
err("problem with olsr setup") err("problem with olsr setup")