summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--LICENSE2
-rw-r--r--aconf/model/net.lua6
2 files changed, 4 insertions, 4 deletions
diff --git a/LICENSE b/LICENSE
index 495807a..611da68 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2012-2018 Kaarle Ritvanen
+Copyright (c) 2012-2019 Kaarle Ritvanen
All rights reserved.
diff --git a/aconf/model/net.lua b/aconf/model/net.lua
index 57eb3ea..f01c4c6 100644
--- a/aconf/model/net.lua
+++ b/aconf/model/net.lua
@@ -1,5 +1,5 @@
--[[
-Copyright (c) 2012-2016 Kaarle Ritvanen
+Copyright (c) 2012-2019 Kaarle Ritvanen
See LICENSE file for license details
--]]
@@ -108,7 +108,7 @@ end
function M.IPv4Address:mask2cidr(mask)
local acc = 0
for i, comp in ipairs(stringy.split(mask, '.')) do
- acc = acc + math.pow(256, 4 - i) * tonumber(comp)
+ acc = acc + math.floor(256 ^ (4 - i)) * tonumber(comp)
end
local res = 32
while acc % 2 == 0 do
@@ -120,7 +120,7 @@ function M.IPv4Address:mask2cidr(mask)
end
function M.IPv4Address:cidr2mask(cidr)
- local acc = (math.pow(2, cidr) - 1) * math.pow(2, 32 - cidr)
+ local acc = (math.floor(2 ^ cidr) - 1) * math.floor(2 ^ (32 - cidr))
local comps = {}
for i = 4,1,-1 do
comps[i] = acc % 256