Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make the interface visible in luci admin console 0d33510 #37

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ipset-lists/files/usr/lib/lua/luci/controller/gfwlist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ module("luci.controller.gfwlist", package.seeall)

function index()
local page
page = entry({"admin", "services", "gfwlist"}, cbi("gfwlist"), _("Domain Lists"))
page = entry({"admin", "services", "gfwlist"}, form("gfwlist"), _("Domain Lists"))
page.dependent = true
end
622 changes: 622 additions & 0 deletions luci-app-udp2raw/LICENSE

Large diffs are not rendered by default.

73 changes: 73 additions & 0 deletions luci-app-udp2raw/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#
# Copyright (C) 2016-2017 Jian Chang <[email protected]>
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-udp2raw
PKG_VERSION:=1.0.0
PKG_RELEASE:=4

PKG_LICENSE:=GPLv3
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=Jian Chang <[email protected]>

include $(INCLUDE_DIR)/package.mk

define Package/$(PKG_NAME)
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=3. Applications
TITLE:=LuCI Support for udp2raw-tunnel
PKGARCH:=all
# DEPENDS:=+udp2raw-tunnel
endef

define Package/$(PKG_NAME)/description
LuCI Support for udp2raw-tunnel.
endef

define Build/Prepare
$(foreach po,$(wildcard ${CURDIR}/files/luci/i18n/*.po), \
po2lmo $(po) $(PKG_BUILD_DIR)/$(patsubst %.po,%.lmo,$(notdir $(po)));)
endef

define Build/Configure
endef

define Build/Compile
endef

define Package/$(PKG_NAME)/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
( . /etc/uci-defaults/luci-udp2raw ) && rm -f /etc/uci-defaults/luci-udp2raw
fi
exit 0
endef

define Package/$(PKG_NAME)/conffiles
/etc/config/udp2raw
endef

define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
$(INSTALL_DATA) $(PKG_BUILD_DIR)/udp2raw.*.lmo $(1)/usr/lib/lua/luci/i18n/
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
$(INSTALL_DATA) ./files/luci/controller/*.lua $(1)/usr/lib/lua/luci/controller/
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/udp2raw
$(INSTALL_DATA) ./files/luci/model/cbi/udp2raw/*.lua $(1)/usr/lib/lua/luci/model/cbi/udp2raw/
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/udp2raw
$(INSTALL_DATA) ./files/luci/view/udp2raw/*.htm $(1)/usr/lib/lua/luci/view/udp2raw/
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/root/etc/config/udp2raw $(1)/etc/config/udp2raw
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/root/etc/init.d/udp2raw $(1)/etc/init.d/udp2raw
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/root/etc/uci-defaults/luci-udp2raw $(1)/etc/uci-defaults/luci-udp2raw
endef

$(eval $(call BuildPackage,$(PKG_NAME)))
10 changes: 10 additions & 0 deletions luci-app-udp2raw/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# luci-app-udp2raw
适用于 OpenWRT/LEDE 的 [udp2raw-tunnel](https://github.com/wangyu-/udp2raw-tunnel) LuCI 控制界面

更多内容,请看[wiki](https://github.com/sensec/luci-app-udp2raw/wiki)

![](images/luci-app-udp2raw1.jpg)

![](images/luci-app-udp2raw2.jpg)

![](images/luci-app-udp2raw3.jpg)
30 changes: 30 additions & 0 deletions luci-app-udp2raw/files/luci/controller/udp2raw.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module("luci.controller.udp2raw", package.seeall)

function index()
if not nixio.fs.access("/etc/config/udp2raw") then
return
end

entry({"admin", "services", "udp2raw"},
firstchild(), _("udp2raw-tunnel")).dependent = false

entry({"admin", "services", "udp2raw", "general"},
cbi("udp2raw/general"), _("Settings"), 1)

entry({"admin", "services", "udp2raw", "servers"},
arcombine(cbi("udp2raw/servers"), cbi("udp2raw/servers-details")),
_("Servers Manage"), 2).leaf = true

entry({"admin", "services", "udp2raw", "status"}, call("action_status"))
end

local function is_running(name)
return luci.sys.call("pidof %s >/dev/null" %{name}) == 0
end

function action_status()
luci.http.prepare_content("application/json")
luci.http.write_json({
running = is_running("udp2raw")
})
end
Binary file not shown.
120 changes: 120 additions & 0 deletions luci-app-udp2raw/files/luci/i18n/udp2raw.zh-cn.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8\n"

msgid "udp2raw-tunnel"
msgstr "udp2raw 隧道"

msgid "Settings"
msgstr "设置"

msgid "Servers Manage"
msgstr "服务器管理"

msgid "Running Status"
msgstr "运行状态"

msgid "Binary Version"
msgstr "文件版本"

msgid "Build Time"
msgstr "编译时间"

msgid "Invalid Binary File."
msgstr "可执行文件无效。"

msgid "RUNNING"
msgstr "运行中"

msgid "NOT RUNNING"
msgstr "未运行"

msgid "General Settings"
msgstr "基本设置"

msgid "Server"
msgstr "服务器"

msgid "Disable"
msgstr "停用"

msgid "Run Daemon as User"
msgstr "以该用户启动"

msgid "Alias"
msgstr "别名"

msgid "None"
msgstr "无"

msgid "Server Address"
msgstr "服务器地址"

msgid "Listen Address"
msgstr "监听地址"

msgid "Edit Server"
msgstr "编辑服务器"

msgid "Alias(optional)"
msgstr "别名(可选)"

msgid "Server Port"
msgstr "服务器端口"

msgid "Local Listen Host"
msgstr "本地监听地址"

msgid "Local Listen Port"
msgstr "本地监听端口"

msgid "Raw Mode"
msgstr "Raw 方式"

msgid "Password"
msgstr "密码"

msgid "Cipher Mode"
msgstr "加密方式"

msgid "Auth Mode"
msgstr "验证方式"

msgid "Auto Rule"
msgstr "自动规则"

msgid "Auto add (and delete) iptables rule."
msgstr "自动添加/删除 iptables 规则。"

msgid "Keep Rule"
msgstr "保持规则"

msgid "Monitor iptables and auto re-add if necessary."
msgstr "定期检查 iptables 并在必要时重新添加规则。"

msgid "seq Mode"
msgstr "seq 模式"

msgid "seq increase mode for faketcp."
msgstr "用于 faketcp 的 seq 增加方式。"

msgid "Lower Level"
msgstr ""

msgid "Send packets at OSI level 2, format: \"eth0#00:11:22:33:44:55\", or \"auto\"."
msgstr "在 OSI 模型第二层发送数据包,格式:\"eth0#00:11:22:33:44:55\",或 \"auto\"。"

msgid "Source-IP"
msgstr "源IP"

msgid "Force source-ip for Raw Socket."
msgstr "在原始数据包中强制指定源IP。"

msgid "Source-Port"
msgstr "源端口"

msgid "Force source-port for Raw Socket, TCP/UDP only."
msgstr "在原始数据包中强制指定源端口,仅用于 TCP/UDP。"

msgid "Log Level"
msgstr "日志级别"

39 changes: 39 additions & 0 deletions luci-app-udp2raw/files/luci/model/cbi/udp2raw/general.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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. install udp2raw-tunnel package, or copy binary to /usr/bin/udp2raw manually. </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(DynamicList, "server", translate("Server"))
o.template = "udp2raw/dynamiclist"
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
92 changes: 92 additions & 0 deletions luci-app-udp2raw/files/luci/model/cbi/udp2raw/servers-details.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
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.default = "1"

o = s:option(Flag, "keep_rule", translate("Keep Rule"), translate("Monitor iptables and auto re-add if necessary."))
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
Loading