Software /
code /
prosody
Comparison
util/ip.lua @ 12931:bbae3acc6694
util.ip: Add is_ip() helper method to detect if an object is an ip object
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 14 Mar 2023 18:23:33 +0000 |
parent | 12355:a0ff5c438e9d |
child | 12932:9bb044705ea1 |
comparison
equal
deleted
inserted
replaced
12930:a7b7cdec2b31 | 12931:bbae3acc6694 |
---|---|
239 end | 239 end |
240 end | 240 end |
241 return ipA.bits:sub(1, bits) == ipB.bits:sub(1, bits); | 241 return ipA.bits:sub(1, bits) == ipB.bits:sub(1, bits); |
242 end | 242 end |
243 | 243 |
244 local function is_ip(obj) | |
245 return getmetatable(obj) == ip_mt; | |
246 end | |
247 | |
244 return { | 248 return { |
245 new_ip = new_ip, | 249 new_ip = new_ip, |
246 commonPrefixLength = commonPrefixLength, | 250 commonPrefixLength = commonPrefixLength, |
247 parse_cidr = parse_cidr, | 251 parse_cidr = parse_cidr, |
248 match = match, | 252 match = match, |
253 is_ip = is_ip; | |
249 }; | 254 }; |