mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Update luci-base
This commit is contained in:
parent
c3dc257a80
commit
e7ae8eed52
8 changed files with 761 additions and 290 deletions
|
@ -9,7 +9,7 @@ local function readfile(path)
|
|||
end
|
||||
|
||||
local methods = {
|
||||
initList = {
|
||||
getInitList = {
|
||||
args = { name = "name" },
|
||||
call = function(args)
|
||||
local sys = require "luci.sys"
|
||||
|
@ -22,11 +22,11 @@ local methods = {
|
|||
return { error = "No such init script" }
|
||||
end
|
||||
end
|
||||
return { result = scripts }
|
||||
return scripts
|
||||
end
|
||||
},
|
||||
|
||||
initCall = {
|
||||
setInitAction = {
|
||||
args = { name = "name", action = "action" },
|
||||
call = function(args)
|
||||
local sys = require "luci.sys"
|
||||
|
@ -39,7 +39,7 @@ local methods = {
|
|||
|
||||
getLocaltime = {
|
||||
call = function(args)
|
||||
return { localtime = os.time() }
|
||||
return { result = os.time() }
|
||||
end
|
||||
},
|
||||
|
||||
|
@ -52,11 +52,11 @@ local methods = {
|
|||
sys.call("date -s '%04d-%02d-%02d %02d:%02d:%02d' >/dev/null" %{ date.year, date.month, date.day, date.hour, date.min, date.sec })
|
||||
sys.call("/etc/init.d/sysfixtime restart >/dev/null")
|
||||
end
|
||||
return { localtime = args.localtime }
|
||||
return { result = args.localtime }
|
||||
end
|
||||
},
|
||||
|
||||
timezone = {
|
||||
getTimezones = {
|
||||
call = function(args)
|
||||
local util = require "luci.util"
|
||||
local zones = require "luci.sys.zoneinfo"
|
||||
|
@ -76,11 +76,11 @@ local methods = {
|
|||
active = (res and res.value == zone[1]) and true or nil
|
||||
}
|
||||
end
|
||||
return { result = result }
|
||||
return result
|
||||
end
|
||||
},
|
||||
|
||||
leds = {
|
||||
getLEDs = {
|
||||
call = function()
|
||||
local iter = fs.dir("/sys/class/leds")
|
||||
local result = { }
|
||||
|
@ -115,7 +115,7 @@ local methods = {
|
|||
end
|
||||
},
|
||||
|
||||
usb = {
|
||||
getUSBDevices = {
|
||||
call = function()
|
||||
local fs = require "nixio.fs"
|
||||
local iter = fs.glob("/sys/bus/usb/devices/[0-9]*/manufacturer")
|
||||
|
@ -126,7 +126,7 @@ local methods = {
|
|||
|
||||
local p
|
||||
for p in iter do
|
||||
local id = p:match("%d+-%d+")
|
||||
local id = p:match("/([^/]+)/manufacturer$")
|
||||
|
||||
result.devices[#result.devices+1] = {
|
||||
id = id,
|
||||
|
@ -139,18 +139,19 @@ local methods = {
|
|||
end
|
||||
end
|
||||
|
||||
iter = fs.glob("/sys/bus/usb/devices/*/usb[0-9]*-port[0-9]*")
|
||||
iter = fs.glob("/sys/bus/usb/devices/*/*-port[0-9]*")
|
||||
|
||||
if iter then
|
||||
result.ports = {}
|
||||
|
||||
local p
|
||||
for p in iter do
|
||||
local bus, port = p:match("usb(%d+)-port(%d+)")
|
||||
local port = p:match("([^/]+)$")
|
||||
local link = fs.readlink(p.."/device")
|
||||
|
||||
result.ports[#result.ports+1] = {
|
||||
hub = tonumber(bus),
|
||||
port = tonumber(port)
|
||||
port = port,
|
||||
device = link and fs.basename(link)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -159,20 +160,20 @@ local methods = {
|
|||
end
|
||||
},
|
||||
|
||||
ifaddrs = {
|
||||
getIfaddrs = {
|
||||
call = function()
|
||||
return { result = nixio.getifaddrs() }
|
||||
end
|
||||
},
|
||||
|
||||
host_hints = {
|
||||
getHostHints = {
|
||||
call = function()
|
||||
local sys = require "luci.sys"
|
||||
return sys.net.host_hints()
|
||||
end
|
||||
},
|
||||
|
||||
duid_hints = {
|
||||
getDUIDHints = {
|
||||
call = function()
|
||||
local fp = io.open('/var/hosts/odhcpd')
|
||||
local result = { }
|
||||
|
@ -192,7 +193,7 @@ local methods = {
|
|||
end
|
||||
},
|
||||
|
||||
leases = {
|
||||
getDHCPLeases = {
|
||||
args = { family = 0 },
|
||||
call = function(args)
|
||||
local s = require "luci.tools.status"
|
||||
|
@ -210,7 +211,7 @@ local methods = {
|
|||
end
|
||||
},
|
||||
|
||||
netdevs = {
|
||||
getNetworkDevices = {
|
||||
call = function(args)
|
||||
local dir = fs.dir("/sys/class/net")
|
||||
local result = { }
|
||||
|
@ -273,52 +274,138 @@ local methods = {
|
|||
end
|
||||
},
|
||||
|
||||
boardjson = {
|
||||
getBoardJSON = {
|
||||
call = function(args)
|
||||
local jsc = require "luci.jsonc"
|
||||
return jsc.parse(fs.readfile("/etc/board.json") or "")
|
||||
end
|
||||
},
|
||||
|
||||
offload_support = {
|
||||
getConntrackHelpers = {
|
||||
call = function()
|
||||
local fs = require "nixio.fs"
|
||||
return { offload_support = not not fs.access("/sys/module/xt_FLOWOFFLOAD/refcnt") }
|
||||
local ok, fd = pcall(io.open, "/usr/share/fw3/helpers.conf", "r")
|
||||
local rv = {}
|
||||
|
||||
if ok then
|
||||
local entry
|
||||
|
||||
while true do
|
||||
local line = fd:read("*l")
|
||||
if not line then
|
||||
break
|
||||
end
|
||||
|
||||
if line:match("^%s*config%s") then
|
||||
if entry then
|
||||
rv[#rv+1] = entry
|
||||
end
|
||||
entry = {}
|
||||
else
|
||||
local opt, val = line:match("^%s*option%s+(%S+)%s+(%S.*)$")
|
||||
if opt and val then
|
||||
opt = opt:gsub("^'(.+)'$", "%1"):gsub('^"(.+)"$', "%1")
|
||||
val = val:gsub("^'(.+)'$", "%1"):gsub('^"(.+)"$', "%1")
|
||||
entry[opt] = val
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if entry then
|
||||
rv[#rv+1] = entry
|
||||
end
|
||||
|
||||
fd:close()
|
||||
end
|
||||
|
||||
return { result = rv }
|
||||
end
|
||||
},
|
||||
|
||||
|
||||
conntrack_helpers = {
|
||||
getFeatures = {
|
||||
call = function()
|
||||
local fd = io.open("/usr/share/fw3/helpers.conf", "r")
|
||||
local fs = require "nixio.fs"
|
||||
local rv = {}
|
||||
local ok, fd
|
||||
|
||||
local line, entry
|
||||
while true do
|
||||
line = fd:read("*l")
|
||||
if not line then
|
||||
break
|
||||
end
|
||||
rv.firewall = fs.access("/sbin/fw3")
|
||||
rv.opkg = fs.access("/bin/opkg")
|
||||
rv.offloading = fs.access("/sys/module/xt_FLOWOFFLOAD/refcnt")
|
||||
rv.br2684ctl = fs.access("/usr/sbin/br2684ctl")
|
||||
rv.swconfig = fs.access("/sbin/swconfig")
|
||||
rv.odhcpd = fs.access("/usr/sbin/odhcpd")
|
||||
rv.zram = fs.access("/sys/class/zram-control")
|
||||
rv.sysntpd = fs.readlink("/usr/sbin/ntpd") and true
|
||||
|
||||
if line:match("^%s*config%s") then
|
||||
if entry then
|
||||
rv[#rv+1] = entry
|
||||
end
|
||||
entry = {}
|
||||
else
|
||||
local opt, val = line:match("^%s*option%s+(%S+)%s+(%S.*)$")
|
||||
if opt and val then
|
||||
opt = opt:gsub("^'(.+)'$", "%1"):gsub('^"(.+)"$', "%1")
|
||||
val = val:gsub("^'(.+)'$", "%1"):gsub('^"(.+)"$', "%1")
|
||||
entry[opt] = val
|
||||
end
|
||||
local wifi_features = { "eap", "11n", "11ac", "11r", "11w", "acs", "sae", "owe", "suiteb192" }
|
||||
|
||||
if fs.access("/usr/sbin/hostapd") then
|
||||
rv.hostapd = {}
|
||||
|
||||
local _, feature
|
||||
for _, feature in ipairs(wifi_features) do
|
||||
rv.hostapd[feature] =
|
||||
(os.execute(string.format("/usr/sbin/hostapd -v%s >/dev/null 2>/dev/null", feature)) == 0)
|
||||
end
|
||||
end
|
||||
if entry then
|
||||
rv[#rv+1] = entry
|
||||
|
||||
if fs.access("/usr/sbin/wpa_supplicant") then
|
||||
rv.wpasupplicant = {}
|
||||
|
||||
local _, feature
|
||||
for _, feature in ipairs(wifi_features) do
|
||||
rv.wpasupplicant[feature] =
|
||||
(os.execute(string.format("/usr/sbin/wpa_supplicant -v%s >/dev/null 2>/dev/null", feature)) == 0)
|
||||
end
|
||||
end
|
||||
|
||||
return { helpers = rv }
|
||||
ok, fd = pcall(io.popen, "dnsmasq --version 2>/dev/null")
|
||||
if ok then
|
||||
rv.dnsmasq = {}
|
||||
|
||||
while true do
|
||||
local line = fd:read("*l")
|
||||
if not line then
|
||||
break
|
||||
end
|
||||
|
||||
local opts = line:match("^Compile time options: (.+)$")
|
||||
if opts then
|
||||
local opt
|
||||
for opt in opts:gmatch("%S+") do
|
||||
local no = opt:match("^no%-(%S+)$")
|
||||
rv.dnsmasq[string.lower(no or opt)] = not no
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
fd:close()
|
||||
end
|
||||
|
||||
ok, fd = pcall(io.popen, "ipset --help 2>/dev/null")
|
||||
if ok then
|
||||
rv.ipset = {}
|
||||
|
||||
local sets = false
|
||||
|
||||
while true do
|
||||
local line = fd:read("*l")
|
||||
if not line then
|
||||
break
|
||||
elseif line:match("^Supported set types:") then
|
||||
sets = true
|
||||
elseif sets then
|
||||
local set, ver = line:match("^%s+(%S+)%s+(%d+)")
|
||||
if set and not rv.ipset[set] then
|
||||
rv.ipset[set] = tonumber(ver)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
fd:close()
|
||||
end
|
||||
|
||||
return rv
|
||||
end
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,54 @@
|
|||
{
|
||||
"user": "nobody",
|
||||
"access": {
|
||||
"system": {
|
||||
"methods": [ "board", "info" ]
|
||||
"unauthenticated": {
|
||||
"description": "Allow system feature probing",
|
||||
"read": {
|
||||
"ubus": {
|
||||
"luci": [ "getFeatures" ]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"uci-access": {
|
||||
"description": "Grant uci write access to all configurations",
|
||||
"read": {
|
||||
"uci": [ "*" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "*" ]
|
||||
}
|
||||
},
|
||||
"luci-access": {
|
||||
"description": "Grant access to basic LuCI procedures",
|
||||
"read": {
|
||||
"ubus": {
|
||||
"iwinfo": [ "info" ],
|
||||
"luci": [ "getBoardJSON", "getDUIDHints", "getHostHints", "getIfaddrs", "getInitList", "getLocaltime", "getTimezones", "getDHCPLeases", "getLEDs", "getNetworkDevices", "getUSBDevices" ],
|
||||
"network.device": [ "status" ],
|
||||
"network.interface": [ "dump" ],
|
||||
"network.wireless": [ "status" ],
|
||||
"network": [ "get_proto_handlers" ],
|
||||
"uci": [ "changes", "get" ]
|
||||
},
|
||||
"uci": [ "*" ]
|
||||
},
|
||||
"write": {
|
||||
"ubus": {
|
||||
"luci": [ "setInitAction", "setLocaltime" ],
|
||||
"uci": [ "add", "apply", "confirm", "delete", "order", "set" ]
|
||||
},
|
||||
"uci": [ "*" ]
|
||||
}
|
||||
},
|
||||
"luci-app-firewall": {
|
||||
"description": "Grant access to firewall procedures",
|
||||
"read": {
|
||||
"ubus": {
|
||||
"luci": [ "getConntrackHelpers" ]
|
||||
},
|
||||
"uci": [ "firewall" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "firewall" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue