X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=util%2Fip.lua;h=7dcace5cac35d8ec271a4fd2328ce58b7e020fcc;hb=9fd7abf8b5ad419803144a4cdb3c553db90d17e3;hp=62649c9b8567d6afe1aacc85d0aa91b7948245db;hpb=f4c6d4483110defc36d9e25b820a2d7e70565f15;p=prosody.git diff --git a/util/ip.lua b/util/ip.lua index 62649c9b..7dcace5c 100644 --- a/util/ip.lua +++ b/util/ip.lua @@ -92,7 +92,7 @@ local function v6scope(ip) if ip:match("^[0:]*1$") then return 0x2; -- Link-local unicast: - elseif ip:match("^[Ff][Ee][89ABab]") then + elseif ip:match("^[Ff][Ee][89ABab]") then return 0x2; -- Site-local unicast: elseif ip:match("^[Ff][Ee][CcDdEeFf]") then @@ -229,13 +229,10 @@ end local function match(ipA, ipB, bits) local common_bits = commonPrefixLength(ipA, ipB); - if not bits then - return ipA == ipB; - end if bits and ipB.proto == "IPv4" then common_bits = common_bits - 96; -- v6 mapped addresses always share these bits end - return common_bits >= bits; + return common_bits >= (bits or 128); end return {new_ip = new_ip,