diff options
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | awall/iptables.lua | 24 | ||||
| -rw-r--r-- | awall/model.lua | 4 | 
3 files changed, 17 insertions, 15 deletions
@@ -1,9 +1,9 @@  # Installer Makefile for Alpine Wall -# Copyright (C) 2012-2018 Kaarle Ritvanen +# Copyright (C) 2012-2020 Kaarle Ritvanen  # See LICENSE file for license details  ROOT_DIR := / -LUA_VERSION := 5.2 +LUA_VERSION := 5.3  resdir := usr/share/awall  confdir := etc/awall diff --git a/awall/iptables.lua b/awall/iptables.lua index cb19ff8..3a8a755 100644 --- a/awall/iptables.lua +++ b/awall/iptables.lua @@ -106,17 +106,19 @@ function BaseIPTables:flush() M.flush() end  M.IPTables = class(BaseIPTables)  function M.IPTables:init() -   self.config = {} -   setmetatable( -      self.config, -      { -	 __index=function(t, k) -	    t[k] = {} -	    setmetatable(t[k], getmetatable(t)) -	    return t[k] -	 end -      } -   ) +   local function nestedtable(levels) +      return levels > 0 and setmetatable( +	 {}, +	 { +	    __index=function(t, k) +	       t[k] = nestedtable(getmetatable(t).levels - 1) +	       return t[k] +	    end, +	    levels=levels +	 } +      ) or {} +   end +   self.config = nestedtable(3)  end  function M.IPTables:dumpfile(family, iptfile) diff --git a/awall/model.lua b/awall/model.lua index b6acd69..5a2b870 100644 --- a/awall/model.lua +++ b/awall/model.lua @@ -733,14 +733,14 @@ function M.Maskable:recentmask(name)  	 for i = 0, 3 do  	    if len <= i * 8 then octet = 0  	    elseif len > i * 8 + 7 then octet = 255 -	    else octet = 256 - 2^(8 - len % 8) end +	    else octet = 256 - math.floor(2^(8 - len % 8)) end  	    mask = util.join(mask, '.', octet)  	 end        elseif family == 'inet6' then  	 while len > 0 do  	    if #mask % 5 == 4 then mask = mask..':' end -	    mask = mask..('%x'):format(16 - 2^math.max(0, 4 - len)) +	    mask = mask..('%x'):format(16 - math.floor(2^math.max(0, 4 - len)))  	    len = len - 4  	 end  	 while #mask % 5 < 4 do mask = mask..'0' end  | 
