diff options
Diffstat (limited to 'modules/luci-base/luasrc')
-rw-r--r-- | modules/luci-base/luasrc/model/network.lua | 168 | ||||
-rw-r--r-- | modules/luci-base/luasrc/sys/iptparser.lua | 36 | ||||
-rw-r--r-- | modules/luci-base/luasrc/sys/zoneinfo/tzdata.lua | 101 | ||||
-rw-r--r-- | modules/luci-base/luasrc/sys/zoneinfo/tzoffset.lua | 41 | ||||
-rw-r--r-- | modules/luci-base/luasrc/tools/status.lua | 7 | ||||
-rw-r--r-- | modules/luci-base/luasrc/tools/webadmin.lua | 2 | ||||
-rw-r--r-- | modules/luci-base/luasrc/util.lua | 19 | ||||
-rw-r--r-- | modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm | 4 | ||||
-rw-r--r-- | modules/luci-base/luasrc/view/cbi/fvalue.htm | 1 | ||||
-rw-r--r-- | modules/luci-base/luasrc/view/cbi/lvalue.htm | 3 | ||||
-rw-r--r-- | modules/luci-base/luasrc/view/cbi/mvalue.htm | 3 | ||||
-rw-r--r-- | modules/luci-base/luasrc/view/cbi/network_ifacelist.htm | 12 | ||||
-rw-r--r-- | modules/luci-base/luasrc/view/cbi/network_netlist.htm | 3 | ||||
-rw-r--r-- | modules/luci-base/luasrc/view/sysauth.htm | 8 |
14 files changed, 240 insertions, 168 deletions
diff --git a/modules/luci-base/luasrc/model/network.lua b/modules/luci-base/luasrc/model/network.lua index 9cd7c87c0c..2d8336bf33 100644 --- a/modules/luci-base/luasrc/model/network.lua +++ b/modules/luci-base/luasrc/model/network.lua @@ -30,7 +30,7 @@ protocol = utl.class() local _protocols = { } -local _interfaces, _bridge, _switch, _tunnel +local _interfaces, _bridge, _switch, _tunnel, _swtopo local _ubusnetcache, _ubusdevcache, _ubuswificache local _uci @@ -193,7 +193,6 @@ function _iface_ignore(x) return false end - function init(cursor) _uci = cursor or _uci or uci.cursor() @@ -201,6 +200,7 @@ function init(cursor) _bridge = { } _switch = { } _tunnel = { } + _swtopo = { } _ubusnetcache = { } _ubusdevcache = { } @@ -210,7 +210,6 @@ function init(cursor) local n, i for n, i in ipairs(nxo.getifaddrs()) do local name = i.name:match("[^:]+") - local prnt = name:match("^([^%.]+)%.") if _iface_virtual(name) then _tunnel[name] = true @@ -226,11 +225,6 @@ function init(cursor) ip6addrs = { } } - if prnt then - _switch[name] = true - _switch[prnt] = true - end - if i.family == "packet" then _interfaces[name].flags = i.flags _interfaces[name].stats = i.data @@ -266,6 +260,79 @@ function init(cursor) end end + -- read switch topology + local boardinfo = jsc.parse(nfs.readfile("/etc/board.json") or "") + if type(boardinfo) == "table" and type(boardinfo.switch) == "table" then + local switch, layout + for switch, layout in pairs(boardinfo.switch) do + if type(layout) == "table" and type(layout.ports) == "table" then + local _, port + local ports = { } + local nports = { } + local netdevs = { } + + for _, port in ipairs(layout.ports) do + if type(port) == "table" and + type(port.num) == "number" and + (type(port.role) == "string" or + type(port.device) == "string") + then + local spec = { + num = port.num, + role = port.role or "cpu", + index = port.index or port.num + } + + if port.device then + spec.device = port.device + spec.tagged = port.need_tag + netdevs[tostring(port.num)] = port.device + end + + ports[#ports+1] = spec + + if port.role then + nports[port.role] = (nports[port.role] or 0) + 1 + end + end + end + + table.sort(ports, function(a, b) + if a.role ~= b.role then + return (a.role < b.role) + end + + return (a.index < b.index) + end) + + local pnum, role + for _, port in ipairs(ports) do + if port.role ~= role then + role = port.role + pnum = 1 + end + + if role == "cpu" then + port.label = "CPU (%s)" % port.device + elseif nports[role] > 1 then + port.label = "%s %d" %{ role:upper(), pnum } + pnum = pnum + 1 + else + port.label = role:upper() + end + + port.role = nil + port.index = nil + end + + _swtopo[switch] = { + ports = ports, + netdevs = netdevs + } + end + end + end + return _M end @@ -474,41 +541,23 @@ function get_interface(self, i) end end -local function swdev_from_board_json() - local boardinfo = jsc.parse(nfs.readfile("/etc/board.json") or "") - if type(boardinfo) == "table" and type(boardinfo.network) == "table" then - local net, val - for net, val in pairs(boardinfo.network) do - if type(val) == "table" and type(val.ifname) == "string" and - val.create_vlan == true - then - return val.ifname - end - end - end - return nil -end - function get_interfaces(self) local iface local ifaces = { } - local seen = { } local nfs = { } - local baseof = { } -- find normal interfaces _uci:foreach("network", "interface", function(s) for iface in utl.imatch(s.ifname) do if not _iface_ignore(iface) and not _iface_virtual(iface) and not _wifi_iface(iface) then - seen[iface] = true nfs[iface] = interface(iface) end end end) for iface in utl.kspairs(_interfaces) do - if not (seen[iface] or _iface_ignore(iface) or _iface_virtual(iface) or _wifi_iface(iface)) then + if not (nfs[iface] or _iface_ignore(iface) or _iface_virtual(iface) or _wifi_iface(iface)) then nfs[iface] = interface(iface) end end @@ -516,34 +565,32 @@ function get_interfaces(self) -- find vlan interfaces _uci:foreach("network", "switch_vlan", function(s) - if not s.device then + if type(s.ports) ~= "string" or + type(s.device) ~= "string" or + type(_swtopo[s.device]) ~= "table" + then return end - local base = baseof[s.device] - if not base then - if not s.device:match("^eth%d") then - local l - for l in utl.execi("swconfig dev %q help 2>/dev/null" % s.device) do - if not base then - base = l:match("^%w+: (%w+)") - end + local pnum, ptag + for pnum, ptag in s.ports:gmatch("(%d+)([tu]?)") do + local netdev = _swtopo[s.device].netdevs[pnum] + if netdev then + if not nfs[netdev] then + nfs[netdev] = interface(netdev) end - if not base or not base:match("^eth%d") then - base = swdev_from_board_json() or "eth0" + _switch[netdev] = true + + if ptag == "t" then + local vid = tonumber(s.vid or s.vlan) + if vid ~= nil and vid >= 0 and vid <= 4095 then + local iface = "%s.%d" %{ netdev, vid } + if not nfs[iface] then + nfs[iface] = interface(iface) + end + _switch[iface] = true + end end - else - base = s.device - end - baseof[s.device] = base - end - - local vid = tonumber(s.vid or s.vlan) - if vid ~= nil and vid >= 0 and vid <= 4095 then - local iface = "%s.%d" %{ base, vid } - if not seen[iface] then - seen[iface] = true - nfs[iface] = interface(iface) end end end) @@ -685,6 +732,10 @@ function get_wan6dev(self) return stat and interface(stat.l3_device or stat.device) end +function get_switch_topologies(self) + return _swtopo +end + function network(name, proto) if name then @@ -1140,10 +1191,7 @@ end function interface.shortname(self) if self.wif then - return "%s %q" %{ - self.wif:active_mode(), - self.wif:active_ssid() or self.wif:active_bssid() - } + return self.wif:shortname() else return self.ifname end @@ -1154,7 +1202,7 @@ function interface.get_i18n(self) return "%s: %s %q" %{ lng.translate("Wireless Network"), self.wif:active_mode(), - self.wif:active_ssid() or self.wif:active_bssid() + self.wif:active_ssid() or self.wif:active_bssid() or self.wif:id() } else return "%s: %q" %{ self:get_type_i18n(), self:name() } @@ -1170,7 +1218,11 @@ function interface.get_type_i18n(self) elseif x == "switch" then return lng.translate("Ethernet Switch") elseif x == "vlan" then - return lng.translate("VLAN Interface") + if _switch[self.ifname] then + return lng.translate("Switch VLAN") + else + return lng.translate("Software VLAN") + end elseif x == "tunnel" then return lng.translate("Tunnel Interface") else @@ -1593,7 +1645,7 @@ end function wifinet.shortname(self) return "%s %q" %{ lng.translate(self:active_mode()), - self:active_ssid() or self:active_bssid() + self:active_ssid() or self:active_bssid() or self:id() } end @@ -1601,7 +1653,7 @@ function wifinet.get_i18n(self) return "%s: %s %q (%s)" %{ lng.translate("Wireless Network"), lng.translate(self:active_mode()), - self:active_ssid() or self:active_bssid(), + self:active_ssid() or self:active_bssid() or self:id(), self:ifname() } end diff --git a/modules/luci-base/luasrc/sys/iptparser.lua b/modules/luci-base/luasrc/sys/iptparser.lua index a9dbc30826..7ff665e7af 100644 --- a/modules/luci-base/luasrc/sys/iptparser.lua +++ b/modules/luci-base/luasrc/sys/iptparser.lua @@ -31,29 +31,43 @@ function IptParser.__init__( self, family ) self._family = (tonumber(family) == 6) and 6 or 4 self._rules = { } self._chains = { } + self._tables = { } + + local t = self._tables + local s = self:_supported_tables(self._family) + + if s.filter then t[#t+1] = "filter" end + if s.nat then t[#t+1] = "nat" end + if s.mangle then t[#t+1] = "mangle" end + if s.raw then t[#t+1] = "raw" end if self._family == 4 then self._nulladdr = "0.0.0.0/0" - self._tables = { "filter", "nat", "mangle", "raw" } self._command = "iptables -t %s --line-numbers -nxvL" else self._nulladdr = "::/0" - self._tables = { "filter", "mangle", "raw" } - local ok, lines = pcall(io.lines, "/proc/net/ip6_tables_names") - if ok and lines then - local line - for line in lines do - if line == "nat" then - self._tables = { "filter", "nat", "mangle", "raw" } - end - end - end self._command = "ip6tables -t %s --line-numbers -nxvL" end self:_parse_rules() end +function IptParser._supported_tables( self, family ) + local tables = { } + local ok, lines = pcall(io.lines, + (family == 6) and "/proc/net/ip6_tables_names" + or "/proc/net/ip_tables_names") + + if ok and lines then + local line + for line in lines do + tables[line] = true + end + end + + return tables +end + -- search criteria as only argument. If args is nil or an empty table then all -- rules will be returned. -- diff --git a/modules/luci-base/luasrc/sys/zoneinfo/tzdata.lua b/modules/luci-base/luasrc/sys/zoneinfo/tzdata.lua index c9a507eaa2..465d7df3d3 100644 --- a/modules/luci-base/luasrc/sys/zoneinfo/tzdata.lua +++ b/modules/luci-base/luasrc/sys/zoneinfo/tzdata.lua @@ -87,7 +87,7 @@ TZ = { { 'America/Cambridge Bay', 'MST7MDT,M3.2.0,M11.1.0' }, { 'America/Campo Grande', 'AMT4AMST,M10.3.0/0,M2.3.0/0' }, { 'America/Cancun', 'EST5' }, - { 'America/Caracas', 'VET4:30' }, + { 'America/Caracas', 'VET4' }, { 'America/Cayenne', 'GFT3' }, { 'America/Cayman', 'EST5' }, { 'America/Chicago', 'CST6CDT,M3.2.0,M11.1.0' }, @@ -201,97 +201,100 @@ TZ = { { 'America/Winnipeg', 'CST6CDT,M3.2.0,M11.1.0' }, { 'America/Yakutat', 'AKST9AKDT,M3.2.0,M11.1.0' }, { 'America/Yellowknife', 'MST7MDT,M3.2.0,M11.1.0' }, - { 'Antarctica/Casey', 'AWST-8' }, - { 'Antarctica/Davis', 'DAVT-7' }, - { 'Antarctica/DumontDUrville', 'DDUT-10' }, + { 'Antarctica/Casey', '<+11>-11' }, + { 'Antarctica/Davis', '<+07>-7' }, + { 'Antarctica/DumontDUrville', '<+10>-10' }, { 'Antarctica/Macquarie', 'MIST-11' }, - { 'Antarctica/Mawson', 'MAWT-5' }, + { 'Antarctica/Mawson', '<+05>-5' }, { 'Antarctica/McMurdo', 'NZST-12NZDT,M9.5.0,M4.1.0/3' }, { 'Antarctica/Palmer', 'CLT4CLST,M8.2.6/24,M5.2.6/24' }, - { 'Antarctica/Rothera', 'ROTT3' }, - { 'Antarctica/Syowa', 'SYOT-3' }, - { 'Antarctica/Troll', 'UTC0CEST-2,M3.5.0/1,M10.5.0/3' }, - { 'Antarctica/Vostok', 'VOST-6' }, + { 'Antarctica/Rothera', '<-03>3' }, + { 'Antarctica/Syowa', '<+03>-3' }, + { 'Antarctica/Troll', '<+00>0<+02>-2,M3.5.0/1,M10.5.0/3' }, + { 'Antarctica/Vostok', '<+06>-6' }, { 'Arctic/Longyearbyen', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Asia/Aden', 'AST-3' }, - { 'Asia/Almaty', 'ALMT-6' }, + { 'Asia/Almaty', '<+06>-6' }, { 'Asia/Amman', 'EET-2EEST,M3.5.4/24,M10.5.5/1' }, - { 'Asia/Anadyr', 'ANAT-12' }, - { 'Asia/Aqtau', 'AQTT-5' }, - { 'Asia/Aqtobe', 'AQTT-5' }, - { 'Asia/Ashgabat', 'TMT-5' }, + { 'Asia/Anadyr', '<+12>-12' }, + { 'Asia/Aqtau', '<+05>-5' }, + { 'Asia/Aqtobe', '<+05>-5' }, + { 'Asia/Ashgabat', '<+05>-5' }, + { 'Asia/Atyrau', '<+05>-5' }, { 'Asia/Baghdad', 'AST-3' }, { 'Asia/Bahrain', 'AST-3' }, - { 'Asia/Baku', 'AZT-4' }, + { 'Asia/Baku', '<+04>-4' }, { 'Asia/Bangkok', 'ICT-7' }, { 'Asia/Barnaul', '<+07>-7' }, { 'Asia/Beirut', 'EET-2EEST,M3.5.0/0,M10.5.0/0' }, - { 'Asia/Bishkek', 'KGT-6' }, + { 'Asia/Bishkek', '<+06>-6' }, { 'Asia/Brunei', 'BNT-8' }, - { 'Asia/Chita', 'YAKT-9' }, + { 'Asia/Chita', '<+09>-9' }, { 'Asia/Choibalsan', 'CHOT-8CHOST,M3.5.6,M9.5.6/0' }, - { 'Asia/Colombo', 'IST-5:30' }, + { 'Asia/Colombo', '<+0530>-5:30' }, { 'Asia/Damascus', 'EET-2EEST,M3.5.5/0,M10.5.5/0' }, { 'Asia/Dhaka', 'BDT-6' }, { 'Asia/Dili', 'TLT-9' }, { 'Asia/Dubai', 'GST-4' }, - { 'Asia/Dushanbe', 'TJT-5' }, - { 'Asia/Gaza', 'EET-2EEST,M3.5.6/1,M10.3.6/144' }, - { 'Asia/Hebron', 'EET-2EEST,M3.5.6/1,M10.3.6/144' }, + { 'Asia/Dushanbe', '<+05>-5' }, + { 'Asia/Famagusta', '<+03>-3' }, + { 'Asia/Gaza', 'EET-2EEST,M3.5.6/1,M10.5.6/1' }, + { 'Asia/Hebron', 'EET-2EEST,M3.5.6/1,M10.5.6/1' }, { 'Asia/Ho Chi Minh', 'ICT-7' }, { 'Asia/Hong Kong', 'HKT-8' }, { 'Asia/Hovd', 'HOVT-7HOVST,M3.5.6,M9.5.6/0' }, - { 'Asia/Irkutsk', 'IRKT-8' }, + { 'Asia/Irkutsk', '<+08>-8' }, { 'Asia/Jakarta', 'WIB-7' }, { 'Asia/Jayapura', 'WIT-9' }, { 'Asia/Jerusalem', 'IST-2IDT,M3.4.4/26,M10.5.0' }, { 'Asia/Kabul', 'AFT-4:30' }, - { 'Asia/Kamchatka', 'PETT-12' }, + { 'Asia/Kamchatka', '<+12>-12' }, { 'Asia/Karachi', 'PKT-5' }, { 'Asia/Kathmandu', 'NPT-5:45' }, - { 'Asia/Khandyga', 'YAKT-9' }, + { 'Asia/Khandyga', '<+09>-9' }, { 'Asia/Kolkata', 'IST-5:30' }, - { 'Asia/Krasnoyarsk', 'KRAT-7' }, + { 'Asia/Krasnoyarsk', '<+07>-7' }, { 'Asia/Kuala Lumpur', 'MYT-8' }, { 'Asia/Kuching', 'MYT-8' }, { 'Asia/Kuwait', 'AST-3' }, { 'Asia/Macau', 'CST-8' }, - { 'Asia/Magadan', 'MAGT-10' }, + { 'Asia/Magadan', '<+11>-11' }, { 'Asia/Makassar', 'WITA-8' }, { 'Asia/Manila', 'PHT-8' }, { 'Asia/Muscat', 'GST-4' }, { 'Asia/Nicosia', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, - { 'Asia/Novokuznetsk', 'KRAT-7' }, - { 'Asia/Novosibirsk', 'NOVT-6' }, - { 'Asia/Omsk', 'OMST-6' }, - { 'Asia/Oral', 'ORAT-5' }, + { 'Asia/Novokuznetsk', '<+07>-7' }, + { 'Asia/Novosibirsk', '<+07>-7' }, + { 'Asia/Omsk', '<+06>-6' }, + { 'Asia/Oral', '<+05>-5' }, { 'Asia/Phnom Penh', 'ICT-7' }, { 'Asia/Pontianak', 'WIB-7' }, { 'Asia/Pyongyang', 'KST-8:30' }, { 'Asia/Qatar', 'AST-3' }, - { 'Asia/Qyzylorda', 'QYZT-6' }, - { 'Asia/Rangoon', 'MMT-6:30' }, + { 'Asia/Qyzylorda', '<+06>-6' }, { 'Asia/Riyadh', 'AST-3' }, - { 'Asia/Sakhalin', 'SAKT-11' }, - { 'Asia/Samarkand', 'UZT-5' }, + { 'Asia/Sakhalin', '<+11>-11' }, + { 'Asia/Samarkand', '<+05>-5' }, { 'Asia/Seoul', 'KST-9' }, { 'Asia/Shanghai', 'CST-8' }, { 'Asia/Singapore', 'SGT-8' }, - { 'Asia/Srednekolymsk', 'SRET-11' }, + { 'Asia/Srednekolymsk', '<+11>-11' }, { 'Asia/Taipei', 'CST-8' }, - { 'Asia/Tashkent', 'UZT-5' }, - { 'Asia/Tbilisi', 'GET-4' }, + { 'Asia/Tashkent', '<+05>-5' }, + { 'Asia/Tbilisi', '<+04>-4' }, { 'Asia/Tehran', 'IRST-3:30IRDT,J80/0,J264/0' }, { 'Asia/Thimphu', 'BTT-6' }, { 'Asia/Tokyo', 'JST-9' }, + { 'Asia/Tomsk', '<+07>-7' }, { 'Asia/Ulaanbaatar', 'ULAT-8ULAST,M3.5.6,M9.5.6/0' }, { 'Asia/Urumqi', 'XJT-6' }, - { 'Asia/Ust-Nera', 'VLAT-10' }, + { 'Asia/Ust-Nera', '<+10>-10' }, { 'Asia/Vientiane', 'ICT-7' }, - { 'Asia/Vladivostok', 'VLAT-10' }, - { 'Asia/Yakutsk', 'YAKT-9' }, - { 'Asia/Yekaterinburg', 'YEKT-5' }, - { 'Asia/Yerevan', 'AMT-4' }, + { 'Asia/Vladivostok', '<+10>-10' }, + { 'Asia/Yakutsk', '<+09>-9' }, + { 'Asia/Yangon', 'MMT-6:30' }, + { 'Asia/Yekaterinburg', '<+05>-5' }, + { 'Asia/Yerevan', '<+04>-4' }, { 'Atlantic/Azores', 'AZOT1AZOST,M3.5.0/0,M10.5.0/1' }, { 'Atlantic/Bermuda', 'AST4ADT,M3.2.0,M11.1.0' }, { 'Atlantic/Canary', 'WET0WEST,M3.5.0/1,M10.5.0' }, @@ -332,10 +335,11 @@ TZ = { { 'Europe/Guernsey', 'GMT0BST,M3.5.0/1,M10.5.0' }, { 'Europe/Helsinki', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, { 'Europe/Isle of Man', 'GMT0BST,M3.5.0/1,M10.5.0' }, - { 'Europe/Istanbul', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, + { 'Europe/Istanbul', '<+03>-3' }, { 'Europe/Jersey', 'GMT0BST,M3.5.0/1,M10.5.0' }, { 'Europe/Kaliningrad', 'EET-2' }, { 'Europe/Kiev', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, + { 'Europe/Kirov', '<+03>-3' }, { 'Europe/Lisbon', 'WET0WEST,M3.5.0/1,M10.5.0' }, { 'Europe/Ljubljana', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/London', 'GMT0BST,M3.5.0/1,M10.5.0' }, @@ -343,7 +347,7 @@ TZ = { { 'Europe/Madrid', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Malta', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Mariehamn', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, - { 'Europe/Minsk', 'MSK-3' }, + { 'Europe/Minsk', '<+03>-3' }, { 'Europe/Monaco', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Moscow', 'MSK-3' }, { 'Europe/Oslo', 'CET-1CEST,M3.5.0,M10.5.0/3' }, @@ -352,9 +356,10 @@ TZ = { { 'Europe/Prague', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Riga', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, { 'Europe/Rome', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Samara', 'SAMT-4' }, + { 'Europe/Samara', '<+04>-4' }, { 'Europe/San Marino', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Sarajevo', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Saratov', '<+04>-4' }, { 'Europe/Simferopol', 'MSK-3' }, { 'Europe/Skopje', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Sofia', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, @@ -367,7 +372,7 @@ TZ = { { 'Europe/Vatican', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Vienna', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Vilnius', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, - { 'Europe/Volgograd', 'MSK-3' }, + { 'Europe/Volgograd', '<+03>-3' }, { 'Europe/Warsaw', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Zagreb', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Zaporozhye', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, @@ -377,7 +382,7 @@ TZ = { { 'Indian/Christmas', 'CXT-7' }, { 'Indian/Cocos', 'CCT-6:30' }, { 'Indian/Comoro', 'EAT-3' }, - { 'Indian/Kerguelen', 'TFT-5' }, + { 'Indian/Kerguelen', '<+05>-5' }, { 'Indian/Mahe', 'SCT-4' }, { 'Indian/Maldives', 'MVT-5' }, { 'Indian/Mauritius', 'MUT-4' }, @@ -419,7 +424,7 @@ TZ = { { 'Pacific/Saipan', 'ChST-10' }, { 'Pacific/Tahiti', 'TAHT10' }, { 'Pacific/Tarawa', 'GILT-12' }, - { 'Pacific/Tongatapu', 'TOT-13' }, + { 'Pacific/Tongatapu', '<+13>-13<+14>,M11.1.0,M1.3.0/3' }, { 'Pacific/Wake', 'WAKT-12' }, { 'Pacific/Wallis', 'WFT-12' }, } diff --git a/modules/luci-base/luasrc/sys/zoneinfo/tzoffset.lua b/modules/luci-base/luasrc/sys/zoneinfo/tzoffset.lua index a8417e06c8..e5da7c6442 100644 --- a/modules/luci-base/luasrc/sys/zoneinfo/tzoffset.lua +++ b/modules/luci-base/luasrc/sys/zoneinfo/tzoffset.lua @@ -27,7 +27,7 @@ OFFSET = { cot = -18000, -- COT mst = -25200, -- MST mdt = -21600, -- MDT - vet = -16200, -- VET + vet = -14400, -- VET gft = -10800, -- GFT pst = -28800, -- PST pdt = -25200, -- PDT @@ -49,59 +49,31 @@ OFFSET = { egst = 0, -- EGST nst = -12600, -- NST ndt = -9000, -- NDT - awst = 28800, -- AWST - davt = 25200, -- DAVT - ddut = 36000, -- DDUT mist = 39600, -- MIST - mawt = 18000, -- MAWT nzst = 43200, -- NZST nzdt = 46800, -- NZDT - rott = -10800, -- ROTT - syot = 10800, -- SYOT - utc = 0, -- UTC - vost = 21600, -- VOST - almt = 21600, -- ALMT - anat = 43200, -- ANAT - aqtt = 18000, -- AQTT - tmt = 18000, -- TMT - azt = 14400, -- AZT ict = 25200, -- ICT - kgt = 21600, -- KGT bnt = 28800, -- BNT - yakt = 32400, -- YAKT chot = 28800, -- CHOT chost = 32400, -- CHOST - ist = 19800, -- IST bdt = 21600, -- BDT tlt = 32400, -- TLT gst = 14400, -- GST - tjt = 18000, -- TJT hkt = 28800, -- HKT hovt = 25200, -- HOVT hovst = 28800, -- HOVST - irkt = 28800, -- IRKT wib = 25200, -- WIB wit = 32400, -- WIT + ist = 7200, -- IST + idt = 10800, -- IDT aft = 16200, -- AFT - pett = 43200, -- PETT pkt = 18000, -- PKT npt = 20700, -- NPT - krat = 25200, -- KRAT myt = 28800, -- MYT - magt = 36000, -- MAGT wita = 28800, -- WITA pht = 28800, -- PHT - novt = 21600, -- NOVT - omst = 21600, -- OMST - orat = 18000, -- ORAT kst = 30600, -- KST - qyzt = 21600, -- QYZT - mmt = 23400, -- MMT - sakt = 39600, -- SAKT - uzt = 18000, -- UZT sgt = 28800, -- SGT - sret = 39600, -- SRET - get = 14400, -- GET irst = 12600, -- IRST irdt = 16200, -- IRDT btt = 21600, -- BTT @@ -109,8 +81,7 @@ OFFSET = { ulat = 28800, -- ULAT ulast = 32400, -- ULAST xjt = 21600, -- XJT - vlat = 36000, -- VLAT - yekt = 18000, -- YEKT + mmt = 23400, -- MMT azot = -3600, -- AZOT azost = 0, -- AZOST cvt = -3600, -- CVT @@ -121,12 +92,11 @@ OFFSET = { acwst = 31500, -- ACWST lhst = 37800, -- LHST lhdt = 39600, -- LHDT + awst = 28800, -- AWST msk = 10800, -- MSK - samt = 14400, -- SAMT iot = 21600, -- IOT cxt = 25200, -- CXT cct = 23400, -- CCT - tft = 18000, -- TFT sct = 14400, -- SCT mvt = 18000, -- MVT mut = 14400, -- MUT @@ -163,7 +133,6 @@ OFFSET = { ckt = -36000, -- CKT taht = -36000, -- TAHT gilt = 43200, -- GILT - tot = 46800, -- TOT wakt = 43200, -- WAKT wft = 43200, -- WFT } diff --git a/modules/luci-base/luasrc/tools/status.lua b/modules/luci-base/luasrc/tools/status.lua index a1ecbe71d0..4da0cf984b 100644 --- a/modules/luci-base/luasrc/tools/status.lua +++ b/modules/luci-base/luasrc/tools/status.lua @@ -63,17 +63,18 @@ local function dhcp_leases_common(family) if not ln then break else - local iface, duid, iaid, name, ts, id, length, ip = ln:match("^# (%S+) (%S+) (%S+) (%S+) (%d+) (%S+) (%S+) (.*)") + local iface, duid, iaid, name, ts, id, length, ip = ln:match("^# (%S+) (%S+) (%S+) (%S+) (-?%d+) (%S+) (%S+) (.*)") + local expire = tonumber(ts) or 0 if ip and iaid ~= "ipv4" and family == 6 then rv[#rv+1] = { - expires = os.difftime(tonumber(ts) or 0, os.time()), + expires = (expire >= 0) and os.difftime(expire, os.time()), duid = duid, ip6addr = ip, hostname = (name ~= "-") and name } elseif ip and iaid == "ipv4" and family == 4 then rv[#rv+1] = { - expires = os.difftime(tonumber(ts) or 0, os.time()), + expires = (expire >= 0) and os.difftime(expire, os.time()), macaddr = duid, ipaddr = ip, hostname = (name ~= "-") and name diff --git a/modules/luci-base/luasrc/tools/webadmin.lua b/modules/luci-base/luasrc/tools/webadmin.lua index 8273175de7..106810aa03 100644 --- a/modules/luci-base/luasrc/tools/webadmin.lua +++ b/modules/luci-base/luasrc/tools/webadmin.lua @@ -96,7 +96,7 @@ function iface_get_network(iface) if net.l3_device == iface or net.device == iface then -- cross check with uci to filter out @name style aliases local uciname = cur:get("network", net.interface, "ifname") - if not uciname or uciname:sub(1, 1) ~= "@" then + if type(uciname) == "string" and uciname:sub(1,1) ~= "@" or uciname then return net.interface end end diff --git a/modules/luci-base/luasrc/util.lua b/modules/luci-base/luasrc/util.lua index 896e36b45f..0e7334be87 100644 --- a/modules/luci-base/luasrc/util.lua +++ b/modules/luci-base/luasrc/util.lua @@ -16,7 +16,7 @@ local _ubus_connection = nil local getmetatable, setmetatable = getmetatable, setmetatable local rawget, rawset, unpack = rawget, rawset, unpack -local tostring, type, assert = tostring, type, assert +local tostring, type, assert, error = tostring, type, assert, error local ipairs, pairs, next, loadstring = ipairs, pairs, next, loadstring local require, pcall, xpcall = require, pcall, xpcall local collectgarbage, get_memory_limit = collectgarbage, get_memory_limit @@ -27,14 +27,27 @@ module "luci.util" -- Pythonic string formatting extension -- getmetatable("").__mod = function(a, b) + local ok, res + if not b then return a elseif type(b) == "table" then + local k, _ for k, _ in pairs(b) do if type(b[k]) == "userdata" then b[k] = tostring(b[k]) end end - return a:format(unpack(b)) + + ok, res = pcall(a.format, a, unpack(b)) + if not ok then + error(res, 2) + end + return res else if type(b) == "userdata" then b = tostring(b) end - return a:format(b) + + ok, res = pcall(a.format, a, b) + if not ok then + error(res, 2) + end + return res end end diff --git a/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm b/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm index b3b454008f..5cb31511f6 100644 --- a/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm +++ b/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm @@ -28,6 +28,7 @@ <% if self.allowlocal then %> <li style="padding:0.5em"> <input class="cbi-input-radio" data-update="click change"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "_empty") .. attr("name", cbid) .. attr("value", "") .. ifattr(checked[""], "checked", "checked")%> />   + <label<%=attr("for", cbid .. "_empty")%>></label> <label<%=attr("for", cbid .. "_empty")%> style="background-color:<%=fwm.zone.get_color()%>" class="zonebadge"> <strong><%:Device%></strong> <% if self.allowany and self.allowlocal then %>(<%:input%>)<% end %> @@ -37,6 +38,7 @@ <% if self.allowany then %> <li style="padding:0.5em"> <input class="cbi-input-radio" data-update="click change"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "_any") .. attr("name", cbid) .. attr("value", "*") .. ifattr(checked["*"], "checked", "checked")%> />   + <label<%=attr("for", cbid .. "_any")%>></label> <label<%=attr("for", cbid .. "_any")%> style="background-color:<%=fwm.zone.get_color()%>" class="zonebadge"> <strong><%:Any zone%></strong> <% if self.allowany and self.allowlocal then %>(<%:forward%>)<% end %> @@ -50,6 +52,7 @@ %> <li style="padding:0.5em"> <input class="cbi-input-radio" data-update="click change"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "." .. zone:name()) .. attr("name", cbid) .. attr("value", zone:name()) .. ifattr(checked[zone:name()], "checked", "checked")%> />   + <label<%=attr("for", cbid .. "." .. zone:name())%>></label> <label<%=attr("for", cbid .. "." .. zone:name())%> style="background-color:<%=zone:get_color()%>" class="zonebadge"> <strong><%=zone:name()%>:</strong> <% @@ -78,6 +81,7 @@ <% if self.widget ~= "checkbox" and not self.nocreate then %> <li style="padding:0.5em"> <input class="cbi-input-radio" data-update="click change" type="radio"<%=attr("id", cbid .. "_new") .. attr("name", cbid) .. attr("value", "-") .. ifattr(not selected, "checked", "checked")%> />   + <label<%=attr("for", cbid .. "_new")%>></label> <div onclick="document.getElementById('<%=cbid%>_new').checked=true" class="zonebadge" style="background-color:<%=fwm.zone.get_color()%>"> <em><%:unspecified -or- create:%> </em> <input type="text"<%=attr("name", cbid .. ".newzone") .. ifattr(not selected, "value", luci.http.formvalue(cbid .. ".newzone") or self.default)%> onfocus="document.getElementById('<%=cbid%>_new').checked=true" /> diff --git a/modules/luci-base/luasrc/view/cbi/fvalue.htm b/modules/luci-base/luasrc/view/cbi/fvalue.htm index 5eddcf22a1..197d03cf31 100644 --- a/modules/luci-base/luasrc/view/cbi/fvalue.htm +++ b/modules/luci-base/luasrc/view/cbi/fvalue.htm @@ -6,4 +6,5 @@ attr("id", cbid) .. attr("name", cbid) .. attr("value", self.enabled or 1) .. ifattr((self:cfgvalue(section) or self.default) == self.enabled, "checked", "checked") %> /> + <label<%= attr("for", cbid)%>></label> <%+cbi/valuefooter%> diff --git a/modules/luci-base/luasrc/view/cbi/lvalue.htm b/modules/luci-base/luasrc/view/cbi/lvalue.htm index 99f456dc54..34d02eeca0 100644 --- a/modules/luci-base/luasrc/view/cbi/lvalue.htm +++ b/modules/luci-base/luasrc/view/cbi/lvalue.htm @@ -24,15 +24,16 @@ <div> <% for i, key in pairs(self.keylist) do %> <label<%= - attr("id", cbid.."-"..key) .. attr("data-index", i) .. attr("data-depends", self:deplist2json(section, self.deplist[i])) %>> <input class="cbi-input-radio" data-update="click change" type="radio"<%= + attr("id", cbid.."-"..key) .. attr("name", cbid) .. attr("value", key) .. ifattr((self:cfgvalue(section) or self.default) == key, "checked", "checked") %> /> + <label<%= attr("for", cbid.."-"..key)%>></label> <%=pcdata(self.vallist[i])%> </label> <% if i == self.size then write(br) end %> diff --git a/modules/luci-base/luasrc/view/cbi/mvalue.htm b/modules/luci-base/luasrc/view/cbi/mvalue.htm index ca7b94c15e..246ef43aad 100644 --- a/modules/luci-base/luasrc/view/cbi/mvalue.htm +++ b/modules/luci-base/luasrc/view/cbi/mvalue.htm @@ -24,15 +24,16 @@ <div> <% for i, key in pairs(self.keylist) do %> <label<%= - attr("id", cbid.."-"..key) .. attr("data-index", i) .. attr("data-depends", self:deplist2json(section, self.deplist[i])) %>> <input class="cbi-input-checkbox" type="checkbox" data-update="click change"<%= + attr("id", cbid.."-"..key) .. attr("name", cbid) .. attr("value", key) .. ifattr(luci.util.contains(v, key), "checked", "checked") %> /> + <label<%= attr("for", cbid.."-"..key)%>></label> <%=pcdata(self.vallist[i])%> </label> <% if i == self.size then write('<br />') end %> diff --git a/modules/luci-base/luasrc/view/cbi/network_ifacelist.htm b/modules/luci-base/luasrc/view/cbi/network_ifacelist.htm index db6112992a..62dbde7dd4 100644 --- a/modules/luci-base/luasrc/view/cbi/network_ifacelist.htm +++ b/modules/luci-base/luasrc/view/cbi/network_ifacelist.htm @@ -46,7 +46,11 @@ attr("id", cbid .. "." .. iface:name()) .. attr("name", cbid) .. attr("value", iface:name()) .. ifattr(checked[iface:name()], "checked", "checked") - %> />   + %> /> + <%- if not self.widget or self.widget == "checkbox" or self.widget == "radio" then -%> + <label<%=attr("for", cbid .. "." .. iface:name())%>></label> + <%- end -%> +   <label<%=attr("for", cbid .. "." .. iface:name())%>> <% if link then -%><a href="<%=link%>"><% end -%> <img<%=attr("title", iface:get_i18n())%> style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" /> @@ -68,7 +72,11 @@ attr("id", cbid .. "_custom") .. attr("name", cbid) .. attr("value", " ") - %> />   + %> /> + <%- if not self.widget or self.widget == "checkbox" or self.widget == "radio" then -%> + <label<%=attr("for", cbid .. "_custom")%>></label> + <%- end -%> +   <label<%=attr("for", cbid .. "_custom")%>> <img title="<%:Custom Interface%>" style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/ethernet_disabled.png" /> <%:Custom Interface%>: diff --git a/modules/luci-base/luasrc/view/cbi/network_netlist.htm b/modules/luci-base/luasrc/view/cbi/network_netlist.htm index f8a2b72f3c..8bf1a70a20 100644 --- a/modules/luci-base/luasrc/view/cbi/network_netlist.htm +++ b/modules/luci-base/luasrc/view/cbi/network_netlist.htm @@ -52,6 +52,9 @@ <% if not self.nocreate then %> <li style="padding:0.25em 0"> <input class="cbi-input-<%=self.widget or "radio"%>" data-update="click change"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "_new") .. attr("name", cbid) .. attr("value", "-") .. ifattr(not value and self.widget ~= "checkbox", "checked", "checked")%> />   + <%- if not self.widget or self.widget == "checkbox" or self.widget == "radio" then -%> + <label<%=attr("for", cbid .. "_new")%>></label> + <%- end -%> <div style="padding:0.5em; display:inline"> <label<%=attr("for", cbid .. "_new")%>><em> <%- if self.widget == "checkbox" then -%> diff --git a/modules/luci-base/luasrc/view/sysauth.htm b/modules/luci-base/luasrc/view/sysauth.htm index e207504911..f6b0f5706a 100644 --- a/modules/luci-base/luasrc/view/sysauth.htm +++ b/modules/luci-base/luasrc/view/sysauth.htm @@ -7,14 +7,14 @@ <%+header%> <form method="post" action="<%=pcdata(luci.http.getenv("REQUEST_URI"))%>"> + <%- if fuser then %> + <div class="errorbox"><%:Invalid username and/or password! Please try again.%></div> + <% end -%> + <div class="cbi-map"> <h2 name="content"><%:Authorization Required%></h2> <div class="cbi-map-descr"> <%:Please enter your username and password.%> - <%- if fuser then %> - <div class="error"><%:Invalid username and/or password! Please try again.%></div> - <br /> - <% end -%> </div> <fieldset class="cbi-section"><fieldset class="cbi-section-node"> <div class="cbi-value"> |