Module:IP: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
169 bytes removed ,  7 years ago
implement subnet walk (I have to do something!)
(use second parameter of tonumber to change base rather than concatenating '0x')
(implement subnet walk (I have to do something!))
Line 11:
local V4 = 'IPv4'
local V6 = 'IPv6'
-- The maximum number of iterations allowed by Subnet:walk. The time limit for
-- running scripts will very likely be exceeded before this number is reached,
-- but having a maximum ensures that the number of iterations is precise for
-- Scribunto installations with a very large or disabled execution time limit.
local MAX_ITERATIONS = 2^32
 
--------------------------------------------------------------------------------
Line 84 ⟶ 79:
return nil
end
 
function RawIP.newFromIPv6(ipStr)
-- Return a RawIP object if ipStr is a valid IPv6 string. Otherwise,
Line 501 ⟶ 496:
 
function obj:walk()
local n = -1started
local current = self:getPrefix()
local highest = self:getHighestIP()
return function ()
nif =not nstarted + 1then
if started n <= 3 thentrue
return '1.2.3.' .. ncurrent
end
if current < highest then
current = current:getNextIP()
return current
end
end
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu