openwrt: solves the wifi status table updates, LuCI itf cleanup
This commit is contained in:
parent
79f2894496
commit
a93f0d30ab
|
@ -1,4 +1,5 @@
|
|||
config system
|
||||
option timezone UTC
|
||||
option hostname flukso
|
||||
option device 0123456789abcdef0123456789abcdef
|
||||
option key 00112233445566778899aabbccddeeff
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
config 'core' 'main'
|
||||
option 'lang' 'auto'
|
||||
option 'mediaurlbase' '/luci-static/openwrt.org'
|
||||
option 'resourcebase' '/luci-static/resources'
|
||||
option 'mediaurlbase' '/luci-static/oxygen'
|
||||
|
||||
config 'extern' 'flash_keep'
|
||||
option 'uci' '/etc/config/'
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -19,112 +19,6 @@ function index()
|
|||
luci.i18n.loadc("admin-core")
|
||||
local i18n = luci.i18n.translate
|
||||
|
||||
--[[ entry({"system"}, alias("mini", "system", "index"), i18n("system"), 40).index = true
|
||||
entry({"system", "index"}, cbi("mini/system", {autoapply=true}), i18n("general"), 1)
|
||||
entry({"system", "passwd"}, form("mini/passwd"), i18n("a_s_changepw"), 10)
|
||||
entry({"system", "backup"}, call("action_backup"), i18n("a_s_backup"), 80)
|
||||
entry({"system", "upgrade"}, call("action_upgrade"), i18n("a_s_flash"), 90)
|
||||
entry({"system", "reboot"}, call("action_reboot"), i18n("reboot"), 100)
|
||||
]]--
|
||||
entry({"system"}, cbi("mini/system", {autoapply=true}), i18n("system"), 1)
|
||||
|
||||
end
|
||||
|
||||
function action_backup()
|
||||
local reset_avail = os.execute([[grep '"rootfs_data"' /proc/mtd >/dev/null 2>&1]]) == 0
|
||||
local restore_cmd = "gunzip | tar -xC/ >/dev/null 2>&1"
|
||||
local backup_cmd = "tar -c %s | gzip 2>/dev/null"
|
||||
|
||||
local restore_fpi
|
||||
luci.http.setfilehandler(
|
||||
function(meta, chunk, eof)
|
||||
if not restore_fpi then
|
||||
restore_fpi = io.popen(restore_cmd, "w")
|
||||
end
|
||||
if chunk then
|
||||
restore_fpi:write(chunk)
|
||||
end
|
||||
if eof then
|
||||
restore_fpi:close()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
local upload = luci.http.formvalue("archive")
|
||||
local backup = luci.http.formvalue("backup")
|
||||
local reset = reset_avail and luci.http.formvalue("reset")
|
||||
|
||||
if upload and #upload > 0 then
|
||||
luci.template.render("mini/applyreboot")
|
||||
luci.sys.reboot()
|
||||
elseif backup then
|
||||
luci.util.perror(backup_cmd:format(_keep_pattern()))
|
||||
local backup_fpi = io.popen(backup_cmd:format(_keep_pattern()), "r")
|
||||
luci.http.header('Content-Disposition', 'attachment; filename="backup-%s-%s.tar.gz"' % {
|
||||
luci.sys.hostname(), os.date("%Y-%m-%d")})
|
||||
luci.http.prepare_content("application/x-targz")
|
||||
luci.ltn12.pump.all(luci.ltn12.source.file(backup_fpi), luci.http.write)
|
||||
elseif reset then
|
||||
luci.template.render("mini/applyreboot")
|
||||
luci.util.exec("mtd -r erase rootfs_data")
|
||||
else
|
||||
luci.template.render("mini/backup", {reset_avail = reset_avail})
|
||||
end
|
||||
end
|
||||
|
||||
function action_reboot()
|
||||
local reboot = luci.http.formvalue("reboot")
|
||||
luci.template.render("mini/reboot", {reboot=reboot})
|
||||
if reboot then
|
||||
luci.sys.reboot()
|
||||
end
|
||||
end
|
||||
|
||||
function action_upgrade()
|
||||
require("luci.model.uci")
|
||||
|
||||
local ret = nil
|
||||
local plat = luci.fs.mtime("/lib/upgrade/platform.sh")
|
||||
local tmpfile = "/tmp/firmware.img"
|
||||
local keep_avail = true
|
||||
|
||||
local file
|
||||
luci.http.setfilehandler(
|
||||
function(meta, chunk, eof)
|
||||
if not file then
|
||||
file = io.open(tmpfile, "w")
|
||||
end
|
||||
if chunk then
|
||||
file:write(chunk)
|
||||
end
|
||||
if eof then
|
||||
file:close()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
local fname = luci.http.formvalue("image")
|
||||
local keepcfg = keep_avail and luci.http.formvalue("keepcfg")
|
||||
|
||||
if plat and fname then
|
||||
ret = function()
|
||||
return luci.sys.flash(tmpfile, keepcfg and _keep_pattern())
|
||||
end
|
||||
end
|
||||
|
||||
luci.http.prepare_content("text/html")
|
||||
luci.template.render("mini/upgrade", {sysupgrade=plat, ret=ret, keep_avail=keep_avail})
|
||||
end
|
||||
|
||||
function _keep_pattern()
|
||||
local kpattern = ""
|
||||
local files = luci.model.uci.cursor():get_all("luci", "flash_keep")
|
||||
if files then
|
||||
kpattern = ""
|
||||
for k, v in pairs(files) do
|
||||
if k:sub(1,1) ~= "." and luci.fs.glob(v) then
|
||||
kpattern = kpattern .. " " .. v
|
||||
end
|
||||
end
|
||||
end
|
||||
return kpattern
|
||||
end
|
||||
|
|
|
@ -21,8 +21,8 @@ a_i_keepflash = 'Files to be kept when flashing a new firmware'
|
|||
a_i_keepflash1 = 'When flashing a new firmware with <abbr title="Lua Configuration Interface">LuCI</abbr> these files will be added to the new firmware installation.'
|
||||
a_st_i_status1 = 'Here you can find information about the current system status like <abbr title="Central Processing Unit">CPU</abbr> clock frequency, memory usage or network interface data.'
|
||||
a_st_i_status2 = 'Also kernel or service logfiles can be viewed here to get an overview over their current state.'
|
||||
iwscan = '<abbr title="Wireless Local Area Network">WLAN</abbr>-Scan'
|
||||
iwscan1 = 'Wifi networks in your local environment'
|
||||
iwscan = 'Wifi-Scan'
|
||||
iwscan1 = 'Wifi networks detected by this Fluksometer'
|
||||
iwscan_encr = '<abbr title="Encrypted">Encr.</abbr>'
|
||||
iwscan_link = 'Link'
|
||||
iwscan_signal = 'Signal'
|
||||
|
@ -247,9 +247,10 @@ system_system_logsize = 'System log buffer size'
|
|||
system_system_logip = 'External system log server'
|
||||
system_system_conloglevel = 'Log output level'
|
||||
system_system_conloglevel_desc = 'Level of log messages on the console'
|
||||
m_i_chipset = 'Chipset'
|
||||
m_i_processor = 'Processor'
|
||||
m_i_memory = 'Memory'
|
||||
m_i_systemtime = 'Local Time'
|
||||
m_i_systemtime = 'System Time [UTC]'
|
||||
m_i_uptime = 'Uptime'
|
||||
m_n_d_firstaddress = 'First leased address'
|
||||
m_n_d_numleases = 'Number of leased addresses'
|
||||
|
|
|
@ -32,57 +32,6 @@ for k, v in pairs(network) do
|
|||
end
|
||||
|
||||
m = Map("network", translate("network"))
|
||||
s = m:section(Table, ifaces, translate("status"))
|
||||
s.parse = function() end
|
||||
|
||||
s:option(DummyValue, ".name", translate("network"))
|
||||
|
||||
hwaddr = s:option(DummyValue, "_hwaddr",
|
||||
translate("network_interface_hwaddr"), translate("network_interface_hwaddr_desc"))
|
||||
function hwaddr.cfgvalue(self, section)
|
||||
local ix = self.map:get(section, "ifname") or ""
|
||||
return luci.fs.readfile("/sys/class/net/" .. ix .. "/address")
|
||||
or luci.util.exec("ifconfig " .. ix):match(" ([A-F0-9:]+)%s*\n")
|
||||
or "n/a"
|
||||
end
|
||||
|
||||
|
||||
s:option(DummyValue, "ipaddr", translate("ipaddress"))
|
||||
|
||||
s:option(DummyValue, "netmask", translate("netmask"))
|
||||
|
||||
|
||||
txrx = s:option(DummyValue, "_txrx",
|
||||
translate("network_interface_txrx"), translate("network_interface_txrx_desc"))
|
||||
|
||||
function txrx.cfgvalue(self, section)
|
||||
local ix = self.map:get(section, "ifname")
|
||||
|
||||
local rx = netstat and netstat[ix] and netstat[ix][1]
|
||||
rx = rx and luci.tools.webadmin.byte_format(tonumber(rx)) or "-"
|
||||
|
||||
local tx = netstat and netstat[ix] and netstat[ix][9]
|
||||
tx = tx and luci.tools.webadmin.byte_format(tonumber(tx)) or "-"
|
||||
|
||||
return string.format("%s / %s", tx, rx)
|
||||
end
|
||||
|
||||
errors = s:option(DummyValue, "_err",
|
||||
translate("network_interface_err"), translate("network_interface_err_desc"))
|
||||
|
||||
function errors.cfgvalue(self, section)
|
||||
local ix = self.map:get(section, "ifname")
|
||||
|
||||
local rx = netstat and netstat[ix] and netstat[ix][3]
|
||||
local tx = netstat and netstat[ix] and netstat[ix][11]
|
||||
|
||||
rx = rx and tostring(rx) or "-"
|
||||
tx = tx and tostring(tx) or "-"
|
||||
|
||||
return string.format("%s / %s", tx, rx)
|
||||
end
|
||||
|
||||
|
||||
|
||||
s = m:section(NamedSection, "lan", "interface", translate("m_n_local"))
|
||||
s.addremove = false
|
||||
|
@ -105,7 +54,7 @@ p = s:option(ListValue, "proto", translate("protocol"))
|
|||
p.override_values = true
|
||||
p:value("none", "disabled")
|
||||
p:value("static", translate("manual", "manual"))
|
||||
p:value("dhcp", translate("automatic", "automatic"))
|
||||
p:value("dhcp", translate("automatic", "DHCP"))
|
||||
if has_pppoe then p:value("pppoe", "PPPoE") end
|
||||
if has_pptp then p:value("pptp", "PPTP") end
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@ require("luci.sys.zoneinfo")
|
|||
require("luci.tools.webadmin")
|
||||
|
||||
|
||||
m = Map("system", translate("system"), translate("a_s_desc"))
|
||||
m = Map("system", translate("system"), "")
|
||||
|
||||
s = m:section(TypedSection, "system", "")
|
||||
s = m:section(TypedSection, "system", translate("general"))
|
||||
s.anonymous = true
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ s.anonymous = true
|
|||
local system, model, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo()
|
||||
local uptime = luci.sys.uptime()
|
||||
|
||||
s:option(DummyValue, "_system", translate("system")).value = system
|
||||
s:option(DummyValue, "_chipset", translate("m_i_chipset")).value = system
|
||||
s:option(DummyValue, "_cpu", translate("m_i_processor")).value = model
|
||||
|
||||
local load1, load5, load15 = luci.sys.loadavg()
|
||||
|
@ -49,7 +49,169 @@ s:option(DummyValue, "_systime", translate("m_i_systemtime")).value =
|
|||
|
||||
s:option(DummyValue, "_uptime", translate("m_i_uptime")).value =
|
||||
luci.tools.webadmin.date_format(tonumber(uptime))
|
||||
|
||||
s:option(DummyValue, "hostname", translate("hostname"))
|
||||
|
||||
-- Wifi Data init --
|
||||
local uci = luci.model.uci.cursor()
|
||||
if not uci:get("network", "wan") then
|
||||
uci:section("network", "interface", "wan", {proto="none", ifname=" "})
|
||||
uci:save("network")
|
||||
uci:commit("network")
|
||||
end
|
||||
|
||||
local wlcursor = luci.model.uci.cursor_state()
|
||||
local wireless = wlcursor:get_all("wireless")
|
||||
local wifidata = luci.sys.wifi.getiwconfig()
|
||||
local wifidevs = {}
|
||||
local ifaces = {}
|
||||
|
||||
for k, v in pairs(wireless) do
|
||||
if v[".type"] == "wifi-iface" then
|
||||
table.insert(ifaces, v)
|
||||
end
|
||||
end
|
||||
|
||||
wlcursor:foreach("wireless", "wifi-device",
|
||||
function(section)
|
||||
table.insert(wifidevs, section[".name"])
|
||||
end)
|
||||
|
||||
|
||||
-- Wifi Status Table --
|
||||
s = m:section(Table, ifaces, translate("wifi"))
|
||||
|
||||
link = s:option(DummyValue, "_link", translate("link"))
|
||||
function link.cfgvalue(self, section)
|
||||
local ifname = self.map:get(section, "ifname")
|
||||
return wifidata[ifname] and wifidata[ifname]["Link Quality"] or "-"
|
||||
end
|
||||
|
||||
essid = s:option(DummyValue, "ssid", "ESSID")
|
||||
|
||||
bssid = s:option(DummyValue, "_bsiid", "BSSID")
|
||||
function bssid.cfgvalue(self, section)
|
||||
local ifname = self.map:get(section, "ifname")
|
||||
return (wifidata[ifname] and (wifidata[ifname].Cell
|
||||
or wifidata[ifname]["Access Point"])) or "-"
|
||||
end
|
||||
|
||||
protocol = s:option(DummyValue, "_mode", translate("protocol"))
|
||||
function protocol.cfgvalue(self, section)
|
||||
local mode = wireless[self.map:get(section, "device")].mode
|
||||
return mode and "802." .. mode
|
||||
end
|
||||
|
||||
mode = s:option(DummyValue, "mode", translate("mode"))
|
||||
encryption = s:option(DummyValue, "encryption", translate("iwscan_encr"))
|
||||
|
||||
power = s:option(DummyValue, "_power", translate("power"))
|
||||
function power.cfgvalue(self, section)
|
||||
local ifname = self.map:get(section, "ifname")
|
||||
return wifidata[ifname] and wifidata[ifname]["Tx-Power"] or "-"
|
||||
end
|
||||
|
||||
scan = s:option(Button, "_scan", translate("scan"))
|
||||
scan.inputstyle = "find"
|
||||
|
||||
function scan.cfgvalue(self, section)
|
||||
return self.map:get(section, "ifname") or false
|
||||
end
|
||||
|
||||
-- Wifi-Scan-Table --
|
||||
t2 = m:section(Table, {}, translate("iwscan"), translate("iwscan1"))
|
||||
|
||||
function scan.write(self, section)
|
||||
m.autoapply = false
|
||||
t2.render = t2._render
|
||||
local ifname = self.map:get(section, "ifname")
|
||||
luci.util.update(t2.data, luci.sys.wifi.iwscan(ifname))
|
||||
end
|
||||
|
||||
t2._render = t2.render
|
||||
t2.render = function() end
|
||||
|
||||
t2:option(DummyValue, "Quality", translate("iwscan_link"))
|
||||
essid = t2:option(DummyValue, "ESSID", "ESSID")
|
||||
function essid.cfgvalue(self, section)
|
||||
return self.map:get(section, "ESSID")
|
||||
end
|
||||
|
||||
t2:option(DummyValue, "Address", "BSSID")
|
||||
t2:option(DummyValue, "Mode", translate("mode"))
|
||||
chan = t2:option(DummyValue, "channel", translate("channel"))
|
||||
function chan.cfgvalue(self, section)
|
||||
return self.map:get(section, "Channel")
|
||||
or self.map:get(section, "Frequency")
|
||||
or "-"
|
||||
end
|
||||
|
||||
t2:option(DummyValue, "Encryption key", translate("iwscan_encr"))
|
||||
|
||||
t2:option(DummyValue, "Signal level", translate("iwscan_signal"))
|
||||
|
||||
t2:option(DummyValue, "Noise level", translate("iwscan_noise"))
|
||||
|
||||
-- Interface Data Init--
|
||||
local network = luci.model.uci.cursor_state():get_all("network")
|
||||
|
||||
local netstat = luci.sys.net.deviceinfo()
|
||||
local ifaces = {}
|
||||
|
||||
for k, v in pairs(network) do
|
||||
if v[".type"] == "interface" and k ~= "loopback" then
|
||||
table.insert(ifaces, v)
|
||||
end
|
||||
end
|
||||
|
||||
-- Interfaces Status Table--
|
||||
s = m:section(Table, ifaces, translate("interfaces"))
|
||||
s.parse = function() end
|
||||
|
||||
s:option(DummyValue, ".name", translate("interface"))
|
||||
|
||||
hwaddr = s:option(DummyValue, "_hwaddr",
|
||||
translate("network_interface_hwaddr"), translate("network_interface_hwaddr_desc"))
|
||||
function hwaddr.cfgvalue(self, section)
|
||||
local ix = self.map:get(section, "ifname") or ""
|
||||
return luci.fs.readfile("/sys/class/net/" .. ix .. "/address")
|
||||
or luci.util.exec("ifconfig " .. ix):match(" ([A-F0-9:]+)%s*\n")
|
||||
or "n/a"
|
||||
end
|
||||
|
||||
|
||||
s:option(DummyValue, "ipaddr", translate("ipaddress"))
|
||||
|
||||
s:option(DummyValue, "netmask", translate("netmask"))
|
||||
|
||||
|
||||
txrx = s:option(DummyValue, "_txrx",
|
||||
translate("network_interface_txrx"), translate("network_interface_txrx_desc"))
|
||||
|
||||
function txrx.cfgvalue(self, section)
|
||||
local ix = self.map:get(section, "ifname")
|
||||
|
||||
local rx = netstat and netstat[ix] and netstat[ix][1]
|
||||
rx = rx and luci.tools.webadmin.byte_format(tonumber(rx)) or "-"
|
||||
|
||||
local tx = netstat and netstat[ix] and netstat[ix][9]
|
||||
tx = tx and luci.tools.webadmin.byte_format(tonumber(tx)) or "-"
|
||||
|
||||
return string.format("%s / %s", tx, rx)
|
||||
end
|
||||
|
||||
errors = s:option(DummyValue, "_err",
|
||||
translate("network_interface_err"), translate("network_interface_err_desc"))
|
||||
|
||||
function errors.cfgvalue(self, section)
|
||||
local ix = self.map:get(section, "ifname")
|
||||
|
||||
local rx = netstat and netstat[ix] and netstat[ix][3]
|
||||
local tx = netstat and netstat[ix] and netstat[ix][11]
|
||||
|
||||
rx = rx and tostring(rx) or "-"
|
||||
tx = tx and tostring(tx) or "-"
|
||||
|
||||
return string.format("%s / %s", tx, rx)
|
||||
end
|
||||
|
||||
|
||||
return m
|
||||
|
|
|
@ -45,95 +45,15 @@ wlcursor:foreach("wireless", "wifi-device",
|
|||
m = Map("wireless", translate("wifi"), translate("a_w_devices1"))
|
||||
m:chain("network")
|
||||
|
||||
|
||||
-- Status Table --
|
||||
s = m:section(Table, ifaces, translate("networks"))
|
||||
|
||||
link = s:option(DummyValue, "_link", translate("link"))
|
||||
function link.cfgvalue(self, section)
|
||||
local ifname = self.map:get(section, "ifname")
|
||||
return wifidata[ifname] and wifidata[ifname]["Link Quality"] or "-"
|
||||
end
|
||||
|
||||
essid = s:option(DummyValue, "ssid", "ESSID")
|
||||
|
||||
bssid = s:option(DummyValue, "_bsiid", "BSSID")
|
||||
function bssid.cfgvalue(self, section)
|
||||
local ifname = self.map:get(section, "ifname")
|
||||
return (wifidata[ifname] and (wifidata[ifname].Cell
|
||||
or wifidata[ifname]["Access Point"])) or "-"
|
||||
end
|
||||
|
||||
channel = s:option(DummyValue, "channel", translate("channel"))
|
||||
function channel.cfgvalue(self, section)
|
||||
return wireless[self.map:get(section, "device")].channel
|
||||
end
|
||||
|
||||
protocol = s:option(DummyValue, "_mode", translate("protocol"))
|
||||
function protocol.cfgvalue(self, section)
|
||||
local mode = wireless[self.map:get(section, "device")].mode
|
||||
return mode and "802." .. mode
|
||||
end
|
||||
|
||||
mode = s:option(DummyValue, "mode", translate("mode"))
|
||||
encryption = s:option(DummyValue, "encryption", translate("iwscan_encr"))
|
||||
|
||||
power = s:option(DummyValue, "_power", translate("power"))
|
||||
function power.cfgvalue(self, section)
|
||||
local ifname = self.map:get(section, "ifname")
|
||||
return wifidata[ifname] and wifidata[ifname]["Tx-Power"] or "-"
|
||||
end
|
||||
|
||||
scan = s:option(Button, "_scan", translate("scan"))
|
||||
scan.inputstyle = "find"
|
||||
|
||||
function scan.cfgvalue(self, section)
|
||||
return self.map:get(section, "ifname") or false
|
||||
end
|
||||
|
||||
-- WLAN-Scan-Table --
|
||||
|
||||
t2 = m:section(Table, {}, translate("iwscan"), translate("iwscan1"))
|
||||
|
||||
function scan.write(self, section)
|
||||
m.autoapply = false
|
||||
t2.render = t2._render
|
||||
local ifname = self.map:get(section, "ifname")
|
||||
luci.util.update(t2.data, luci.sys.wifi.iwscan(ifname))
|
||||
end
|
||||
|
||||
t2._render = t2.render
|
||||
t2.render = function() end
|
||||
|
||||
t2:option(DummyValue, "Quality", translate("iwscan_link"))
|
||||
essid = t2:option(DummyValue, "ESSID", "ESSID")
|
||||
function essid.cfgvalue(self, section)
|
||||
return self.map:get(section, "ESSID")
|
||||
end
|
||||
|
||||
t2:option(DummyValue, "Address", "BSSID")
|
||||
t2:option(DummyValue, "Mode", translate("mode"))
|
||||
chan = t2:option(DummyValue, "channel", translate("channel"))
|
||||
function chan.cfgvalue(self, section)
|
||||
return self.map:get(section, "Channel")
|
||||
or self.map:get(section, "Frequency")
|
||||
or "-"
|
||||
end
|
||||
|
||||
t2:option(DummyValue, "Encryption key", translate("iwscan_encr"))
|
||||
|
||||
t2:option(DummyValue, "Signal level", translate("iwscan_signal"))
|
||||
|
||||
t2:option(DummyValue, "Noise level", translate("iwscan_noise"))
|
||||
|
||||
|
||||
|
||||
if #wifidevs < 1 then
|
||||
return m
|
||||
end
|
||||
|
||||
-- Config Section --
|
||||
|
||||
local hwtype = m:get(wifidevs[1], "type")
|
||||
|
||||
--[[
|
||||
s = m:section(NamedSection, wifidevs[1], "wifi-device", translate("devices"))
|
||||
s.addremove = false
|
||||
|
||||
|
@ -155,7 +75,7 @@ ch = s:option(Value, "channel", translate("a_w_channel"))
|
|||
for i=1, 14 do
|
||||
ch:value(i, i .. " (2.4 GHz)")
|
||||
end
|
||||
|
||||
]]--
|
||||
|
||||
s = m:section(TypedSection, "wifi-iface", translate("m_n_local"))
|
||||
s.anonymous = true
|
||||
|
@ -238,7 +158,7 @@ function key:validate(value, section)
|
|||
return nil
|
||||
end
|
||||
elseif encr:formvalue(section) == 'psk' or encr:formvalue(section) == 'psk2' then
|
||||
return #value == 64 and value:hexcheck()
|
||||
return #value > 7 and #value < 64 and value
|
||||
else
|
||||
return value
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ $Id$
|
|||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<p class="luci"><a href="<%=controller%>/about">Powered by <%= luci.__appname__ .. " (v" .. luci.__version__ .. ")" %></a></p>
|
||||
<p class="luci"><a href="<%=controller%>/about">Powered by LuCI</a></p>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
|
|
@ -20,89 +20,12 @@ div.dashicon a {
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.di_index a {
|
||||
background-image: url(icons/network.png);
|
||||
div.di_network a {
|
||||
background-image: url(icons/network.png);
|
||||
}
|
||||
|
||||
div.di_wifi a {
|
||||
background-image: url(icons/wifi.png);
|
||||
}
|
||||
|
||||
|
||||
div.di_network a {
|
||||
background-image: url(icons/network.png);
|
||||
}
|
||||
|
||||
div.di_luci a {
|
||||
background-image: url(icons/desktop.png);
|
||||
}
|
||||
|
||||
/**div.di_index a {
|
||||
background-image: url(icons/overview.png);
|
||||
}**/
|
||||
|
||||
div.di_logout a {
|
||||
background-image: url(icons/logout.png);
|
||||
}
|
||||
|
||||
/**div.di_freifunk a {
|
||||
background-image: url(icons/freifunk.png);
|
||||
}**/
|
||||
|
||||
div.di_status a {
|
||||
background-image: url(icons/status.png);
|
||||
}
|
||||
|
||||
div.di_system a {
|
||||
background-image: url(icons/system.png);
|
||||
}
|
||||
|
||||
div.di_syslog a {
|
||||
background-image: url(icons/shell.png);
|
||||
}
|
||||
|
||||
div.di_ntpc a {
|
||||
background-image: url(icons/datetime.png);
|
||||
}
|
||||
|
||||
div.di_leds a {
|
||||
background-image: url(icons/lightbulb.png);
|
||||
}
|
||||
|
||||
div.di_reboot a {
|
||||
background-image: url(icons/restart.png);
|
||||
}
|
||||
|
||||
div.di_passwd a {
|
||||
background-image: url(icons/login.png);
|
||||
}
|
||||
|
||||
div.di_statistics a {
|
||||
background-image: url(icons/stats.png);
|
||||
}
|
||||
|
||||
div.di_packages a {
|
||||
background-image: url(icons/package.png);
|
||||
}
|
||||
|
||||
div.di_sshkeys a {
|
||||
background-image: url(icons/key.png);
|
||||
}
|
||||
|
||||
div.di_upgrade a {
|
||||
background-image: url(icons/flash.png);
|
||||
}
|
||||
|
||||
div.di_services a {
|
||||
background-image: url(icons/worker.png);
|
||||
}
|
||||
|
||||
div.di_backup a {
|
||||
background-image: url(icons/switch.png);
|
||||
}
|
||||
|
||||
div.di_fstab a {
|
||||
background-image: url(icons/harddisk.png);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.6 KiB |
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="refresh" content="0; URL=/cgi-bin/luci/splash" />
|
||||
</head>
|
||||
<body style="background-color: black">
|
||||
<a style="color: white; text-decoration: none" href="/cgi-bin/luci/splash">LuCI - Lua Configuration Interface</a>
|
||||
<body style="background-color: grey">
|
||||
<a style="color: white; text-decoration: none" href="/cgi-bin/luci/splash">Flukso Configuration Interface</a>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -21,8 +21,8 @@ a_i_keepflash = 'Files to be kept when flashing a new firmware'
|
|||
a_i_keepflash1 = 'When flashing a new firmware with <abbr title="Lua Configuration Interface">LuCI</abbr> these files will be added to the new firmware installation.'
|
||||
a_st_i_status1 = 'Here you can find information about the current system status like <abbr title="Central Processing Unit">CPU</abbr> clock frequency, memory usage or network interface data.'
|
||||
a_st_i_status2 = 'Also kernel or service logfiles can be viewed here to get an overview over their current state.'
|
||||
iwscan = '<abbr title="Wireless Local Area Network">WLAN</abbr>-Scan'
|
||||
iwscan1 = 'Wifi networks in your local environment'
|
||||
iwscan = 'Wifi-Scan'
|
||||
iwscan1 = 'Wifi networks detected by this Fluksometer'
|
||||
iwscan_encr = '<abbr title="Encrypted">Encr.</abbr>'
|
||||
iwscan_link = 'Link'
|
||||
iwscan_signal = 'Signal'
|
||||
|
@ -103,7 +103,7 @@ a_w_channel = 'Channel'
|
|||
a_w_wifi1 = 'On this pages you can find configuration options for <abbr title="Wireless Local Area Network">WLAN</abbr> based wireless networks.'
|
||||
a_w_wifi2 = 'You can easily integrate your 802.11a/b/g/n-devices into your physical network and use the virtual adapter support to build wireless repeaters or offer several networks with one device.'
|
||||
a_w_wifi3 = 'There is support for Managed, Client, Ad-Hoc and <abbr title="Wireless Distribution System">WDS</abbr> operating modes as well as <abbr title="Wi-Fi Protected Access">WPA</abbr> and <abbr title="Wi-Fi Protected Access 2">WPA2</abbr> encryption for secure communnication.'
|
||||
a_w_devices1 = 'Here you can configure installed wifi devices.'
|
||||
a_w_devices1 = 'Please enter the name, encryption type and key/passphrase of your wifi network.'
|
||||
a_w_txantenna = 'Transmit Antenna'
|
||||
a_w_rxantenna = 'Receive Antenna'
|
||||
a_w_distance1 = 'Distance to furthest station (in meter)'
|
||||
|
@ -234,10 +234,11 @@ a_n_routes_kernel6 = 'Active <abbr title="Internet Protocol Version 6">IPv6</abb
|
|||
a_n_r_target1 = 'Host-<abbr title="Internet Protocol Address">IP</abbr> or Network'
|
||||
a_n_r_target6 = '<abbr title="Internet Protocol Version 6">IPv6</abbr>-Address or Network (CIDR)'
|
||||
a_n_r_netmask1 = 'if target is a network'
|
||||
m_n_network = 'These default settings should work just fine for most wifi networks.'
|
||||
m_n_inet = 'Internet Connection'
|
||||
m_n_local = 'Local Network'
|
||||
m_n_route = 'Route'
|
||||
m_n_brdige = 'Bridge'
|
||||
m_n_bridge = 'Bridge'
|
||||
m_w_ap = 'Provide (Access Point)'
|
||||
m_w_adhoc = 'Independent (Ad-Hoc)'
|
||||
m_w_client = 'Join (Client)'
|
||||
|
@ -247,9 +248,10 @@ system_system_logsize = 'System log buffer size'
|
|||
system_system_logip = 'External system log server'
|
||||
system_system_conloglevel = 'Log output level'
|
||||
system_system_conloglevel_desc = 'Level of log messages on the console'
|
||||
m_i_chipset = 'Chipset'
|
||||
m_i_processor = 'Processor'
|
||||
m_i_memory = 'Memory'
|
||||
m_i_systemtime = 'Local Time'
|
||||
m_i_systemtime = 'System Time [UTC]'
|
||||
m_i_uptime = 'Uptime'
|
||||
m_n_d_firstaddress = 'First leased address'
|
||||
m_n_d_numleases = 'Number of leased addresses'
|
||||
|
|
|
@ -48,7 +48,7 @@ ip6address = '<abbr title="Internet Protocol Version 6">IPv6</abbr>-Address'
|
|||
legend = 'Legend'
|
||||
library = 'Library'
|
||||
logout = 'Logout'
|
||||
key = 'Key'
|
||||
key = 'WEP-key or WPA-passphrase'
|
||||
language = 'Language'
|
||||
limit = 'Limit'
|
||||
load = 'Load'
|
||||
|
|
|
@ -35,4 +35,4 @@ wifi_ar = 'AR Support'
|
|||
wifi_nosbeacon = 'Disable HW-Beacon timer'
|
||||
wifi_noprobereq = 'Do not send probe responses'
|
||||
wifi_wpareq = 'WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP and ad-hoc mode) to be installed.'
|
||||
wifi_keyreq = '40bit/104bit WEP is autodetected based on key length. Use either 5/13 ASCII or 10/26 HEX characters as WEP key. A valid ASCII-based key will be translated into a HEX-based one. WPA(2)-PSK keys should be 64 HEX characters.'
|
||||
wifi_keyreq = '40bit/104bit WEP keys are autodetected based on key length. Use either 5/13 ASCII or 10/26 HEX characters as WEP key. A valid ASCII-based key will be translated into a HEX-based one. For WPA(2)-PSK encrypted networks, please enter your 8-to-63-character passphrase.'
|
||||
|
|
|
@ -27,17 +27,6 @@ function index()
|
|||
|
||||
entry({"about"}, template("about")).i18n = "admin-core"
|
||||
|
||||
--[[
|
||||
local page = entry({"mini"}, alias("mini", "index"), i18n("essentials", "Essentials"), 10)
|
||||
page.i18n = "admin-core"
|
||||
page.sysauth = "root"
|
||||
page.sysauth_authenticator = "htmlauth"
|
||||
page.index = true
|
||||
]]--
|
||||
--entry({"mini", "index"}, alias("mini", "index", "index"), i18n("overview"), 10).index = true
|
||||
--entry({"mini", "index", "index"}, form("mini/index"), i18n("general"), 1).ignoreindex = true
|
||||
--entry({"system", "luci"}, cbi("mini/luci", {autoapply=true}), i18n("settings"), 10)
|
||||
--entry({"mini", "index", "logout"}, call("action_logout"), i18n("logout"))
|
||||
end
|
||||
|
||||
function action_logout()
|
||||
|
|
|
@ -19,8 +19,6 @@ function index()
|
|||
luci.i18n.loadc("admin-core")
|
||||
local i18n = luci.i18n.translate
|
||||
|
||||
-- entry({"network"}, alias("mini", "network", "index"), i18n("network"), 20).index = true
|
||||
entry({"network"}, cbi("mini/network", {autoapply=true}), i18n("network"), 1)
|
||||
entry({"wifi"}, cbi("mini/wifi", {autoapply=true}), i18n("wifi"), 10).i18n="wifi"
|
||||
-- entry({"network", "dhcp"}, cbi("mini/dhcp", {autoapply=true}), "DHCP", 20)
|
||||
entry({"network"}, cbi("mini/network", {autoapply=true}), i18n("network"), 2)
|
||||
entry({"wifi"}, cbi("mini/wifi", {autoapply=true}), i18n("wifi"), 1).i18n="wifi"
|
||||
end
|
||||
|
|
|
@ -19,112 +19,6 @@ function index()
|
|||
luci.i18n.loadc("admin-core")
|
||||
local i18n = luci.i18n.translate
|
||||
|
||||
--[[ entry({"system"}, alias("mini", "system", "index"), i18n("system"), 40).index = true
|
||||
entry({"system", "index"}, cbi("mini/system", {autoapply=true}), i18n("general"), 1)
|
||||
entry({"system", "passwd"}, form("mini/passwd"), i18n("a_s_changepw"), 10)
|
||||
entry({"system", "backup"}, call("action_backup"), i18n("a_s_backup"), 80)
|
||||
entry({"system", "upgrade"}, call("action_upgrade"), i18n("a_s_flash"), 90)
|
||||
entry({"system", "reboot"}, call("action_reboot"), i18n("reboot"), 100)
|
||||
]]--
|
||||
entry({"system"}, cbi("mini/system", {autoapply=true}), i18n("system"), 3)
|
||||
|
||||
end
|
||||
|
||||
function action_backup()
|
||||
local reset_avail = os.execute([[grep '"rootfs_data"' /proc/mtd >/dev/null 2>&1]]) == 0
|
||||
local restore_cmd = "gunzip | tar -xC/ >/dev/null 2>&1"
|
||||
local backup_cmd = "tar -c %s | gzip 2>/dev/null"
|
||||
|
||||
local restore_fpi
|
||||
luci.http.setfilehandler(
|
||||
function(meta, chunk, eof)
|
||||
if not restore_fpi then
|
||||
restore_fpi = io.popen(restore_cmd, "w")
|
||||
end
|
||||
if chunk then
|
||||
restore_fpi:write(chunk)
|
||||
end
|
||||
if eof then
|
||||
restore_fpi:close()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
local upload = luci.http.formvalue("archive")
|
||||
local backup = luci.http.formvalue("backup")
|
||||
local reset = reset_avail and luci.http.formvalue("reset")
|
||||
|
||||
if upload and #upload > 0 then
|
||||
luci.template.render("mini/applyreboot")
|
||||
luci.sys.reboot()
|
||||
elseif backup then
|
||||
luci.util.perror(backup_cmd:format(_keep_pattern()))
|
||||
local backup_fpi = io.popen(backup_cmd:format(_keep_pattern()), "r")
|
||||
luci.http.header('Content-Disposition', 'attachment; filename="backup-%s-%s.tar.gz"' % {
|
||||
luci.sys.hostname(), os.date("%Y-%m-%d")})
|
||||
luci.http.prepare_content("application/x-targz")
|
||||
luci.ltn12.pump.all(luci.ltn12.source.file(backup_fpi), luci.http.write)
|
||||
elseif reset then
|
||||
luci.template.render("mini/applyreboot")
|
||||
luci.util.exec("mtd -r erase rootfs_data")
|
||||
else
|
||||
luci.template.render("mini/backup", {reset_avail = reset_avail})
|
||||
end
|
||||
end
|
||||
|
||||
function action_reboot()
|
||||
local reboot = luci.http.formvalue("reboot")
|
||||
luci.template.render("mini/reboot", {reboot=reboot})
|
||||
if reboot then
|
||||
luci.sys.reboot()
|
||||
end
|
||||
end
|
||||
|
||||
function action_upgrade()
|
||||
require("luci.model.uci")
|
||||
|
||||
local ret = nil
|
||||
local plat = luci.fs.mtime("/lib/upgrade/platform.sh")
|
||||
local tmpfile = "/tmp/firmware.img"
|
||||
local keep_avail = true
|
||||
|
||||
local file
|
||||
luci.http.setfilehandler(
|
||||
function(meta, chunk, eof)
|
||||
if not file then
|
||||
file = io.open(tmpfile, "w")
|
||||
end
|
||||
if chunk then
|
||||
file:write(chunk)
|
||||
end
|
||||
if eof then
|
||||
file:close()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
local fname = luci.http.formvalue("image")
|
||||
local keepcfg = keep_avail and luci.http.formvalue("keepcfg")
|
||||
|
||||
if plat and fname then
|
||||
ret = function()
|
||||
return luci.sys.flash(tmpfile, keepcfg and _keep_pattern())
|
||||
end
|
||||
end
|
||||
|
||||
luci.http.prepare_content("text/html")
|
||||
luci.template.render("mini/upgrade", {sysupgrade=plat, ret=ret, keep_avail=keep_avail})
|
||||
end
|
||||
|
||||
function _keep_pattern()
|
||||
local kpattern = ""
|
||||
local files = luci.model.uci.cursor():get_all("luci", "flash_keep")
|
||||
if files then
|
||||
kpattern = ""
|
||||
for k, v in pairs(files) do
|
||||
if k:sub(1,1) ~= "." and luci.fs.glob(v) then
|
||||
kpattern = kpattern .. " " .. v
|
||||
end
|
||||
end
|
||||
end
|
||||
return kpattern
|
||||
end
|
||||
|
|
|
@ -31,58 +31,7 @@ for k, v in pairs(network) do
|
|||
end
|
||||
end
|
||||
|
||||
m = Map("network", translate("network"))
|
||||
s = m:section(Table, ifaces, translate("status"))
|
||||
s.parse = function() end
|
||||
|
||||
s:option(DummyValue, ".name", translate("network"))
|
||||
|
||||
hwaddr = s:option(DummyValue, "_hwaddr",
|
||||
translate("network_interface_hwaddr"), translate("network_interface_hwaddr_desc"))
|
||||
function hwaddr.cfgvalue(self, section)
|
||||
local ix = self.map:get(section, "ifname") or ""
|
||||
return luci.fs.readfile("/sys/class/net/" .. ix .. "/address")
|
||||
or luci.util.exec("ifconfig " .. ix):match(" ([A-F0-9:]+)%s*\n")
|
||||
or "n/a"
|
||||
end
|
||||
|
||||
|
||||
s:option(DummyValue, "ipaddr", translate("ipaddress"))
|
||||
|
||||
s:option(DummyValue, "netmask", translate("netmask"))
|
||||
|
||||
|
||||
txrx = s:option(DummyValue, "_txrx",
|
||||
translate("network_interface_txrx"), translate("network_interface_txrx_desc"))
|
||||
|
||||
function txrx.cfgvalue(self, section)
|
||||
local ix = self.map:get(section, "ifname")
|
||||
|
||||
local rx = netstat and netstat[ix] and netstat[ix][1]
|
||||
rx = rx and luci.tools.webadmin.byte_format(tonumber(rx)) or "-"
|
||||
|
||||
local tx = netstat and netstat[ix] and netstat[ix][9]
|
||||
tx = tx and luci.tools.webadmin.byte_format(tonumber(tx)) or "-"
|
||||
|
||||
return string.format("%s / %s", tx, rx)
|
||||
end
|
||||
|
||||
errors = s:option(DummyValue, "_err",
|
||||
translate("network_interface_err"), translate("network_interface_err_desc"))
|
||||
|
||||
function errors.cfgvalue(self, section)
|
||||
local ix = self.map:get(section, "ifname")
|
||||
|
||||
local rx = netstat and netstat[ix] and netstat[ix][3]
|
||||
local tx = netstat and netstat[ix] and netstat[ix][11]
|
||||
|
||||
rx = rx and tostring(rx) or "-"
|
||||
tx = tx and tostring(tx) or "-"
|
||||
|
||||
return string.format("%s / %s", tx, rx)
|
||||
end
|
||||
|
||||
|
||||
m = Map("network", translate("network"), translate("m_n_network"))
|
||||
|
||||
s = m:section(NamedSection, "lan", "interface", translate("m_n_local"))
|
||||
s.addremove = false
|
||||
|
@ -105,7 +54,7 @@ p = s:option(ListValue, "proto", translate("protocol"))
|
|||
p.override_values = true
|
||||
p:value("none", "disabled")
|
||||
p:value("static", translate("manual", "manual"))
|
||||
p:value("dhcp", translate("automatic", "automatic"))
|
||||
p:value("dhcp", translate("automatic", "DHCP"))
|
||||
if has_pppoe then p:value("pppoe", "PPPoE") end
|
||||
if has_pptp then p:value("pptp", "PPTP") end
|
||||
|
||||
|
|
|
@ -17,17 +17,16 @@ require("luci.sys.zoneinfo")
|
|||
require("luci.tools.webadmin")
|
||||
|
||||
|
||||
m = Map("system", translate("system"), translate("a_s_desc"))
|
||||
m = Map("system", translate("system"), "")
|
||||
m.pageaction = false
|
||||
|
||||
s = m:section(TypedSection, "system", "")
|
||||
s = m:section(TypedSection, "system", translate("general"))
|
||||
s.anonymous = true
|
||||
|
||||
|
||||
|
||||
local system, model, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo()
|
||||
local uptime = luci.sys.uptime()
|
||||
|
||||
s:option(DummyValue, "_system", translate("system")).value = system
|
||||
s:option(DummyValue, "_chipset", translate("m_i_chipset")).value = system
|
||||
s:option(DummyValue, "_cpu", translate("m_i_processor")).value = model
|
||||
|
||||
local load1, load5, load15 = luci.sys.loadavg()
|
||||
|
@ -49,7 +48,169 @@ s:option(DummyValue, "_systime", translate("m_i_systemtime")).value =
|
|||
|
||||
s:option(DummyValue, "_uptime", translate("m_i_uptime")).value =
|
||||
luci.tools.webadmin.date_format(tonumber(uptime))
|
||||
|
||||
s:option(DummyValue, "hostname", translate("hostname"))
|
||||
|
||||
-- Wifi Data init --
|
||||
local uci = luci.model.uci.cursor()
|
||||
if not uci:get("network", "wan") then
|
||||
uci:section("network", "interface", "wan", {proto="none", ifname=" "})
|
||||
uci:save("network")
|
||||
uci:commit("network")
|
||||
end
|
||||
|
||||
local wlcursor = luci.model.uci.cursor_state()
|
||||
local wireless = wlcursor:get_all("wireless")
|
||||
local wifidata = luci.sys.wifi.getiwconfig()
|
||||
local wifidevs = {}
|
||||
local ifaces = {}
|
||||
|
||||
for k, v in pairs(wireless) do
|
||||
if v[".type"] == "wifi-iface" then
|
||||
table.insert(ifaces, v)
|
||||
end
|
||||
end
|
||||
|
||||
wlcursor:foreach("wireless", "wifi-device",
|
||||
function(section)
|
||||
table.insert(wifidevs, section[".name"])
|
||||
end)
|
||||
|
||||
|
||||
-- Wifi Status Table --
|
||||
s = m:section(Table, ifaces, translate("wifi"))
|
||||
|
||||
link = s:option(DummyValue, "_link", translate("link"))
|
||||
function link.cfgvalue(self, section)
|
||||
local ifname = self.map:get(section, "ifname")
|
||||
return wifidata[ifname] and wifidata[ifname]["Link Quality"] or "-"
|
||||
end
|
||||
|
||||
essid = s:option(DummyValue, "ssid", "ESSID")
|
||||
|
||||
bssid = s:option(DummyValue, "_bsiid", "BSSID")
|
||||
function bssid.cfgvalue(self, section)
|
||||
local ifname = self.map:get(section, "ifname")
|
||||
return (wifidata[ifname] and (wifidata[ifname].Cell
|
||||
or wifidata[ifname]["Access Point"])) or "-"
|
||||
end
|
||||
|
||||
protocol = s:option(DummyValue, "_mode", translate("protocol"))
|
||||
function protocol.cfgvalue(self, section)
|
||||
local mode = wireless[self.map:get(section, "device")].mode
|
||||
return mode and "802." .. mode
|
||||
end
|
||||
|
||||
mode = s:option(DummyValue, "mode", translate("mode"))
|
||||
encryption = s:option(DummyValue, "encryption", translate("iwscan_encr"))
|
||||
|
||||
power = s:option(DummyValue, "_power", translate("power"))
|
||||
function power.cfgvalue(self, section)
|
||||
local ifname = self.map:get(section, "ifname")
|
||||
return wifidata[ifname] and wifidata[ifname]["Tx-Power"] or "-"
|
||||
end
|
||||
|
||||
scan = s:option(Button, "_scan", translate("scan"))
|
||||
scan.inputstyle = "find"
|
||||
|
||||
function scan.cfgvalue(self, section)
|
||||
return self.map:get(section, "ifname") or false
|
||||
end
|
||||
|
||||
-- Wifi-Scan-Table --
|
||||
t2 = m:section(Table, {}, translate("iwscan"), translate("iwscan1"))
|
||||
|
||||
function scan.write(self, section)
|
||||
m.autoapply = false
|
||||
t2.render = t2._render
|
||||
local ifname = self.map:get(section, "ifname")
|
||||
luci.util.update(t2.data, luci.sys.wifi.iwscan(ifname))
|
||||
end
|
||||
|
||||
t2._render = t2.render
|
||||
t2.render = function() end
|
||||
|
||||
t2:option(DummyValue, "Quality", translate("iwscan_link"))
|
||||
essid = t2:option(DummyValue, "ESSID", "ESSID")
|
||||
function essid.cfgvalue(self, section)
|
||||
return self.map:get(section, "ESSID")
|
||||
end
|
||||
|
||||
t2:option(DummyValue, "Address", "BSSID")
|
||||
t2:option(DummyValue, "Mode", translate("mode"))
|
||||
chan = t2:option(DummyValue, "channel", translate("channel"))
|
||||
function chan.cfgvalue(self, section)
|
||||
return self.map:get(section, "Channel")
|
||||
or self.map:get(section, "Frequency")
|
||||
or "-"
|
||||
end
|
||||
|
||||
t2:option(DummyValue, "Encryption key", translate("iwscan_encr"))
|
||||
|
||||
t2:option(DummyValue, "Signal level", translate("iwscan_signal"))
|
||||
|
||||
t2:option(DummyValue, "Noise level", translate("iwscan_noise"))
|
||||
|
||||
-- Interface Data Init--
|
||||
local network = luci.model.uci.cursor_state():get_all("network")
|
||||
|
||||
local netstat = luci.sys.net.deviceinfo()
|
||||
local ifaces = {}
|
||||
|
||||
for k, v in pairs(network) do
|
||||
if v[".type"] == "interface" and k ~= "loopback" then
|
||||
table.insert(ifaces, v)
|
||||
end
|
||||
end
|
||||
|
||||
-- Interfaces Status Table--
|
||||
s = m:section(Table, ifaces, translate("interfaces"))
|
||||
s.parse = function() end
|
||||
|
||||
s:option(DummyValue, ".name", translate("interface"))
|
||||
|
||||
hwaddr = s:option(DummyValue, "_hwaddr",
|
||||
translate("network_interface_hwaddr"), translate("network_interface_hwaddr_desc"))
|
||||
function hwaddr.cfgvalue(self, section)
|
||||
local ix = self.map:get(section, "ifname") or ""
|
||||
return luci.fs.readfile("/sys/class/net/" .. ix .. "/address")
|
||||
or luci.util.exec("ifconfig " .. ix):match(" ([A-F0-9:]+)%s*\n")
|
||||
or "n/a"
|
||||
end
|
||||
|
||||
|
||||
s:option(DummyValue, "ipaddr", translate("ipaddress"))
|
||||
|
||||
s:option(DummyValue, "netmask", translate("netmask"))
|
||||
|
||||
|
||||
txrx = s:option(DummyValue, "_txrx",
|
||||
translate("network_interface_txrx"), translate("network_interface_txrx_desc"))
|
||||
|
||||
function txrx.cfgvalue(self, section)
|
||||
local ix = self.map:get(section, "ifname")
|
||||
|
||||
local rx = netstat and netstat[ix] and netstat[ix][1]
|
||||
rx = rx and luci.tools.webadmin.byte_format(tonumber(rx)) or "-"
|
||||
|
||||
local tx = netstat and netstat[ix] and netstat[ix][9]
|
||||
tx = tx and luci.tools.webadmin.byte_format(tonumber(tx)) or "-"
|
||||
|
||||
return string.format("%s / %s", tx, rx)
|
||||
end
|
||||
|
||||
errors = s:option(DummyValue, "_err",
|
||||
translate("network_interface_err"), translate("network_interface_err_desc"))
|
||||
|
||||
function errors.cfgvalue(self, section)
|
||||
local ix = self.map:get(section, "ifname")
|
||||
|
||||
local rx = netstat and netstat[ix] and netstat[ix][3]
|
||||
local tx = netstat and netstat[ix] and netstat[ix][11]
|
||||
|
||||
rx = rx and tostring(rx) or "-"
|
||||
tx = tx and tostring(tx) or "-"
|
||||
|
||||
return string.format("%s / %s", tx, rx)
|
||||
end
|
||||
|
||||
|
||||
return m
|
||||
|
|
|
@ -45,84 +45,6 @@ wlcursor:foreach("wireless", "wifi-device",
|
|||
m = Map("wireless", translate("wifi"), translate("a_w_devices1"))
|
||||
m:chain("network")
|
||||
|
||||
|
||||
-- Status Table --
|
||||
s = m:section(Table, ifaces, translate("networks"))
|
||||
|
||||
link = s:option(DummyValue, "_link", translate("link"))
|
||||
function link.cfgvalue(self, section)
|
||||
local ifname = self.map:get(section, "ifname")
|
||||
return wifidata[ifname] and wifidata[ifname]["Link Quality"] or "-"
|
||||
end
|
||||
|
||||
essid = s:option(DummyValue, "ssid", "ESSID")
|
||||
|
||||
bssid = s:option(DummyValue, "_bsiid", "BSSID")
|
||||
function bssid.cfgvalue(self, section)
|
||||
local ifname = self.map:get(section, "ifname")
|
||||
return (wifidata[ifname] and (wifidata[ifname].Cell
|
||||
or wifidata[ifname]["Access Point"])) or "-"
|
||||
end
|
||||
|
||||
protocol = s:option(DummyValue, "_mode", translate("protocol"))
|
||||
function protocol.cfgvalue(self, section)
|
||||
local mode = wireless[self.map:get(section, "device")].mode
|
||||
return mode and "802." .. mode
|
||||
end
|
||||
|
||||
mode = s:option(DummyValue, "mode", translate("mode"))
|
||||
encryption = s:option(DummyValue, "encryption", translate("iwscan_encr"))
|
||||
|
||||
power = s:option(DummyValue, "_power", translate("power"))
|
||||
function power.cfgvalue(self, section)
|
||||
local ifname = self.map:get(section, "ifname")
|
||||
return wifidata[ifname] and wifidata[ifname]["Tx-Power"] or "-"
|
||||
end
|
||||
|
||||
scan = s:option(Button, "_scan", translate("scan"))
|
||||
scan.inputstyle = "find"
|
||||
|
||||
function scan.cfgvalue(self, section)
|
||||
return self.map:get(section, "ifname") or false
|
||||
end
|
||||
|
||||
-- WLAN-Scan-Table --
|
||||
|
||||
t2 = m:section(Table, {}, translate("iwscan"), translate("iwscan1"))
|
||||
|
||||
function scan.write(self, section)
|
||||
m.autoapply = false
|
||||
t2.render = t2._render
|
||||
local ifname = self.map:get(section, "ifname")
|
||||
luci.util.update(t2.data, luci.sys.wifi.iwscan(ifname))
|
||||
end
|
||||
|
||||
t2._render = t2.render
|
||||
t2.render = function() end
|
||||
|
||||
t2:option(DummyValue, "Quality", translate("iwscan_link"))
|
||||
essid = t2:option(DummyValue, "ESSID", "ESSID")
|
||||
function essid.cfgvalue(self, section)
|
||||
return self.map:get(section, "ESSID")
|
||||
end
|
||||
|
||||
t2:option(DummyValue, "Address", "BSSID")
|
||||
t2:option(DummyValue, "Mode", translate("mode"))
|
||||
chan = t2:option(DummyValue, "channel", translate("channel"))
|
||||
function chan.cfgvalue(self, section)
|
||||
return self.map:get(section, "Channel")
|
||||
or self.map:get(section, "Frequency")
|
||||
or "-"
|
||||
end
|
||||
|
||||
t2:option(DummyValue, "Encryption key", translate("iwscan_encr"))
|
||||
|
||||
t2:option(DummyValue, "Signal level", translate("iwscan_signal"))
|
||||
|
||||
t2:option(DummyValue, "Noise level", translate("iwscan_noise"))
|
||||
|
||||
|
||||
|
||||
if #wifidevs < 1 then
|
||||
return m
|
||||
end
|
||||
|
@ -131,31 +53,8 @@ end
|
|||
|
||||
local hwtype = m:get(wifidevs[1], "type")
|
||||
|
||||
--[[
|
||||
s = m:section(NamedSection, wifidevs[1], "wifi-device", translate("devices"))
|
||||
s.addremove = false
|
||||
|
||||
local hwtype = m:get(wifidevs[1], "type")
|
||||
|
||||
if hwtype == "atheros" then
|
||||
mode = s:option(ListValue, "hwmode", translate("mode"))
|
||||
mode.override_values = true
|
||||
mode:value("", "auto")
|
||||
mode:value("11b", "802.11b")
|
||||
mode:value("11g", "802.11g")
|
||||
mode:value("11a", "802.11a")
|
||||
mode:value("11bg", "802.11b+g")
|
||||
mode.rmempty = true
|
||||
end
|
||||
|
||||
|
||||
ch = s:option(Value, "channel", translate("a_w_channel"))
|
||||
for i=1, 14 do
|
||||
ch:value(i, i .. " (2.4 GHz)")
|
||||
end
|
||||
]]--
|
||||
|
||||
s = m:section(TypedSection, "wifi-iface", translate("m_n_local"))
|
||||
s = m:section(TypedSection, "wifi-iface", "")
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
|
||||
|
|
|
@ -20,12 +20,16 @@ div.dashicon a {
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.di_system a {
|
||||
background-image: url(icons/system.png);
|
||||
}
|
||||
|
||||
div.di_network a {
|
||||
background-image: url(icons/network.png);
|
||||
}
|
||||
|
||||
div.di_wifi a {
|
||||
background-image: url(icons/wifi.png);
|
||||
background-image: url(icons/wifi.png);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
Loading…
Reference in New Issue