From 46676a465037c20b761b02d716fe30fdfd0a3f14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= Date: Mon, 17 Feb 2020 18:24:58 +0000 Subject: fix cross-family sorting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Asbjørn Sloth Tønnesen --- lua/inet/core.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'lua') diff --git a/lua/inet/core.lua b/lua/inet/core.lua index 7037885..5008da9 100644 --- a/lua/inet/core.lua +++ b/lua/inet/core.lua @@ -360,6 +360,7 @@ function inet4:clone() end function inet4:contains(other) + if is_inet6(other) then return false end if self.mask >= other.mask then return false end @@ -370,6 +371,12 @@ function inet4:contains(other) end function inet4:__lt(other) + if not is_inet4(other) then + if is_inet6(other) then + return true + end + return nil + end if self.bip == other.bip then return self.mask < other.mask end @@ -377,6 +384,12 @@ function inet4:__lt(other) end function inet4:__le(other) + if not is_inet4(other) then + if is_inet6(other) then + return true + end + return nil + end if self.mask < other.mask then return false end @@ -391,6 +404,7 @@ function inet4:__le(other) end function inet4:__eq(other) + if getmetatable(other) ~= inet4 then return false end return self.bip == other.bip and self.mask == other.mask end @@ -603,6 +617,12 @@ function inet6:contains(other) end function inet6:__lt(other) + if not is_inet6(other) then + if is_inet4(other) then + return false + end + return nil + end -- self < other local spcs = self.pcs local opcs = other.pcs @@ -620,6 +640,12 @@ function inet6:__lt(other) end function inet6:__le(other) + if not is_inet6(other) then + if is_inet4(other) then + return false + end + return nil + end -- self <= other local spcs = self.pcs local opcs = other.pcs -- cgit v1.2.1