# HG changeset patch # User Matthew Wild # Date 1773788919 0 # Node ID 88852e4f81bf5362f3afc318b53b4931c0ae654c # Parent 4a1c17a5745fa49233b299c17015ea29eeee7f1a mod_s2s_v6mesh: Add is_secure_range shell command to check IP addresses diff -r 4a1c17a5745f -r 88852e4f81bf mod_s2s_v6mesh/mod_s2s_v6mesh.lua --- 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; +});