Mercurial > prosody-hg
comparison util/ip.lua @ 8438:499663bd0122
util.ip: Do exact match for longer bit counts than available
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 01 Dec 2017 03:31:37 +0100 |
| parents | 021129f7b0a3 |
| children | 293dbb08427b |
comparison
equal
deleted
inserted
replaced
| 8437:021129f7b0a3 | 8438:499663bd0122 |
|---|---|
| 226 end | 226 end |
| 227 return new_ip(cidr), bits; | 227 return new_ip(cidr), bits; |
| 228 end | 228 end |
| 229 | 229 |
| 230 function match(ipA, ipB, bits) | 230 function match(ipA, ipB, bits) |
| 231 if not bits then | 231 if not bits or bits >= 128 or ipB.proto == "IPv4" and bits >= 32 then |
| 232 return ipA == ipB; | 232 return ipA == ipB; |
| 233 elseif bits < 1 then | 233 elseif bits < 1 then |
| 234 return true; | 234 return true; |
| 235 end | 235 end |
| 236 if ipA.proto ~= ipB.proto then | 236 if ipA.proto ~= ipB.proto then |
