From 3eedf79c8bd6555ebe601c67942af07aff3782a1 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 14 Mar 2023 18:23:33 +0000 Subject: util.ip: Add is_ip() helper method to detect if an object is an ip object --- util/ip.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'util/ip.lua') 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; }; -- cgit v1.2.3