mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 23:49:33 +00:00
Logout code cleanupo
This commit is contained in:
parent
501f1edf2d
commit
b022e10f6a
2 changed files with 56 additions and 22 deletions
|
|
@ -8,11 +8,62 @@ package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
|||
require "lua_utils"
|
||||
|
||||
local page_utils = require("page_utils")
|
||||
local host_pools_nedge = require "host_pools_nedge"
|
||||
|
||||
local prefs = ntop.getPrefs()
|
||||
|
||||
local captive_portal_utils = {}
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function captive_portal_utils.is_logged(ip)
|
||||
local member = ip
|
||||
|
||||
local host_info = interface.getHostInfo(member)
|
||||
if not host_info then
|
||||
return false
|
||||
end
|
||||
|
||||
local pool_id = host_info.host_pool_id
|
||||
if pool_id == host_pools_nedge.DEFAULT_POOL_ID then
|
||||
tprint(pool_id)
|
||||
-- already logged out
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function captive_portal_utils.logout(ip)
|
||||
local member = ip
|
||||
|
||||
local host_info = interface.getHostInfo(member)
|
||||
if not host_info then
|
||||
return
|
||||
end
|
||||
|
||||
local pool_id = host_info.host_pool_id
|
||||
|
||||
if pool_id == host_pools_nedge.DEFAULT_POOL_ID then
|
||||
-- already logged out
|
||||
return
|
||||
end
|
||||
|
||||
if prefs.is_mac_based_captive_portal then
|
||||
member = host_info.mac
|
||||
if not member then
|
||||
return -- unable to find mac
|
||||
end
|
||||
end
|
||||
|
||||
host_pools_nedge.deletePoolMemberFromAllPools(member)
|
||||
ntop.reloadHostPools()
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function captive_portal_utils.get_style()
|
||||
return [[
|
||||
<style type="text/css">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue