Anonymous user
Module:IP: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
rework the IPRange class as an IPBlock class that deals with network blocks and returns CIDR strings
(more IPAddress metamethods) |
(rework the IPRange class as an IPBlock class that deals with network blocks and returns CIDR strings) |
||
Line 2:
-- This library contains classes for working with IP addresses and IP ranges.
-- Load modules
local libraryUtil = require('libraryUtil')
-- Constants
--------------------------------------------------------------------------------
Line 14 ⟶ 19:
-- Initialize metatable
local mt = {}
▲ local V4 = 'IPv4'
▲ local V6 = 'IPv6'
-- Constructor
Line 92 ⟶ 93:
--------------------------------------------------------------------------------
--
-- Represents a range of ipv4 or ipv6 addresses.
--------------------------------------------------------------------------------
local
do
Line 103 ⟶ 104:
-- Constructor
function
-- Set up structure
local mt = {}
local obj = setmetatable({}, mt)
local data = {}
return '1.2.3.4', '5.6.7.8'▼
-- Public methods
function obj:
end
function obj:
end
function obj:
end
function obj:
return
end
function obj:
return string.format('%s/%d', self:getPrefix(), self:getBitLength())
end
Line 161 ⟶ 146:
-- Set initial values
data.version = 4
Line 176 ⟶ 157:
function mt:__tostring()
return
end
end
Line 182 ⟶ 163:
return {
IPAddress = IPAddress,
}
|