mirror of
https://github.com/wangyu-/udp2raw.git
synced 2025-10-03 20:35:35 +08:00
add luci-app-udp2raw and udp2raw-openwrt-makefile
This commit is contained in:
38
third-party/luci-app-udp2raw/files/luci/model/cbi/udp2raw/general.lua
vendored
Normal file
38
third-party/luci-app-udp2raw/files/luci/model/cbi/udp2raw/general.lua
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
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"),
|
||||
translate("Settings")}, '<b style="color:red">udp2raw-tunnel binary file not found.</b>')
|
||||
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")})
|
||||
m:append(Template("udp2raw_status"))
|
||||
|
||||
s = m:section(NamedSection, "general", "general", translate("General Settings"))
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
|
||||
o = s:option(ListValue, "server", translate("Server"))
|
||||
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
|
96
third-party/luci-app-udp2raw/files/luci/model/cbi/udp2raw/servers-details.lua
vendored
Normal file
96
third-party/luci-app-udp2raw/files/luci/model/cbi/udp2raw/servers-details.lua
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
local m, s, o
|
||||
local sid = arg[1]
|
||||
|
||||
local raw_modes = {
|
||||
"faketcp",
|
||||
"udp",
|
||||
"icmp",
|
||||
}
|
||||
|
||||
local cipher_modes = {
|
||||
"aes128cbc",
|
||||
"xor",
|
||||
"none",
|
||||
}
|
||||
|
||||
local auth_modes = {
|
||||
"md5",
|
||||
"crc32",
|
||||
"simple",
|
||||
"none",
|
||||
}
|
||||
|
||||
m = Map("udp2raw", "%s - %s" %{translate("udp2raw-tunnel"), translate("Edit Server")})
|
||||
m.redirect = luci.dispatcher.build_url("admin/services/udp2raw/servers")
|
||||
m.sid = sid
|
||||
|
||||
if m.uci:get("udp2raw", sid) ~= "servers" then
|
||||
luci.http.redirect(m.redirect)
|
||||
return
|
||||
end
|
||||
|
||||
s = m:section(NamedSection, sid, "servers")
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
|
||||
o = s:option(Value, "alias", translate("Alias(optional)"))
|
||||
|
||||
o = s:option(Value, "server_addr", translate("Server"))
|
||||
o.datatype = "host"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "server_port", translate("Server Port"))
|
||||
o.datatype = "port"
|
||||
o.placeholder = "8080"
|
||||
|
||||
o = s:option(Value, "listen_addr", translate("Local Listen Host"))
|
||||
o.datatype = "ipaddr"
|
||||
o.placeholder = "127.0.0.1"
|
||||
|
||||
o = s:option(Value, "listen_port", translate("Local Listen Port"))
|
||||
o.datatype = "port"
|
||||
o.placeholder = "2080"
|
||||
|
||||
o = s:option(ListValue, "raw_mode", translate("Raw Mode"))
|
||||
for _, v in ipairs(raw_modes) do o:value(v, v:lower()) end
|
||||
o.default = "faketcp"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "key", translate("Password"))
|
||||
o.password = true
|
||||
|
||||
o = s:option(ListValue, "cipher_mode", translate("Cipher Mode"))
|
||||
for _, v in ipairs(cipher_modes) do o:value(v, v:lower()) end
|
||||
o.default = "aes128cbc"
|
||||
|
||||
o = s:option(ListValue, "auth_mode", translate("Auth Mode"))
|
||||
for _, v in ipairs(auth_modes) do o:value(v, v:lower()) end
|
||||
o.default = "md5"
|
||||
|
||||
o = s:option(Flag, "auto_rule", translate("Auto Rule"), translate("Auto add (and delete) iptables rule."))
|
||||
o.enabled = "1"
|
||||
o.disabled = "0"
|
||||
o.default = "1"
|
||||
|
||||
o = s:option(Flag, "keep_rule", translate("Keep Rule"), translate("Monitor iptables and auto re-add if necessary."))
|
||||
o.enabled = "1"
|
||||
o.disabled = "0"
|
||||
o:depends("auto_rule", "1")
|
||||
|
||||
o = s:option(Value, "seq_mode", translate("seq Mode"), translate("seq increase mode for faketcp."))
|
||||
o.datatype = "range(0,4)"
|
||||
o.placeholder = "3"
|
||||
|
||||
o = s:option(Value, "lower_level", translate("Lower Level"), translate("Send packets at OSI level 2, format: \"eth0#00:11:22:33:44:55\", or \"auto\"."))
|
||||
|
||||
o = s:option(Value, "source_ip", translate("Source-IP"), translate("Force source-ip for Raw Socket."))
|
||||
o.datatype = "ipaddr"
|
||||
|
||||
o = s:option(Value, "source_port", translate("Source-Port"), translate("Force source-port for Raw Socket, TCP/UDP only."))
|
||||
o.datatype = "port"
|
||||
|
||||
o = s:option(Value, "log_level", translate("Log Level"))
|
||||
o.datatype = "range(0,6)"
|
||||
o.placeholder = "4"
|
||||
|
||||
return m
|
56
third-party/luci-app-udp2raw/files/luci/model/cbi/udp2raw/servers.lua
vendored
Normal file
56
third-party/luci-app-udp2raw/files/luci/model/cbi/udp2raw/servers.lua
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
local m, s, o
|
||||
|
||||
m = Map("udp2raw", "%s - %s" %{translate("udp2raw-tunnel"), translate("Servers Manage")})
|
||||
|
||||
s = m:section(TypedSection, "servers")
|
||||
s.anonymous = true
|
||||
s.addremove = true
|
||||
s.sortable = true
|
||||
s.template = "cbi/tblsection"
|
||||
s.extedit = luci.dispatcher.build_url("admin/services/udp2raw/servers/%s")
|
||||
function s.create(...)
|
||||
local sid = TypedSection.create(...)
|
||||
if sid then
|
||||
luci.http.redirect(s.extedit % sid)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "alias", translate("Alias"))
|
||||
function o.cfgvalue(...)
|
||||
return Value.cfgvalue(...) or translate("None")
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "_server_address", translate("Server Address"))
|
||||
function o.cfgvalue(self, section)
|
||||
local server_addr = m.uci:get("udp2raw", section, "server_addr") or "?"
|
||||
local server_port = m.uci:get("udp2raw", section, "server_port") or "8080"
|
||||
return "%s:%s" %{server_addr, server_port}
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "_listen_address", translate("Listen Address"))
|
||||
function o.cfgvalue(self, section)
|
||||
local listen_addr = m.uci:get("udp2raw", section, "listen_addr") or "127.0.0.1"
|
||||
local listen_port = m.uci:get("udp2raw", section, "listen_port") or "2080"
|
||||
return "%s:%s" %{listen_addr, listen_port}
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "raw_mode", translate("Raw Mode"))
|
||||
function o.cfgvalue(...)
|
||||
local v = Value.cfgvalue(...)
|
||||
return v and v:lower() or "faketcp"
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "cipher_mode", translate("Cipher Mode"))
|
||||
function o.cfgvalue(...)
|
||||
local v = Value.cfgvalue(...)
|
||||
return v and v:lower() or "aes128cbc"
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "auth_mode", translate("Auth Mode"))
|
||||
function o.cfgvalue(...)
|
||||
local v = Value.cfgvalue(...)
|
||||
return v and v:lower() or "md5"
|
||||
end
|
||||
|
||||
return m
|
Reference in New Issue
Block a user