From d871216a7ce1f1a6b8efae99870361dfd74b7ff8 Mon Sep 17 00:00:00 2001 From: Eason Date: Mon, 7 Jun 2021 23:14:22 +0800 Subject: [PATCH] luci-app-frpc: Support TLS Connection and Admin Web (#6945) --- package/lean/luci-app-frpc/Makefile | 2 +- .../luasrc/model/cbi/frp/frp.lua | 23 +++++++++++++++++++ package/lean/luci-app-frpc/po/zh-cn/frp.po | 21 +++++++++++++++++ .../lean/luci-app-frpc/root/etc/init.d/frp | 13 +++++++++-- 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/package/lean/luci-app-frpc/Makefile b/package/lean/luci-app-frpc/Makefile index 6804fdcf3..fb66488f4 100644 --- a/package/lean/luci-app-frpc/Makefile +++ b/package/lean/luci-app-frpc/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk LUCI_TITLE:=LuCI for FRPC LUCI_DEPENDS:=+wget +frpc LUCI_PKGARCH:=all -PKG_VERSION:=1.3 +PKG_VERSION:=1.4 PKG_RELEASE:=1 include $(TOPDIR)/feeds/luci/luci.mk diff --git a/package/lean/luci-app-frpc/luasrc/model/cbi/frp/frp.lua b/package/lean/luci-app-frpc/luasrc/model/cbi/frp/frp.lua index 34fc151fb..38b6753a4 100644 --- a/package/lean/luci-app-frpc/luasrc/model/cbi/frp/frp.lua +++ b/package/lean/luci-app-frpc/luasrc/model/cbi/frp/frp.lua @@ -42,6 +42,9 @@ e.rmempty=false e=t:taboption("other",Flag, "tcp_mux", translate("TCP Stream Multiplexing"), translate("Default is Ture. This feature in frps.ini and frpc.ini must be same.")) e.default = "1" e.rmempty=false +e=t:taboption("other",Flag, "tls_enable", translate("Use TLS Connection"), translate("if tls_enable is true, frpc will connect frps by tls.")) +e.default = "0" +e.rmempty=false e=t:taboption("other",ListValue, "protocol", translate("Protocol Type"),translate("Frp support kcp protocol since v0.12.0")) e.default = "tcp" e:value("tcp",translate("TCP Protocol")) @@ -78,6 +81,26 @@ e.datatype = "uinteger" e.default = "3" e.rmempty=false e.optional=false +e=t:taboption("other",Flag, "admin_enable", translate("Enable Web API"), translate("set admin address for control frpc's action by http api such as reload.")) +e.default = "0" +e.rmempty=false +e=t:taboption("other",Value, "admin_port", translate("Admin Web Port")) +e.datatype = "port" +e.default=7400 +e.rmempty=false +e:depends("admin_enable",1) +e=t:taboption("other",Value, "admin_user", translate("Admin Web UserName")) +e.optional=false +e.default = "admin" +e.rmempty=false +e:depends("admin_enable",1) +e=t:taboption("other",Value, "admin_pwd", translate("Admin Web PassWord")) +e.optional=false +e.default = "admin" +e.password=true +e.rmempty=false +e:depends("admin_enable",1) + e=t:taboption("log",TextValue,"log") e.rows=26 e.wrap="off" diff --git a/package/lean/luci-app-frpc/po/zh-cn/frp.po b/package/lean/luci-app-frpc/po/zh-cn/frp.po index 72698cb3f..a0dadb602 100644 --- a/package/lean/luci-app-frpc/po/zh-cn/frp.po +++ b/package/lean/luci-app-frpc/po/zh-cn/frp.po @@ -68,6 +68,12 @@ msgstr "第一次登录失败就退出程序,否则将持续尝试登陆 Frp msgid "Default is Ture. This feature in frps.ini and frpc.ini must be same." msgstr "该功能默认启用,该配置项在服务端和客户端必须保持一致。" +msgid "Use TLS Connection" +msgstr "TLS连接" + +msgid "if tls_enable is true, frpc will connect frps by tls." +msgstr "使用TLS协议与服务器连接(若连接服务器异常可以尝试开启)" + msgid "Protocol Type" msgstr "协议类型" @@ -128,6 +134,21 @@ msgstr "错误" msgid "Log Keepd Max Days" msgstr "日志记录天数" +msgid "Enable Web API" +msgstr "开启网页管理" + +msgid "set admin address for control frpc's action by http api such as reload." +msgstr "可通过http查看客户端状态以及通过API控制" + +msgid "Admin Web Port" +msgstr "管理员端口号" + +msgid "Admin Web UserName" +msgstr "管理员用户名" + +msgid "Admin Web PassWord" +msgstr "管理员密码" + msgid "Services List" msgstr "服务列表" diff --git a/package/lean/luci-app-frpc/root/etc/init.d/frp b/package/lean/luci-app-frpc/root/etc/init.d/frp index 21a2e55d9..8790dabb6 100755 --- a/package/lean/luci-app-frpc/root/etc/init.d/frp +++ b/package/lean/luci-app-frpc/root/etc/init.d/frp @@ -171,8 +171,8 @@ boot() { start() { config_load "frp" - local enabled server_addr server_port time privilege_token user tcp_mux enable_cpool - local pool_count log_level log_max_days login_fail_exit http_proxy protocol + local enabled server_addr server_port time privilege_token user tcp_mux enable_cpool tls_enable + local pool_count log_level log_max_days login_fail_exit http_proxy protocol admin_port admin_user admin_pwd config_get_bool enabled common enabled 1 @@ -189,6 +189,10 @@ start() { config_get http_proxy common http_proxy config_get protocol common protocol config_get time common time + config_get admin_port common admin_port + config_get admin_user common admin_user + config_get admin_pwd common admin_pwd + mkdir -p /var/etc/frp [ ! -f "$LOGFILE" ] && touch $LOGFILE @@ -209,9 +213,14 @@ start() { echo "log_file=$LOGFILE" >>$tmpconf [ -n "$http_proxy" ] && echo "http_proxy=$http_proxy" >>$tmpconf [ -n "$pool_count" ] && echo "pool_count=$pool_count" >>$tmpconf + [ -n "$admin_port" ] && echo "admin_addr=0.0.0.0" >>$tmpconf && echo "admin_port=$admin_port" >>$tmpconf + [ -n "$admin_user" ] && echo "admin_user=$admin_user" >>$tmpconf + [ -n "$admin_pwd" ] && echo "admin_pwd=$admin_pwd" >>$tmpconf + config_load "frp" frp_write_bool tcp_mux common 1 + frp_write_bool tls_enable common 0 frp_write_bool login_fail_exit common 1 config_foreach conf_proxy_add proxy "$tmpconf"