Module:IP: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
373 bytes removed ,  7 years ago
actually, I like your version better - it's simple, it sidesteps the accuracy problem, and it probably isn't too much more overhead
(restore MAX_ITERATIONS that I missed)
(actually, I like your version better - it's simple, it sidesteps the accuracy problem, and it probably isn't too much more overhead)
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 501 ⟶ 496:
 
function obj:walk()
local count = 0started
local current = self:getPrefix()
local highest = self:getHighestIP()
return function ()
countif =not countstarted + 1then
if count started == 1 thentrue
return current
end
if count <= MAX_ITERATIONS and current < highest then
current = current:getNextIP()
return current
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu