提交 658a2a69 编写于 作者: J Jo-Philipp Wich

luci-0.10: merge r6759-r6784

上级 8383f6b9
......@@ -66,30 +66,20 @@ end
-------------------- View --------------------
f = SimpleForm("ffwizward", "Freifunkassistent",
"Dieser Assistent unterstützt Sie bei der Einrichtung des Routers für das Freifunknetz.")
-- main netconfig
local newpsswd = has_rom and sys.exec("diff /rom/etc/passwd /etc/passwd")
if newpsswd ~= "" then
pw = f:field(Flag, "pw", "Router Passwort", "Setzen Sie den Haken, um Ihr Passwort zu ändern.")
function pw.cfgvalue(self, section)
return 1
end
end
pw1 = f:field(Value, "pw1", translate("password"))
pw1.password = true
pw1.rmempty = false
-- if password is not set or default then force the user to set a new one
if sys.exec("diff /rom/etc/passwd /etc/passwd") == "" then
pw1 = f:field(Value, "pw1", translate("password"))
pw1.password = true
pw1.rmempty = false
pw2 = f:field(Value, "pw2", translate("confirmation"))
pw2.password = true
pw2.rmempty = false
function pw2.validate(self, value, section)
return pw1:formvalue(section) == value and value
end
pw2 = f:field(Value, "pw2", translate("confirmation"))
pw2.password = true
pw2.rmempty = false
if newpsswd ~= "" then
pw1:depends("pw", "1")
pw2:depends("pw", "1")
function pw2.validate(self, value, section)
return pw1:formvalue(section) == value and value
end
end
net = f:field(ListValue, "net", "Freifunk Community", "Nutzen Sie die Einstellungen der Freifunk Gemeinschaft in ihrer Nachbarschaft.")
......@@ -131,9 +121,7 @@ function hostname.write(self, section, value)
uci:save("freifunk")
end
function hostname.validate(self, value)
if (#value > 16) then
return
elseif (string.find(value, "[^%w%_%-]")) then
if (#value > 24) or string.find(value, "[^%w%.%-]") or string.find(string.sub(value, value:len()), "[%.%-]") or string.find(string.sub(value, 1), "[%.%-]") then
return
else
return value
......@@ -186,23 +174,22 @@ uci:foreach("wireless", "wifi-device",
function chan.cfgvalue(self, section)
return uci:get("freifunk", "wizard", "chan_" .. device)
end
chan:value('default')
for i = 1, 14, 1 do
chan:value(i)
end
for i = 36, 64, 4 do
chan:value(i)
end
for i = 100, 140, 4 do
chan:value(i)
for _, f in ipairs(sys.wifi.channels(device)) do
if not f.restricted then
chan:value(f.channel)
end
end
function chan.write(self, sec, value)
if value then
uci:set("freifunk", "wizard", "chan_" .. device, value)
uci:save("freifunk")
end
end
local meship = f:field(Value, "meship_" .. device, device:upper() .. " Mesh IP Adresse einrichten", "Ihre Mesh IP Adresse erhalten Sie von der Freifunk Gemeinschaft in Ihrer Nachbarschaft. Es ist eine netzweit eindeutige Identifikation, z.B. 104.1.1.1.")
local meship = f:field(Value, "meship_" .. device, device:upper() .. " Mesh IP Adresse einrichten", "Ihre Mesh IP Adresse erhalten Sie von der Freifunk Gemeinschaft in Ihrer Nachbarschaft. Es ist eine netzweit eindeutige Identifikation, z.B. 104.1.1.1.")
meship:depends("device_" .. device, "1")
meship.rmempty = true
function meship.cfgvalue(self, section)
......@@ -590,11 +577,7 @@ function f.handle(self, state, data)
else
if data.pw1 then
local stat = luci.sys.user.setpasswd("root", data.pw1) == 0
-- if stat then
-- f.message = translate("a_s_changepw_changed")
-- else
-- f.errmessage = translate("unknownerror")
end
end
data.pw1 = nil
data.pw2 = nil
uci:commit("freifunk")
......@@ -619,9 +602,9 @@ function f.handle(self, state, data)
if has_radvd then
uci:commit("radvd")
end
-- the following line didn't work without admin-mini, for now i just replaced it with sys.exec... soma
-- luci.http.redirect(luci.dispatcher.build_url(unpack(luci.dispatcher.context.requested.path), "system", "reboot") .. "?reboot=1")
sys.exec("reboot")
sys.exec("for s in network dnsmasq luci_splash firewall uhttpd olsrd radvd l2gvpn; do [ -x /etc/init.d/$s ] && /etc/init.d/$s restart;done > /dev/null &")
luci.http.redirect(luci.dispatcher.build_url(luci.dispatcher.context.path[1], "freifunk", "ffwizard"))
end
return false
elseif state == FORM_INVALID then
......@@ -782,50 +765,39 @@ function main.write(self, section, value)
end
-- New Config
-- Tune wifi device
local ssiduci = uci:get("freifunk", community, "ssid")
local ssiddot = string.find(ssiduci,'%..*')
local ssidshort
if ssiddot then
ssidshort = string.sub(ssiduci,ssiddot)
else
ssidshort = ssiduci
end
local ssid = uci:get("freifunk", community, "ssid") or "olsr.freifunk.net"
local devconfig = uci:get_all("freifunk", "wifi_device")
util.update(devconfig, uci:get_all(external, "wifi_device") or {})
local ssid = uci:get("freifunk", community, "ssid")
local channel = luci.http.formvalue("cbid.ffwizward.1.chan_" .. device)
local hwmode = "11bg"
local bssid = "02:CA:FF:EE:BA:BE"
local bssid = uci:get_all(external, "wifi_iface", "bssid") or "02:CA:FF:EE:BA:BE"
local mrate = 5500
-- set bssid, see https://kifuse02.pberg.freifunk.net/moin/channel-bssid-essid for schema
if channel and channel ~= "default" then
if devconfig.channel ~= channel then
devconfig.channel = channel
local chan = tonumber(channel)
if chan >= 0 and chan < 10 then
bssid = channel .. "2:CA:FF:EE:BA:BE"
ssid = "ch" .. channel .. ssidshort
elseif chan == 10 then
bssid = "02:CA:FF:EE:BA:BE"
ssid = "ch" .. channel .. ssidshort
elseif chan == 10 then
bssid = "02:CA:FF:EE:BA:BE"
elseif chan >= 11 and chan <= 14 then
bssid = string.format("%X",channel) .. "2:CA:FF:EE:BA:BE"
ssid = "ch" .. channel .. ssidshort
elseif chan >= 36 and chan <= 64 then
hwmode = "11a"
mrate = ""
outdoor = 0
bssid = "00:" .. channel ..":CA:FF:EE:EE"
ssid = "ch" .. channel .. ssidshort
elseif chan >= 100 and chan <= 140 then
hwmode = "11a"
mrate = ""
outdoor = 1
bssid = "01:" .. string.sub(channel, 2) .. ":CA:FF:EE:EE"
ssid = "ch" .. channel .. ssidshort
end
devconfig.hwmode = hwmode
devconfig.outdoor = outdoor
end
ssid = ssid .. " - ch" .. channel
end
uci:tset("wireless", device, devconfig)
-- Create wifi iface
......@@ -833,13 +805,7 @@ function main.write(self, section, value)
util.update(ifconfig, uci:get_all(external, "wifi_iface") or {})
ifconfig.device = device
ifconfig.network = nif
if ssid then
-- See Table https://kifuse02.pberg.freifunk.net/moin/channel-bssid-essid
ifconfig.ssid = ssid
else
ifconfig.ssid = "olsr.freifunk.net"
end
-- See Table https://kifuse02.pberg.freifunk.net/moin/channel-bssid-essid
ifconfig.ssid = ssid
ifconfig.bssid = bssid
ifconfig.encryption="none"
-- Read Preset
......@@ -947,8 +913,8 @@ function main.write(self, section, value)
device =device,
mode ="ap",
encryption ="none",
network =nif.."dhcp",
ssid ="AP"..ssidshort
network =nif .. "dhcp",
ssid ="AP-" .. ssid
})
if has_radvd then
uci:section("radvd", "interface", nil, {
......
......@@ -113,6 +113,7 @@ s = m:section(TypedSection, "redirect", translate("Redirections"))
s.template = "cbi/tblsection"
s.addremove = true
s.anonymous = true
s.sortable = true
s.extedit = ds.build_url("admin", "network", "firewall", "redirect", "%s")
function s.create(self, section)
......@@ -191,6 +192,7 @@ end
s = m:section(TypedSection, "rule", translate("Rules"))
s.addremove = true
s.anonymous = true
s.sortable = true
s.template = "cbi/tblsection"
s.extedit = ds.build_url("admin", "network", "firewall", "rule", "%s")
s.defaults.target = "ACCEPT"
......
......@@ -64,14 +64,20 @@ wa.cbi_add_knownips(dsth)
l7 = s:option(ListValue, "layer7", translate("Service"))
l7.rmempty = true
l7:value("", translate("all"))
local pats = fs.glob("/etc/l7-protocols/*/*.pat")
local pats = io.popen("find /etc/l7-protocols/ -type f -name '*.pat'")
if pats then
for f in pats do
f = f:match("([^/]+)%.pat$")
if f then
l7:value(f)
local l
while true do
l = pats:read("*l")
if not l then break end
l = l:match("([^/]+)%.pat$")
if l then
l7:value(l)
end
end
pats:close()
end
p = s:option(Value, "proto", translate("Protocol"))
......
......@@ -50,14 +50,20 @@ wa.cbi_add_knownips(dsth)
l7 = s:option(ListValue, "layer7", translate("Service"))
l7.rmempty = true
l7:value("", translate("all"))
local pats = fs.glob("/etc/l7-protocols/*/*.pat")
local pats = io.popen("find /etc/l7-protocols/ -type f -name '*.pat'")
if pats then
for f in pats do
f = f:match("([^/]+)%.pat$")
if f then
l7:value(f)
local l
while true do
l = pats:read("*l")
if not l then break end
l = l:match("([^/]+)%.pat$")
if l then
l7:value(l)
end
end
pats:close()
end
p = s:option(ListValue, "proto", translate("Protocol"))
......
......@@ -32,6 +32,9 @@ luasource:
endif
luadiet: luasource
for i in $$(find dist -type f -name '*.lua'); do LUA_PATH="../../contrib/luasrcdiet/lua/?.lua" $(LUA) ../../contrib/luasrcdiet/lua/LuaSrcDiet.lua --maximum $$i -o $$i.diet && mv $$i.diet $$i; done
luastrip: luasource
for i in $$(find dist -type f -name '*.lua'); do perl -e 'undef $$/; open( F, "< $$ARGV[0]" ) || die $$!; $$src = <F>; close F; $$src =~ s/--\[\[.*?\]\](--)?//gs; $$src =~ s/^\s*--.*?\n//gm; open( F, "> $$ARGV[0]" ) || die $$!; print F $$src; close F' $$i; done
......
include ../../build/config.mk
include ../../build/module.mk
\ No newline at end of file
LuaSrcDiet License
------------------
LuaSrcDiet is licensed under the terms of the MIT license reproduced
below. This means that LuaSrcDiet is free software and can be used for
both academic and commercial purposes at absolutely no cost.
Parts of LuaSrcDiet is based on Lua 5 code. See COPYRIGHT_Lua51
(Lua 5.1.3) for Lua 5 license information.
For details and rationale, see http://www.lua.org/license.html .
===============================================================================
Copyright (C) 2005-2008 Kein-Hong Man <khman@users.sf.net>
Lua 5.1.3 Copyright (C) 1994-2008 Lua.org, PUC-Rio.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===============================================================================
(end of COPYRIGHT)
此差异已折叠。
--[[--------------------------------------------------------------------
llex.lua: Lua 5.1 lexical analyzer in Lua
This file is part of LuaSrcDiet, based on Yueliang material.
Copyright (c) 2008 Kein-Hong Man <khman@users.sf.net>
The COPYRIGHT file describes the conditions
under which this software may be distributed.
See the ChangeLog for more information.
----------------------------------------------------------------------]]
--[[--------------------------------------------------------------------
-- NOTES:
-- * This is a version of the native 5.1.x lexer from Yueliang 0.4.0,
-- with significant modifications to handle LuaSrcDiet's needs:
-- (1) llex.error is an optional error function handler
-- (2) seminfo for strings include their delimiters and no
-- translation operations are performed on them
-- * ADDED shbang handling has been added to support executable scripts
-- * NO localized decimal point replacement magic
-- * NO limit to number of lines
-- * NO support for compatible long strings (LUA_COMPAT_LSTR)
-- * Please read technotes.txt for more technical details.
----------------------------------------------------------------------]]
local base = _G
local string = require "string"
module "llex"
local find = string.find
local match = string.match
local sub = string.sub
----------------------------------------------------------------------
-- initialize keyword list, variables
----------------------------------------------------------------------
local kw = {}
for v in string.gmatch([[
and break do else elseif end false for function if in
local nil not or repeat return then true until while]], "%S+") do
kw[v] = true
end
-- NOTE: see init() for module variables (externally visible):
-- tok, seminfo, tokln
local z, -- source stream
sourceid, -- name of source
I, -- position of lexer
buff, -- buffer for strings
ln -- line number
----------------------------------------------------------------------
-- add information to token listing
----------------------------------------------------------------------
local function addtoken(token, info)
local i = #tok + 1
tok[i] = token
seminfo[i] = info
tokln[i] = ln
end
----------------------------------------------------------------------
-- handles line number incrementation and end-of-line characters
----------------------------------------------------------------------
local function inclinenumber(i, is_tok)
local sub = sub
local old = sub(z, i, i)
i = i + 1 -- skip '\n' or '\r'
local c = sub(z, i, i)
if (c == "\n" or c == "\r") and (c ~= old) then
i = i + 1 -- skip '\n\r' or '\r\n'
old = old..c
end
if is_tok then addtoken("TK_EOL", old) end
ln = ln + 1
I = i
return i
end
----------------------------------------------------------------------
-- initialize lexer for given source _z and source name _sourceid
----------------------------------------------------------------------
function init(_z, _sourceid)
z = _z -- source
sourceid = _sourceid -- name of source
I = 1 -- lexer's position in source
ln = 1 -- line number
tok = {} -- lexed token list*
seminfo = {} -- lexed semantic information list*
tokln = {} -- line numbers for messages*
-- (*) externally visible thru' module
--------------------------------------------------------------------
-- initial processing (shbang handling)
--------------------------------------------------------------------
local p, _, q, r = find(z, "^(#[^\r\n]*)(\r?\n?)")
if p then -- skip first line
I = I + #q
addtoken("TK_COMMENT", q)
if #r > 0 then inclinenumber(I, true) end
end
end
----------------------------------------------------------------------
-- returns a chunk name or id, no truncation for long names
----------------------------------------------------------------------
function chunkid()
if sourceid and match(sourceid, "^[=@]") then
return sub(sourceid, 2) -- remove first char
end
return "[string]"
end
----------------------------------------------------------------------
-- formats error message and throws error
-- * a simplified version, does not report what token was responsible
----------------------------------------------------------------------
function errorline(s, line)
local e = error or base.error
e(string.format("%s:%d: %s", chunkid(), line or ln, s))
end
local errorline = errorline
------------------------------------------------------------------------
-- count separators ("=") in a long string delimiter
------------------------------------------------------------------------
local function skip_sep(i)
local sub = sub
local s = sub(z, i, i)
i = i + 1
local count = #match(z, "=*", i) -- note, take the length
i = i + count
I = i
return (sub(z, i, i) == s) and count or (-count) - 1
end
----------------------------------------------------------------------
-- reads a long string or long comment
----------------------------------------------------------------------
local function read_long_string(is_str, sep)
local i = I + 1 -- skip 2nd '['
local sub = sub
local c = sub(z, i, i)
if c == "\r" or c == "\n" then -- string starts with a newline?
i = inclinenumber(i) -- skip it
end
local j = i
while true do
local p, q, r = find(z, "([\r\n%]])", i) -- (long range)
if not p then
errorline(is_str and "unfinished long string" or
"unfinished long comment")
end
i = p
if r == "]" then -- delimiter test
if skip_sep(i) == sep then
buff = sub(z, buff, I)
I = I + 1 -- skip 2nd ']'
return buff
end
i = I
else -- newline
buff = buff.."\n"
i = inclinenumber(i)
end
end--while
end
----------------------------------------------------------------------
-- reads a string
----------------------------------------------------------------------
local function read_string(del)
local i = I
local find = find
local sub = sub
while true do
local p, q, r = find(z, "([\n\r\\\"\'])", i) -- (long range)
if p then
if r == "\n" or r == "\r" then
errorline("unfinished string")
end
i = p
if r == "\\" then -- handle escapes
i = i + 1
r = sub(z, i, i)
if r == "" then break end -- (EOZ error)
p = find("abfnrtv\n\r", r, 1, true)
------------------------------------------------------
if p then -- special escapes
if p > 7 then
i = inclinenumber(i)
else
i = i + 1
end
------------------------------------------------------
elseif find(r, "%D") then -- other non-digits
i = i + 1
------------------------------------------------------
else -- \xxx sequence
local p, q, s = find(z, "^(%d%d?%d?)", i)
i = q + 1
if s + 1 > 256 then -- UCHAR_MAX
errorline("escape sequence too large")
end
------------------------------------------------------
end--if p
else
i = i + 1
if r == del then -- ending delimiter
I = i
return sub(z, buff, i - 1) -- return string
end
end--if r
else
break -- (error)
end--if p
end--while
errorline("unfinished string")
end
------------------------------------------------------------------------
-- main lexer function
------------------------------------------------------------------------
function llex()
local find = find
local match = match
while true do--outer
local i = I
-- inner loop allows break to be used to nicely section tests
while true do--inner
----------------------------------------------------------------
local p, _, r = find(z, "^([_%a][_%w]*)", i)
if p then
I = i + #r
if kw[r] then
addtoken("TK_KEYWORD", r) -- reserved word (keyword)
else
addtoken("TK_NAME", r) -- identifier
end
break -- (continue)
end
----------------------------------------------------------------
local p, _, r = find(z, "^(%.?)%d", i)
if p then -- numeral
if r == "." then i = i + 1 end
local _, q, r = find(z, "^%d*[%.%d]*([eE]?)", i)
i = q + 1
if #r == 1 then -- optional exponent
if match(z, "^[%+%-]", i) then -- optional sign
i = i + 1
end
end
local _, q = find(z, "^[_%w]*", i)
I = q + 1
local v = sub(z, p, q) -- string equivalent
if not base.tonumber(v) then -- handles hex test also
errorline("malformed number")
end
addtoken("TK_NUMBER", v)
break -- (continue)
end
----------------------------------------------------------------
local p, q, r, t = find(z, "^((%s)[ \t\v\f]*)", i)
if p then
if t == "\n" or t == "\r" then -- newline
inclinenumber(i, true)
else
I = q + 1 -- whitespace
addtoken("TK_SPACE", r)
end
break -- (continue)
end
----------------------------------------------------------------
local r = match(z, "^%p", i)
if r then
buff = i
local p = find("-[\"\'.=<>~", r, 1, true)
if p then
-- two-level if block for punctuation/symbols
--------------------------------------------------------
if p <= 2 then
if p == 1 then -- minus
local c = match(z, "^%-%-(%[?)", i)
if c then
i = i + 2
local sep = -1
if c == "[" then
sep = skip_sep(i)
end
if sep >= 0 then -- long comment
addtoken("TK_LCOMMENT", read_long_string(false, sep))
else -- short comment
I = find(z, "[\n\r]", i) or (#z + 1)
addtoken("TK_COMMENT", sub(z, buff, I - 1))
end
break -- (continue)
end
-- (fall through for "-")
else -- [ or long string
local sep = skip_sep(i)
if sep >= 0 then
addtoken("TK_LSTRING", read_long_string(true, sep))
elseif sep == -1 then
addtoken("TK_OP", "[")
else
errorline("invalid long string delimiter")
end
break -- (continue)
end
--------------------------------------------------------
elseif p <= 5 then
if p < 5 then -- strings
I = i + 1
addtoken("TK_STRING", read_string(r))
break -- (continue)
end
r = match(z, "^%.%.?%.?", i) -- .|..|... dots
-- (fall through)
--------------------------------------------------------
else -- relational
r = match(z, "^%p=?", i)
-- (fall through)
end
end
I = i + #r
addtoken("TK_OP", r) -- for other symbols, fall through
break -- (continue)
end
----------------------------------------------------------------
local r = sub(z, i, i)
if r ~= "" then
I = i + 1
addtoken("TK_OP", r) -- other single-char tokens
break
end
addtoken("TK_EOS", "") -- end of stream,
return -- exit here
----------------------------------------------------------------
end--while inner
end--while outer
end
return base.getfenv()
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -103,6 +103,9 @@ define Package/luci-lib-core/config
config PACKAGE_luci-lib-core_stripped
bool "Stripped"
config PACKAGE_luci-lib-core_srcdiet
bool "Compressed Source"
config PACKAGE_luci-lib-core_source
bool "Full Source"
......@@ -117,8 +120,8 @@ ifneq ($(CONFIG_PACKAGE_luci-lib-core_stripped),)
LUA_TARGET:=strip
endif
ifneq ($(CONFIG_PACKAGE_luci-lib-core_zipped),)
LUA_TARGET:=gzip
ifneq ($(CONFIG_PACKAGE_luci-lib-core_srcdiet),)
LUA_TARGET:=diet
endif
ifneq ($(CONFIG_PACKAGE_luci-lib-core),)
......
......@@ -242,10 +242,19 @@ function has_ipv6(self)
end
function add_network(self, n, options)
if n and #n > 0 and n:match("^[a-zA-Z0-9_]+$") and not self:get_network(n) then
local oldnet = self:get_network(n)
if n and #n > 0 and n:match("^[a-zA-Z0-9_]+$") and not oldnet then
if uci_r:section("network", "interface", n, options) then
return network(n)
end
elseif oldnet and oldnet:is_empty() then
if options then
local k, v
for k, v in pairs(options) do
oldnet:set(k, v)
end
end
return oldnet
end
end
......@@ -1016,7 +1025,7 @@ end
function wifinet.active_mode(self)
local m = _stror(self.iwinfo.mode, self.iwdata.mode) or "ap"
if m == "ap" then m = "AP"
if m == "ap" then m = "Master"
elseif m == "sta" then m = "Client"
elseif m == "adhoc" then m = "Ad-Hoc"
elseif m == "mesh" then m = "Mesh"
......@@ -1118,8 +1127,7 @@ function wifinet.get_i18n(self)
end
function wifinet.adminlink(self)
return dsp.build_url("admin", "network", "wireless",
self.iwdata.device, self.netid)
return dsp.build_url("admin", "network", "wireless", self.netid)
end
function wifinet.get_network(self)
......
......@@ -402,16 +402,24 @@ function cbi_filebrowser(id, url, defpath) {
browser.focus();
}
function cbi_dynlist_init(name)
function cbi_dynlist_init(name, respath)
{
function cbi_dynlist_renumber(e)
{
var count = 1;
var childs = e.parentNode.childNodes;
for( var i = 0; i < childs.length; i++ )
if( childs[i].name == name )
childs[i].id = name + '.' + (count++);
/* in a perfect world, we could just getElementsByName() - but not if
* MSIE is involved... */
var inputs = [ ]; // = document.getElementsByName(name);
for (var i = 0; i < e.parentNode.childNodes.length; i++)
if (e.parentNode.childNodes[i].name == name)
inputs.push(e.parentNode.childNodes[i]);
for (var i = 0; i < inputs.length; i++)
{
inputs[i].id = name + '.' + (i + 1);
inputs[i].nextSibling.src = respath + (
(i+1) < inputs.length ? '/cbi/remove.gif' : '/cbi/add.gif'
);
}
e.focus();
}
......@@ -480,6 +488,7 @@ function cbi_dynlist_init(name)
if (se.value.length == 0 && jump)
{
se.parentNode.removeChild(se.nextSibling.nextSibling);
se.parentNode.removeChild(se.nextSibling);
se.parentNode.removeChild(se);
......@@ -488,6 +497,9 @@ function cbi_dynlist_init(name)
if (ev.preventDefault)
ev.preventDefault();
/* IE Quirk, needs double focus somehow */
jump.focus();
return false;
}
......@@ -499,17 +511,22 @@ function cbi_dynlist_init(name)
n.name = se.name;
n.type = se.type;
var b = document.createElement('img');
cbi_bind(n, 'keydown', cbi_dynlist_keydown);
cbi_bind(n, 'keypress', cbi_dynlist_keypress);
cbi_bind(b, 'click', cbi_dynlist_btnclick);
if (next)
{
se.parentNode.insertBefore(n, next);
se.parentNode.insertBefore(b, next);
se.parentNode.insertBefore(document.createElement('br'), next);
}
else
{
se.parentNode.appendChild(n);
se.parentNode.appendChild(b);
se.parentNode.appendChild(document.createElement('br'));
}
......@@ -540,11 +557,45 @@ function cbi_dynlist_init(name)
return true;
}
function cbi_dynlist_btnclick(ev)
{
ev = ev ? ev : window.event;
var se = ev.target ? ev.target : ev.srcElement;
if (se.src.indexOf('remove') > -1)
{
se.previousSibling.value = '';
cbi_dynlist_keydown({
target: se.previousSibling,
keyCode: 8
});
}
else
{
cbi_dynlist_keydown({
target: se.previousSibling,
keyCode: 13
});
}
return false;
}
var inputs = document.getElementsByName(name);
for( var i = 0; i < inputs.length; i++ )
{
var btn = document.createElement('img');
btn.src = respath + (
(i+1) < inputs.length ? '/cbi/remove.gif' : '/cbi/add.gif'
);
inputs[i].parentNode.insertBefore(btn, inputs[i].nextSibling);
cbi_bind(inputs[i], 'keydown', cbi_dynlist_keydown);
cbi_bind(inputs[i], 'keypress', cbi_dynlist_keypress);
cbi_bind(btn, 'click', cbi_dynlist_btnclick);
}
}
......@@ -718,6 +769,56 @@ function cbi_validate_field(cbid, optional, type)
}
}
function cbi_row_swap(elem, up, store)
{
var tr = elem.parentNode;
while (tr && tr.nodeName.toLowerCase() != 'tr')
tr = tr.parentNode;
if (!tr)
return false;
var table = tr.parentNode;
while (table && table.nodeName.toLowerCase() != 'table')
table = table.parentNode;
if (!table)
return false;
var s = up ? 3 : 2;
var e = up ? table.rows.length : table.rows.length - 1;
for (var idx = s; idx < e; idx++)
{
if (table.rows[idx] == tr)
{
if (up)
tr.parentNode.insertBefore(table.rows[idx], table.rows[idx-1]);
else
tr.parentNode.insertBefore(table.rows[idx+1], table.rows[idx]);
break;
}
}
var ids = [ ];
for (idx = 2; idx < table.rows.length; idx++)
{
table.rows[idx].className = table.rows[idx].className.replace(
/cbi-rowstyle-[12]/, 'cbi-rowstyle-' + (1 + (idx % 2))
);
if (table.rows[idx].id && table.rows[idx].id.match(/-([^\-]+)$/) )
ids.push(RegExp.$1);
}
var input = document.getElementById(store);
if (input)
input.value = ids.join(' ');
return false;
}
if( ! String.serialize )
String.serialize = function(o)
{
......
......@@ -50,6 +50,7 @@ AUTO = true
CREATE_PREFIX = "cbi.cts."
REMOVE_PREFIX = "cbi.rts."
RESORT_PREFIX = "cbi.sts."
-- Loads a CBI map from given file, creating an environment and returns it
function load(cbimap, ...)
......@@ -1121,6 +1122,20 @@ function TypedSection.parse(self, novld)
end
end
if self.sortable then
local stval = RESORT_PREFIX .. self.config .. "." .. self.sectiontype
local order = self.map:formvalue(stval)
if order and #order > 0 then
local sid
local num = 0
for sid in util.imatch(order) do
self.map.uci:reorder(self.config, sid, num)
num = num + 1
end
self.changed = (num > 0)
end
end
if created or self.changed then
self:push_events()
end
......
......@@ -27,7 +27,7 @@ $Id$
<% end end %>
</div>
<script type="text/javascript">
cbi_dynlist_init('<%=cbid%>');
cbi_dynlist_init('<%=cbid%>', '<%=resource%>');
<% if self.datatype then -%>
<% if #self.keylist > 0 then -%>
cbi_combobox_init('<%=cbid .. "." .. i%>', {
......
......@@ -35,6 +35,9 @@ end
<% if self.title and #self.title > 0 then -%>
<legend><%=self.title%></legend>
<%- end %>
<%- if self.sortable then -%>
<input type="hidden" id="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" name="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" value="" />
<%- end -%>
<div class="cbi-section-descr"><%=self.description%></div>
<div class="cbi-section-node">
<%- local count = 0 -%>
......@@ -53,7 +56,9 @@ end
<%-=k.title-%>
<%- if k.titleref then -%></a><%- end -%>
</th>
<%- count = count + 1; end; end; if self.extedit or self.addremove then -%>
<%- count = count + 1; end; end; if self.sortable then -%>
<th class="cbi-section-table-cell"><%:Sort%></th>
<%- end; if self.extedit or self.addremove then -%>
<th class="cbi-section-table-cell">&#160;</th>
<%- count = count + 1; end -%>
</tr>
......@@ -67,7 +72,9 @@ end
<%- end -%>
<%- for i, k in pairs(self.children) do if not k.optional then -%>
<th class="cbi-section-table-cell"<%=width(k)%>><%=k.description%></th>
<%- end; end; if self.extedit or self.addremove then -%>
<%- end; end; if self.sortable then -%>
<th class="cbi-section-table-cell"></th>
<%- end; if self.extedit or self.addremove then -%>
<th class="cbi-section-table-cell"></th>
<%- end -%>
</tr>
......@@ -91,6 +98,13 @@ end
end
-%>
<%- if self.sortable then -%>
<td class="cbi-section-table-cell" style="width:50px">
<a href="#" onclick="return cbi_row_swap(this, true, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" title="<%:Move up%>"><img src="<%=resource%>/cbi/up.gif" alt="<%:Move up%>" /></a>
<a href="#" onclick="return cbi_row_swap(this, false, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" title="<%:Move down%>"><img src="<%=resource%>/cbi/down.gif" alt="<%:Move down%>" /></a>
</td>
<%- end -%>
<%- if self.extedit or self.addremove then -%>
<td class="cbi-section-table-cell" style="width:50px">
<%- if self.extedit then -%>
......
......@@ -17,6 +17,7 @@ module("luci.controller.admin.network", package.seeall)
function index()
require("luci.i18n")
local uci = require("luci.model.uci").cursor()
local net = require "luci.model.network".init(uci)
local i18n = luci.i18n.translate
local has_wifi = nixio.fs.stat("/etc/config/wireless")
local has_switch = false
......@@ -59,6 +60,18 @@ function index()
page = entry({"admin", "network", "wireless_status"}, call("wifi_status"), nil, 16)
page.leaf = true
local wdev
for _, wdev in ipairs(net:get_wifidevs()) do
local wnet
for _, wnet in ipairs(wdev:get_wifinets()) do
entry(
{"admin", "network", "wireless", wnet.netid},
alias("admin", "network", "wireless"),
wdev:name() .. ": " .. wnet:shortname()
)
end
end
end
page = entry({"admin", "network", "network"}, arcombine(cbi("admin_network/network"), cbi("admin_network/ifaces")), i18n("Interfaces"), 10)
......@@ -307,6 +320,7 @@ function iface_delete()
end
function wifi_status()
local netm = require "luci.model.network".init()
local path = luci.dispatcher.context.requestpath
local arp = luci.sys.net.arptable()
local rv = { }
......@@ -314,17 +328,22 @@ function wifi_status()
local dev
for dev in path[#path]:gmatch("[%w%.%-]+") do
local j = { id = dev }
local iw = luci.sys.wifi.getiwinfo(dev)
local wn = netm:get_wifinet(dev)
local iw = wn and wn.iwinfo
if iw then
local f
for _, f in ipairs({
"channel", "frequency", "txpower", "bitrate", "signal", "noise",
"quality", "quality_max", "mode", "ssid", "bssid", "country",
"quality", "quality_max", "bssid", "country",
"encryption", "ifname", "assoclist"
}) do
j[f] = iw[f]
end
end
j.mode = wn and wn:active_mode() or "?"
j.ssid = wn and wn:active_ssid() or "?"
rv[#rv+1] = j
end
......
......@@ -24,7 +24,7 @@ function index()
entry({"admin", "uci", "changes"}, call("action_changes"), i18n("Changes"), 40).query = {redir=redir}
entry({"admin", "uci", "revert"}, call("action_revert"), i18n("Revert"), 30).query = {redir=redir}
entry({"admin", "uci", "apply"}, call("action_apply"), i18n("Apply"), 20).query = {redir=redir}
entry({"admin", "uci", "saveapply"}, call("action_apply"), i18n("Save & Apply"), 10).query = {redir=redir}
entry({"admin", "uci", "saveapply"}, call("action_apply"), i18n("Save &#38; Apply"), 10).query = {redir=redir}
end
function action_changes()
......
......@@ -17,7 +17,6 @@ local nw = require "luci.model.network"
local fs = require "nixio.fs"
arg[1] = arg[1] or ""
arg[2] = arg[2] or ""
m = Map("wireless", "",
translate("The <em>Device Configuration</em> section covers physical settings of the radio " ..
......@@ -30,24 +29,25 @@ m:chain("network")
local ifsection
function m.on_commit(map)
local wnet = nw:get_wifinet(arg[2])
local wnet = nw:get_wifinet(arg[1])
if ifsection and wnet then
ifsection.section = wnet.sid
m.title = wnet:get_i18n()
m.title = luci.util.pcdata(wnet:get_i18n())
end
end
nw.init(m.uci)
local wnet = nw:get_wifinet(arg[2])
local wnet = nw:get_wifinet(arg[1])
local wdev = wnet and wnet:get_device()
-- redirect to overview page if network does not exist anymore (e.g. after a revert)
if not wnet then
if not wnet or not wdev then
luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless"))
return
end
m.title = wnet:get_i18n()
m.title = luci.util.pcdata(wnet:get_i18n())
local iw = luci.sys.wifi.getiwinfo(arg[1])
......@@ -55,7 +55,7 @@ local tx_powers = iw.txpwrlist or { }
local hw_modes = iw.hwmodelist or { }
s = m:section(NamedSection, arg[1], "wifi-device", translate("Device Configuration"))
s = m:section(NamedSection, wdev:name(), "wifi-device", translate("Device Configuration"))
s.addremove = false
s:tab("general", translate("General Setup"))
......@@ -70,7 +70,7 @@ back.titleref = luci.dispatcher.build_url("admin", "network", "wireless")
st = s:taboption("general", DummyValue, "__status", translate("Status"))
st.template = "admin_network/wifi_status"
st.ifname = arg[2]
st.ifname = arg[1]
en = s:taboption("general", Flag, "disabled", translate("Enable device"))
en.enabled = "0"
......@@ -82,11 +82,11 @@ function en.cfgvalue(self, section)
end
local hwtype = m:get(arg[1], "type")
local htcaps = m:get(arg[1], "ht_capab") and true or false
local hwtype = wdev:get("type")
local htcaps = wdev:get("ht_capab") and true or false
-- NanoFoo
local nsantenna = m:get(arg[1], "antenna")
local nsantenna = wdev:get("antenna")
ch = s:taboption("general", Value, "channel", translate("Channel"))
ch:value("auto", translate("auto"))
......@@ -276,7 +276,7 @@ s = m:section(NamedSection, wnet.sid, "wifi-iface", translate("Interface Configu
ifsection = s
s.addremove = false
s.anonymous = true
s.defaults.device = arg[1]
s.defaults.device = wdev:name()
s:tab("general", translate("General Setup"))
s:tab("encryption", translate("Wireless Security"))
......@@ -633,7 +633,7 @@ wepslot.cfgvalue = function(self, section)
if not slot or slot < 1 or slot > 4 then
return 1
end
return slot
return slot
end
wepslot.write = function(self, section, value)
......@@ -648,7 +648,7 @@ for slot=1,4 do
wepkey.datatype = "wepkey"
wepkey.rmempty = true
wepkey.password = true
function wepkey.write(self, section, value)
if value and (#value == 5 or #value == 13) then
value = "s:" .. value
......
......@@ -166,9 +166,7 @@ function newnet.parse(self, section)
uci:save("network")
uci:save("firewall")
luci.http.redirect(luci.dispatcher.build_url(
"admin/network/wireless", wdev:name(), wnet:ifname()
))
luci.http.redirect(wnet:adminlink())
end
end
end
......
......@@ -33,8 +33,8 @@ $Id$
'<%:Waiting for router...%>'
;
legend.style.display = null;
legend.parentNode.style.display = 'block';
legend.style.display = 'inline';
stxhr.get('<%=luci.dispatcher.build_url("admin", "network")%>/diag_' + tool + '/' + addr, null,
function(x)
......
......@@ -167,7 +167,7 @@ $Id$
{
if (is_assoc)
info.innerHTML = String.format(
'<strong><%:SSID%>:</strong> %s | ' +
'<strong><%:SSID%>:</strong> %h | ' +
'<strong><%:Mode%>:</strong> %s<br />' +
'<strong><%:BSSID%>:</strong> %s | ' +
'<strong><%:Encryption%>:</strong> %s',
......@@ -175,7 +175,12 @@ $Id$
iw.encryption ? iw.encryption.description : '<%:None%>'
);
else
info.innerHTML = '<em><%:Wireless is disabled or not associated%></em>';
info.innerHTML = String.format(
'<strong><%:SSID%>:</strong> %h | ' +
'<strong><%:Mode%>:</strong> %s<br />' +
'<em><%:Wireless is disabled or not associated%></em>',
iw.ssid || '?', iw.mode
);
}
var dev = document.getElementById(wifidevs[iw.id] + '-iw-devinfo');
......
......@@ -37,7 +37,7 @@
if (d && is_assoc)
d.innerHTML = String.format(
'<strong><%:Mode%>:</strong> %s | ' +
'<strong><%:SSID%>:</strong> %s<br />' +
'<strong><%:SSID%>:</strong> %h<br />' +
'<strong><%:BSSID%>:</strong> %s | ' +
'<strong><%:Encryption%>:</strong> %s<br />' +
'<strong><%:Channel%>:</strong> %d (%.3f GHz) | ' +
......@@ -53,7 +53,12 @@
iw.bitrate ? (iw.bitrate / 1000) : 0, iw.country
);
else if (d)
d.innerHTML = '<%:Wireless is disabled or not associated%>';
d.innerHTML = String.format(
'<strong><%:SSID%>:</strong> %h | ' +
'<strong><%:Mode%>:</strong> %s<br />' +
'<em><%:Wireless is disabled or not associated%></em>',
iw.ssid || '?', iw.mode
);
}
window.setTimeout(update_status, 5000);
......
......@@ -74,6 +74,12 @@ require("luci.http").prepare_content("application/xhtml+xml")
</div></div>
<![endif]-->
<%- if luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%>
<div class="warning">
<strong><%:No password set!%></strong><br />
<%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%>
</div>
<%- end -%>
<p class="skiplink">
<span id="skiplink1"><a href="#navigation"><%:skiplink1 Skip to navigation%></a></span>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册