2017-12-29 05:41:04 -06:00
|
|
|
local m, s, o
|
|
|
|
local uci = luci.model.uci.cursor()
|
|
|
|
local servers = {}
|
|
|
|
|
|
|
|
local function has_bin(name)
|
|
|
|
return luci.sys.call("command -v %s >/dev/null" %{name}) == 0
|
|
|
|
end
|
|
|
|
|
|
|
|
if not has_bin("udp2raw") then
|
|
|
|
return Map("udp2raw", "%s - %s" %{translate("udp2raw-tunnel"),
|
2018-01-14 06:46:30 -06:00
|
|
|
translate("Settings")}, '<b style="color:red">udp2raw-tunnel binary file(/usr/bin/udp2raw) not found. </b>')
|
2017-12-29 05:41:04 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
uci:foreach("udp2raw", "servers", function(s)
|
|
|
|
if s.server_addr and s.server_port then
|
|
|
|
servers[#servers+1] = {name = s[".name"], alias = s.alias or "%s:%s" %{s.server_addr, s.server_port}}
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
m = Map("udp2raw", "%s - %s" %{translate("udp2raw-tunnel"), translate("Settings")})
|
2018-01-11 17:38:01 -06:00
|
|
|
m:append(Template("udp2raw/status"))
|
2017-12-29 05:41:04 -06:00
|
|
|
|
|
|
|
s = m:section(NamedSection, "general", "general", translate("General Settings"))
|
|
|
|
s.anonymous = true
|
|
|
|
s.addremove = false
|
|
|
|
|
2018-01-11 17:38:01 -06:00
|
|
|
o = s:option(DynamicList, "server", translate("Server"))
|
|
|
|
o.template = "udp2raw/dynamiclist"
|
2017-12-29 05:41:04 -06:00
|
|
|
o:value("nil", translate("Disable"))
|
|
|
|
for _, s in ipairs(servers) do o:value(s.name, s.alias) end
|
|
|
|
o.default = "nil"
|
|
|
|
o.rmempty = false
|
|
|
|
|
|
|
|
o = s:option(ListValue, "daemon_user", translate("Run Daemon as User"))
|
|
|
|
for u in luci.util.execi("cat /etc/passwd | cut -d ':' -f1") do o:value(u) end
|
|
|
|
o.default = "root"
|
|
|
|
o.rmempty = false
|
|
|
|
|
|
|
|
return m
|