diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2010-10-30 17:56:06 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2010-10-30 17:56:06 +0000 |
commit | 95886d45851f34baf0d66a31f217661f21a81f88 (patch) | |
tree | fe23ae4de370a49fd9d8bfc3db58691a6c0b9b2d /libs | |
parent | ddd1ba088ed3b93b3485e34d05c427d43306c744 (diff) |
libs/core: use imatch() in firewall and network model
Diffstat (limited to 'libs')
-rw-r--r-- | libs/core/luasrc/model/firewall.lua | 18 | ||||
-rw-r--r-- | libs/core/luasrc/model/network.lua | 14 |
2 files changed, 6 insertions, 26 deletions
diff --git a/libs/core/luasrc/model/firewall.lua b/libs/core/luasrc/model/firewall.lua index 1baa2ce23..713fc5704 100644 --- a/libs/core/luasrc/model/firewall.lua +++ b/libs/core/luasrc/model/firewall.lua @@ -29,16 +29,6 @@ module "luci.model.firewall" local uci_r, uci_s -function _strlist(x) - if x == nil then - x = "" - elseif type(x) == "table" then - x = table.concat(x, " ") - end - - return x:gmatch("%S+") -end - function _valid_id(x) return (x and #x > 0 and x:match("^[a-zA-Z0-9_]+$")) end @@ -130,7 +120,7 @@ function get_zone_by_network(self, net) function(s) if s.name and net then local n - for n in _strlist(s.network or s.name) do + for n in utl.imatch(s.network or s.name) do if n == net then z = s['.name'] return false @@ -338,7 +328,7 @@ function zone.add_network(self, net) local nets = { } local n - for n in _strlist(self:get("network") or self:get("name")) do + for n in utl.imatch(self:get("network") or self:get("name")) do if n ~= net then nets[#nets+1] = n end @@ -358,7 +348,7 @@ function zone.del_network(self, net) local nets = { } local n - for n in _strlist(self:get("network") or self:get("name")) do + for n in utl.imatch(self:get("network") or self:get("name")) do if n ~= net then nets[#nets+1] = n end @@ -375,7 +365,7 @@ function zone.get_networks(self) local nets = { } local n - for n in _strlist(self:get("network") or self:get("name")) do + for n in utl.imatch(self:get("network") or self:get("name")) do nets[#nets+1] = n end diff --git a/libs/core/luasrc/model/network.lua b/libs/core/luasrc/model/network.lua index ed40dc2ff..bb98f8223 100644 --- a/libs/core/luasrc/model/network.lua +++ b/libs/core/luasrc/model/network.lua @@ -93,16 +93,6 @@ function _stror(s1, s2) end end -function _strlist(x) - if x == nil then - x = "" - elseif type(x) == "table" then - x = table.concat(x, " ") - end - - return x:gmatch("%S+") -end - function _get(c, s, o) return uci_r:get(c, s, o) end @@ -619,7 +609,7 @@ function network.get_interfaces(self) ifaces = { interface(ifn) } else local nfs = { } - for ifn in _strlist(self:get("ifname")) do + for ifn in utl.imatch(self:get("ifname")) do ifn = ifn:match("[^:]+") nfs[ifn] = interface(ifn) end @@ -661,7 +651,7 @@ function network.contains_interface(self, ifname) ifn = self:proto() .. "-" .. self.sid return ifname == ifn else - for ifn in _strlist(self:get("ifname")) do + for ifn in utl.imatch(self:get("ifname")) do ifn = ifn:match("[^:]+") if ifn == ifname then return true |