diff options
author | Matthew Wild <mwild1@gmail.com> | 2023-03-14 18:23:33 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2023-03-14 18:23:33 +0000 |
commit | 3eedf79c8bd6555ebe601c67942af07aff3782a1 (patch) | |
tree | 67955602d364fb405b73930060563c109366747d | |
parent | 9c8b2f50990d4ab9f25e16a9adf211af236f3d75 (diff) | |
download | prosody-3eedf79c8bd6555ebe601c67942af07aff3782a1.tar.gz prosody-3eedf79c8bd6555ebe601c67942af07aff3782a1.zip |
util.ip: Add is_ip() helper method to detect if an object is an ip object
-rw-r--r-- | util/ip.lua | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/util/ip.lua b/util/ip.lua index 4b450934..5e20febe 100644 --- a/util/ip.lua +++ b/util/ip.lua @@ -241,9 +241,14 @@ function match(ipA, ipB, bits) return ipA.bits:sub(1, bits) == ipB.bits:sub(1, bits); end +local function is_ip(obj) + return getmetatable(obj) == ip_mt; +end + return { new_ip = new_ip, commonPrefixLength = commonPrefixLength, parse_cidr = parse_cidr, match = match, + is_ip = is_ip; }; |