Soft whitelisting
Features like brute_force, relay_domains and rbl support soft whitelists. You can dynamically adjust these lists from within Lua.
dynamic_loader("nauthilus_soft_whitelist")
local nauthilus_soft_whitelist = require("nauthilus_soft_whitelist")
nauthilus_soft_whitelist.soft_whitelist_set
Adds or replaces a soft whitelist entry for a specific username, network, and feature.
Syntax
local err = nauthilus_soft_whitelist.soft_whitelist_set(username, network, feature)
Parameters
username
(string): The username to whitelistnetwork
(string): A valid network with CIDR notation (e.g., "192.168.0.0/24")feature
(string): The feature to whitelist for (e.g., "brute_force", "relay_domains", "rbl")
Returns
err
(string): An error message if the operation fails, nil on success
Example
dynamic_loader("nauthilus_soft_whitelist")
local nauthilus_soft_whitelist = require("nauthilus_soft_whitelist")
local username = "testuser"
local network = "192.168.0.0/24"
local feature = "brute_force"
local err = nauthilus_soft_whitelist.soft_whitelist_set(username, network, feature)
if err then
print("Error:", err)
else
print("Successfully added whitelist entry")
end
nauthilus_soft_whitelist.soft_whitelist_get
Retrieves all associated networks for a given username and feature.
Syntax
local networks = nauthilus_soft_whitelist.soft_whitelist_get(username, feature)
Parameters
username
(string): The username to look upfeature
(string): The feature to get whitelists for (e.g., "brute_force", "relay_domains", "rbl")
Returns
networks
(table): A Lua table containing all whitelisted networks for the specified username and feature
Example
dynamic_loader("nauthilus_soft_whitelist")
local nauthilus_soft_whitelist = require("nauthilus_soft_whitelist")
local username = "testuser"
local feature = "brute_force"
local result_table = nauthilus_soft_whitelist.soft_whitelist_get(username, feature)
-- result_table will be { [1] = "192.168.0.0/24" } if that network is whitelisted
for i, network in ipairs(result_table) do
print("Whitelisted network:", network)
end
nauthilus_soft_whitelist.soft_whitelist_delete
Removes a network from the whitelist for a given username and feature.
Syntax
nauthilus_soft_whitelist.soft_whitelist_delete(username, network, feature)
Parameters
username
(string): The username to modifynetwork
(string): The network to remove from the whitelistfeature
(string): The feature to remove the whitelist from
Returns
None
Example
dynamic_loader("nauthilus_soft_whitelist")
local nauthilus_soft_whitelist = require("nauthilus_soft_whitelist")
local username = "testuser"
local network = "192.168.0.0/24"
local feature = "brute_force"
nauthilus_soft_whitelist.soft_whitelist_delete(username, network, feature)
-- Will remove the network "192.168.0.0/24" from the user's whitelist