Skip to content

Commit

Permalink
Merge pull request #43 from croessner/features
Browse files Browse the repository at this point in the history
Add initial key expiry handling to monitoring.lua
  • Loading branch information
croessner authored Jul 8, 2024
2 parents ca9ca71 + 7c815cd commit 587643a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/lua-plugins.d/callback/callback.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function nauthilus_run_callback()
local redis_key = "ntc:DS:" .. crypto.md5(result.user)

if is_cmd_noop then
nauthilus.redis_expire(redis_key, 86400)
nauthilus.redis_expire(redis_key, 3600)
else
-- Cleanup dovecot session
---@type string deleted
Expand Down
17 changes: 17 additions & 0 deletions server/lua-plugins.d/filters/monitoring.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ function nauthilus_call_filter(request)
return nil
end

---@param redis_key string
---@return void
local function set_initial_expiry(redis_key)
---@type number length
---@type string err_redis_hlen
local length, err_redis_hlen = nauthilus.redis_hlen(redis_key)
if err_redis_hlen ~= nil then
nauthilus.custom_log_add("reids_hlen_failure", err_redis_hlen)
else
if length == 1 then
nauthilus.redis_expire(redis_key, 3600)
end
end
end

---@param session string
---@param server string
---@return void
Expand All @@ -27,6 +42,8 @@ function nauthilus_call_filter(request)
if err_redis_hset ~= nil then
nauthilus.custom_log_add("reids_hset_failure", err_redis_hset)
end

set_initial_expiry(redis_key)
end

local function get_server_from_sessions(session)
Expand Down

0 comments on commit 587643a

Please sign in to comment.