Module:IP: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
prevent access to IPAddress metatables, and add some more comments
(prevent altering of isSubnetObject by using __metatable with a unique key)
(prevent access to IPAddress metatables, and add some more comments)
Line 471:
end
end,
__metatable = false, -- Don't allow access to the metatable
})
end
Line 496 ⟶ 497:
 
do
-- uniqueKey is a unique, private key used to test whether a given object
-- is a Subnet object.
local uniqueKey = {}
 
Line 511 ⟶ 514:
-- Private static methods
local function isSubnetObject(val)
-- Return true if val is a Subnet object, and false otherwise.
return getmetatable(val) == uniqueKey
end
 
-- Function to validate subnet objects.
-- Params:
-- methodName (string) - the name of the method being validated
-- argIdx (number) - the position of the argument in the argument list
-- arg - the argument to be validated
validateSubnet = makeValidationFunc('Subnet', isSubnetObject)
 
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu