mirror of https://github.com/aredn/aredn.git
LQM fixes 6 (#379)
This commit is contained in:
parent
0faf41072a
commit
b86213a66f
|
@ -110,15 +110,14 @@ end
|
|||
|
||||
function update_block(track)
|
||||
if should_block(track) then
|
||||
if not track.blocked then
|
||||
track.blocked = true
|
||||
os.execute("/usr/sbin/iptables -D input_lqm -p udp --destination-port 698 -m mac --mac-source " .. track.mac .. " -j DROP 2> /dev/null")
|
||||
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 -I input_lqm -p udp --destination-port 698 -m mac --mac-source " .. track.mac .. " -j DROP 2> /dev/null")
|
||||
return "blocked"
|
||||
end
|
||||
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")
|
||||
return "unblocked"
|
||||
end
|
||||
|
@ -126,6 +125,11 @@ function update_block(track)
|
|||
return "unchanged"
|
||||
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
|
||||
function calc_distance(lat1, lon1, lat2, lon2)
|
||||
local r2 = 12742000 -- diameter earth (meters)
|
||||
|
@ -522,7 +526,7 @@ function lqm()
|
|||
track.blocks.user = false
|
||||
for val in string.gmatch(config.user_blocks, "([^,]+)")
|
||||
do
|
||||
if val == track.mac then
|
||||
if val:gsub("%s+", ""):gsub("-", ":"):upper() == track.mac then
|
||||
track.blocks.user = true
|
||||
break
|
||||
end
|
||||
|
@ -612,9 +616,7 @@ function lqm()
|
|||
|
||||
-- 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
|
||||
track.blocked = true;
|
||||
track.blocks = {}
|
||||
update_block(track)
|
||||
force_remove_block(track)
|
||||
tracker[track.mac] = nil
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
err("problem with port setup")
|
||||
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
|
||||
if os.execute("/etc/init.d/olsrd restart") ~= 0 then
|
||||
err("problem with olsr setup")
|
||||
|
|
Loading…
Reference in New Issue