Module:IP: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
(add check self functions to Subnet) |
(validate ip in subnet:containsIP(ip) and accept a string, like ip:isInSubnet(subnet)) |
||
Line 583: | Line 583: | ||
function obj:containsIP(ip) |
function obj:containsIP(ip) |
||
checkSelf(self, 'containsIP') |
checkSelf(self, 'containsIP') |
||
local tp = type(ip) |
|||
if tp == 'string' then |
|||
ip = makeIPAddress(ip) |
|||
elseif tp == 'table' then |
|||
validateIPAddress('containsIP', 1, ip) |
|||
else |
|||
checkTypeMulti('containsIP', 1, ip, {'string', 'table'}) |
|||
end |
|||
if self:getVersion() == ip:getVersion() then |
if self:getVersion() == ip:getVersion() then |
||
return self:getPrefix() <= ip and ip <= self:getHighestIP() |
return self:getPrefix() <= ip and ip <= self:getHighestIP() |