package.loaders[2] = function(mod)
local encoded = cachepath .. "/" .. _encode_filename(mod)
local modcons = _load_sane(encoded)
-
+
if modcons then
return modcons
end
limitsource(io.stdin, tonumber(luci.sys.getenv("CONTENT_LENGTH"))),
ltn12.sink.file(io.stderr)
)
-
+
local x = coroutine.create(luci.dispatcher.httpdispatch)
local hcache = ""
local active = true
-
+
while coroutine.status(x) ~= "dead" do
local res, id, data1, data2 = coroutine.resume(x, r)
-- Create a new namespace for this template
self.viewns = context.viewns
-
+
-- If we have a cached template, skip compiling and loading
if not self.template then
-- Renders a template
function Template.render(self, scope)
scope = scope or getfenv(2)
-
+
-- Put our predefined objects in the scope of the template
setfenv(self.template, setmetatable({}, {__index =
function(tbl, key)
return rawget(tbl, key) or self.viewns[key] or scope[key]
end}))
-
+
-- Now finally render the thing
local stat, err = util.copcall(self.template)
if not stat then
end
netmod:register_pattern_virtual("^vpn%-%w")
-
if byte > 1024 and i < 5 then
byte = byte / 1024
else
- return string.format("%.2f %s", byte, suff[i])
- end
+ return string.format("%.2f %s", byte, suff[i])
+ end
end
end
local mins = 0
local hour = 0
local days = 0
-
+
secs = math.floor(secs)
if secs > 60 then
mins = math.floor(secs / 60)
secs = secs % 60
end
-
+
if mins > 60 then
hour = math.floor(mins / 60)
mins = mins % 60
end
-
+
if hour > 24 then
days = math.floor(hour / 24)
hour = hour % 24
end
-
+
if days > 0 then
return string.format("%.0fd %02.0fh %02.0fmin %02.0fs", days, hour, mins, secs)
else
function firewall_find_zone(name)
local find
-
- luci.model.uci.cursor():foreach("firewall", "zone",
+
+ luci.model.uci.cursor():foreach("firewall", "zone",
function (section)
if section.name == name then
find = section[".name"]
end
end
)
-
+
return find
end
root.target = alias("mini")
root.index = true
end
-
+
entry({"about"}, template("about"))
-
+
local page = entry({"mini"}, alias("mini", "index"), _("Essentials"), 10)
page.sysauth = "root"
page.sysauth_authenticator = "htmlauth"
page.index = true
-
+
entry({"mini", "index"}, alias("mini", "index", "index"), _("Overview"), 10).index = true
entry({"mini", "index", "index"}, form("mini/index"), _("General"), 1).ignoreindex = true
entry({"mini", "index", "luci"}, cbi("mini/luci", {autoapply=true}), _("Settings"), 10)
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
+
+ local restore_fpi
luci.http.setfilehandler(
function(meta, chunk, eof)
if not restore_fpi then
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()
require("luci.model.uci")
local tmpfile = "/tmp/firmware.img"
-
+
local function image_supported()
-- XXX: yay...
return ( 0 == os.execute(
% tmpfile
) )
end
-
+
local function image_checksum()
return (luci.sys.exec("md5sum %q" % tmpfile):match("^([^%s]+)"))
end
-
+
local function storage_size()
local size = 0
if nixio.fs.access("/proc/mtd") then
local has_support = image_supported()
local has_platform = nixio.fs.access("/lib/upgrade/platform.sh")
local has_upload = luci.http.formvalue("image")
-
+
-- This does the actual flashing which is invoked inside an iframe
- -- so don't produce meaningful errors here because the the
+ -- so don't produce meaningful errors here because the the
-- previous pages should arrange the stuff as required.
if step == 4 then
if has_platform and has_image and has_support then
if has_image then
nixio.fs.unlink(tmpfile)
end
-
+
luci.template.render("mini/upgrade", {
step=1,
bad_image=(has_image and not has_support or false),
flashsize=storage_size(),
keepconfig=(keep_avail and luci.http.formvalue("keepcfg") == "1")
} )
-
+
-- Step 3: load iframe which calls the actual flash procedure
elseif step == 3 then
luci.template.render("mini/upgrade", {
step=3,
keepconfig=(keep_avail and luci.http.formvalue("keepcfg") == "1")
} )
- end
+ end
end
function _keep_pattern()
function limit.cfgvalue(self, section)
local value = Value.cfgvalue(self, section)
-
+
if value then
return tonumber(value) + 1
- end
+ end
end
function limit.write(self, section, value)
value = tonumber(value) - 1
- return Value.write(self, section, value)
+ return Value.write(self, section, value)
end
limit.rmempty = true
function(section)
leasefn = section.leasefile
end
-)
+)
local leasefp = leasefn and fs.access(leasefn) and io.lines(leasefn)
if leasefp then
leases = {}
function f.handle(self, state, data)
if state == FORM_VALID then
local stat = luci.sys.user.setpasswd("root", data.pw1) == 0
-
+
if stat then
f.message = translate("Password successfully changed")
else
f.errmessage = translate("Unknown Error")
end
-
+
data.pw1 = nil
data.pw2 = nil
end
encr.description = translate(
"WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " ..
"and ad-hoc mode) to be installed."
- )
+ )
else
encr.description = translate(
"WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " ..
o = s.taboption('general', form.DynamicList, 'address', _('Addresses'),
_('List of domains to force to an IP address.'));
-
+
o.optional = true;
o.placeholder = '/router.local/192.168.0.1';
o = ss.taboption('advanced', CBIWifiCountryValue, 'country', _('Country Code'));
o.wifiNetwork = radioNet;
-
+
o = ss.taboption('advanced', form.ListValue, 'cell_density', _('Coverage cell density'), _('Configures data rates based on the coverage cell density. Normal configures basic rates to 6, 12, 24 Mbps if legacy 802.11b rates are not used else to 5.5, 11 Mbps. High configures basic rates to 12, 24 Mbps if legacy 802.11b rates are not used else to the 11 Mbps rate. Very High configures 24 Mbps as the basic rate. Supported rates lower than the minimum basic rate are not offered.'));
o.value('0', _('Disabled'));
o.value('1', _('Normal'));
function resolve(mod, method)
local path = luci.util.split(method, ".")
-
+
for j=1, #path-1 do
if not type(mod) == "table" then
break
local json = decoder:get()
local response
local success = false
-
+
if stat then
if type(json.method) == "string"
and (not json.params or type(json.params) == "table") then
function reply(jsonrpc, id, res, err)
require "luci.json"
id = id or luci.json.null
-
+
-- 1.0 compatibility
if jsonrpc ~= "2.0" then
jsonrpc = nil
res = res or luci.json.null
err = err or luci.json.null
end
-
+
return {id=id, result=res, error=err, jsonrpc=jsonrpc}
end
function proxy(method, ...)
local res = {luci.util.copcall(method, ...)}
local stat = table.remove(res, 1)
-
+
if not stat then
- return nil, {code=-32602, message="Invalid params.", data=table.remove(res, 1)}
+ return nil, {code=-32602, message="Invalid params.", data=table.remove(res, 1)}
else
if #res <= 1 then
return res[1] or luci.json.null
end
function delete(config, ...)
- uci:load(config)
- return uci:delete(config, ...) and uci:save(config)
+ uci:load(config)
+ return uci:delete(config, ...) and uci:save(config)
end
function delete_all(config, ...)
uci:load(config)
- return uci:delete_all(config, ...) and uci:save(config)
+ return uci:delete_all(config, ...) and uci:save(config)
end
function foreach(config, stype)
uci:load(config)
local sections = {}
-
+
return uci:foreach(config, stype, function(section)
table.insert(sections, section)
end) and sections
uci:load(config)
return uci:tset(config, ...) and uci:save(config)
end
-
tab: tab,
};
- this.radios[ifname+freq] = {
+ this.radios[ifname+freq] = {
dev: wifiDevs[ifname].dev,
graph: graph_data,
table: table,
ht = rt.ht, vht = rt.vht,
mhz = rt.mhz, nss = rt.nss,
mcs = rt.mcs, sgi = rt.short_gi;
-
+
if (ht || vht) {
if (vht) s += ', VHT-MCS\xa0%d'.format(mcs);
if (nss) s += ', VHT-NSS\xa0%d'.format(nss);
if (ht) s += ', MCS\xa0%s'.format(mcs);
if (sgi) s += ', ' + _('Short GI').replace(/ /g, '\xa0');
}
-
+
return s;
},
freq = null,
rate = null,
badges = [];
-
+
for (var i = 0; i < networks.length; i++) {
var net = networks[i],
is_assoc = (net.getBSSID() != '00:00:00:00:00:00' && net.getChannel() && !net.isDisabled()),
quality = net.getSignalPercent();
-
+
var icon;
if (net.isDisabled())
icon = L.resource('icons/signal-none.png');
}, [ _('Start WPS') ])
}
}
-
+
var badge = renderBadge(
icon,
'%s: %d dBm / %s: %d%%'.format(_('Signal'), net.getSignal(), _('Quality'), quality),
_('WPS status'), this.WPSTranslateTbl[net.wps_status],
'', WPS_button
);
-
+
badges.push(badge);
-
+
chan = (chan != null) ? chan : net.getChannel();
freq = (freq != null) ? freq : net.getFrequency();
rate = (rate != null) ? rate : net.getBitRate();
}
-
+
return E('div', { class: 'ifacebox' }, [
E('div', { class: 'ifacebox-head center ' + (radio.isUp() ? 'active' : '') },
E('strong', radio.getName())),
}).render()
)
}
- else {
+ else {
row.push(E('button', {
'class': 'cbi-button cbi-button-remove',
'click': L.bind(this.handleDelClient, this, networks[i], bss.mac)
handleSave: null,
handleReset: null
});
-