Mercurial > prosody-modules
changeset 6477:88852e4f81bf
mod_s2s_v6mesh: Add is_secure_range shell command to check IP addresses
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 17 Mar 2026 23:08:39 +0000 |
| parents | 4a1c17a5745f |
| children | bd785f524fd2 |
| files | mod_s2s_v6mesh/mod_s2s_v6mesh.lua |
| diffstat | 1 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_s2s_v6mesh/mod_s2s_v6mesh.lua Tue Mar 17 23:08:08 2026 +0000 +++ b/mod_s2s_v6mesh/mod_s2s_v6mesh.lua Tue Mar 17 23:08:39 2026 +0000 @@ -148,3 +148,29 @@ return true, ("IP address: %s"):format(user_ip); end; }); + +module:add_item("shell-command", { + section = "v6alt"; + section_desc = module.name.." utility commands"; + name = "is_secure_range"; + desc = "Check whether an IP address is considered secure"; + args = { + { name = "host", type = "string" }; + { name = "ip", type = "string" }; + }; + host_selector = "host"; + handler = function(self, host, ip_str) --luacheck: ignore 212/self 212/host + local user_ip = ip.new_ip(ip_str, "IPv6"); + if not user_ip then + return nil, "Invalid IP address: "..tostring(ip_str); + end + + local secure, range = is_secure_range(user_ip); + + if not secure then + return true, "Not secure"; + end + + return true, ("In secure range: %s"):format(range); + end; +});
