From 157bf74506c88af79790bbd9da53754b01694648 Mon Sep 17 00:00:00 2001 From: lwz322 Date: Wed, 18 Mar 2020 12:56:00 +0800 Subject: [PATCH] support option: tls_only & extra setting (#3859) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tls_only for frps v0.32.0+ extra setting list for possible new options update translation replace PKG_MAINTAINER‘s name with github ID --- package/lean/luci-app-frps/Makefile | 6 +++--- .../lean/luci-app-frps/luasrc/controller/frps.lua | 2 +- .../luci-app-frps/luasrc/model/cbi/frps/common.lua | 2 +- .../luci-app-frps/luasrc/model/cbi/frps/server.lua | 13 ++++++++++++- .../luasrc/view/frps/status_header.htm | 2 +- package/lean/luci-app-frps/po/zh-cn/frps.po | 12 ++++++++++++ package/lean/luci-app-frps/root/etc/init.d/frps | 12 ++++++++++-- 7 files changed, 40 insertions(+), 9 deletions(-) diff --git a/package/lean/luci-app-frps/Makefile b/package/lean/luci-app-frps/Makefile index 3637e79ee..848b49085 100644 --- a/package/lean/luci-app-frps/Makefile +++ b/package/lean/luci-app-frps/Makefile @@ -1,18 +1,18 @@ # -# Copyright 2020 Weizheng Li +# Copyright 2020 lwz322 # Licensed to the public under the MIT License. # include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-frps -PKG_VERSION:=0.0.1 +PKG_VERSION:=0.0.2 PKG_RELEASE:=1 PKG_LICENSE:=MIT PKG_LICENSE_FILES:=LICENSE -PKG_MAINTAINER:=Weizheng Li +PKG_MAINTAINER:=lwz322 LUCI_TITLE:=LuCI support for Frps LUCI_DEPENDS:=+wget +frps diff --git a/package/lean/luci-app-frps/luasrc/controller/frps.lua b/package/lean/luci-app-frps/luasrc/controller/frps.lua index 94916c0bd..e9c15cd77 100644 --- a/package/lean/luci-app-frps/luasrc/controller/frps.lua +++ b/package/lean/luci-app-frps/luasrc/controller/frps.lua @@ -1,4 +1,4 @@ --- Copyright 2020 Weizheng Li +-- Copyright 2020 lwz322 -- Licensed to the public under the MIT License. local http = require "luci.http" diff --git a/package/lean/luci-app-frps/luasrc/model/cbi/frps/common.lua b/package/lean/luci-app-frps/luasrc/model/cbi/frps/common.lua index ba42f3da6..c5c0d0256 100644 --- a/package/lean/luci-app-frps/luasrc/model/cbi/frps/common.lua +++ b/package/lean/luci-app-frps/luasrc/model/cbi/frps/common.lua @@ -1,4 +1,4 @@ --- Copyright 2020 Weizheng Li +-- Copyright 2020 lwz322 -- Licensed to the public under the MIT License. local uci = require "luci.model.uci".cursor() diff --git a/package/lean/luci-app-frps/luasrc/model/cbi/frps/server.lua b/package/lean/luci-app-frps/luasrc/model/cbi/frps/server.lua index 44d4b38ca..4a721da67 100644 --- a/package/lean/luci-app-frps/luasrc/model/cbi/frps/server.lua +++ b/package/lean/luci-app-frps/luasrc/model/cbi/frps/server.lua @@ -1,4 +1,4 @@ --- Copyright 2020 Weizheng Li +-- Copyright 2020 lwz322 -- Licensed to the public under the MIT License. local dsp = require "luci.dispatcher" @@ -24,6 +24,13 @@ o.disabled = "false" o.defalut = o.enabled o.rmempty = false +o = s:option(Flag, "tls_only", translate("Enforce frps only accept TLS connection") + translatef("Requirements: frpc v0.25.0+, frps v0.32.0+")) +o.enabled = "true" +o.disabled = "false" +o.default = o.disabled +o.rmempty = false + o = s:option(Value, "bind_udp_port", translate("UDP bind port"), translatef("Optional: udp port to help make udp hole to penetrate nat")) o.datatype = "port" @@ -40,4 +47,8 @@ o = s:option(Value, "vhost_https_port", translate("vhost https port"), translatef("Optional: Note: http port and https port can be same with bind_port")) o.datatype = "port" +o = s:option(DynamicList, "extra_setting", translate("Extra Settings"), + translatef("List of extra settings will be added to config file. Format: option=value, eg. detailed_errors_to_client=false.(NO SPACE!)")) +o.placeholder = "option=value" + return m \ No newline at end of file diff --git a/package/lean/luci-app-frps/luasrc/view/frps/status_header.htm b/package/lean/luci-app-frps/luasrc/view/frps/status_header.htm index 7df8bf9e6..a5bd6a0b2 100644 --- a/package/lean/luci-app-frps/luasrc/view/frps/status_header.htm +++ b/package/lean/luci-app-frps/luasrc/view/frps/status_header.htm @@ -1,5 +1,5 @@ <%# - Copyright 2020 Weizheng Li + Copyright 2020 lwz322 Licensed to the public under the MIT License. -%> diff --git a/package/lean/luci-app-frps/po/zh-cn/frps.po b/package/lean/luci-app-frps/po/zh-cn/frps.po index 8f73ccf5d..3868bea37 100644 --- a/package/lean/luci-app-frps/po/zh-cn/frps.po +++ b/package/lean/luci-app-frps/po/zh-cn/frps.po @@ -172,6 +172,12 @@ msgstr "子域名" msgid "TCP mux" msgstr "TCP 复用" +#: luasrc/model/cbi/frps/server.lua:27 +msgid "Enforce frps only accept TLS connection" +msgstr "强制frps只接受TLS连接" +msgid "Requirements: frpc v0.25.0+, frps v0.32.0+" +msgstr "要求:frpc版本0.25.0+, frps版本0.32.0+" + #: luasrc/model/cbi/frps/server.lua:18 msgid "Token" msgstr "令牌" @@ -231,3 +237,9 @@ msgstr "虚拟主机http绑定端口" #: luasrc/model/cbi/frps/server.lua:39 msgid "vhost https port" msgstr "虚拟主机https绑定端口" + +#: luasrc/model/cbi/frps/server.lua:50 +msgid "Extra Settings" +msgstr "额外设置" +msgid "List of extra settings will be added to config file. Format: option=value, eg. detailed_errors_to_client=false.(NO SPACE!)" +msgstr "额外设置列表将会被添加到config文件中。 格式:option=value,如:detailed_errors_to_client=false.(不含空格!)" \ No newline at end of file diff --git a/package/lean/luci-app-frps/root/etc/init.d/frps b/package/lean/luci-app-frps/root/etc/init.d/frps index b524c5e0b..f9876d265 100644 --- a/package/lean/luci-app-frps/root/etc/init.d/frps +++ b/package/lean/luci-app-frps/root/etc/init.d/frps @@ -1,6 +1,6 @@ #!/bin/sh /etc/rc.common # -# Copyright 2020 Weizheng Li +# Copyright 2020 lwz322 # Licensed to the public under the MIT License. # @@ -71,6 +71,7 @@ frps_scetion_validate() { 'bind_port:port' \ 'token:string' \ 'tcp_mux:or("true", "false"):true' \ + 'tls_only:or("true", "false"):false' \ 'bind_udp_port:port' \ 'kcp_bind_port:port' \ 'vhost_http_port:port' \ @@ -98,7 +99,7 @@ create_config_file() { echo "[common]" > "$tmp_file" append_options "$tmp_file" \ - "bind_port" "token" "tcp_mux" "bind_udp_port" "kcp_bind_port" "vhost_http_port" "vhost_https_port" + "bind_port" "token" "tcp_mux" "tls_only" "bind_udp_port" "kcp_bind_port" "vhost_http_port" "vhost_https_port" if [ "x$enable_logging" = "x1" ] ; then @@ -130,6 +131,13 @@ create_config_file() { append_options "$tmp_file" \ "max_pool_count" "max_ports_per_client" "subdomain_host" "dashboard_addr" "dashboard_port" "dashboard_user" "dashboard_pwd" + extra_setting=$(uci get frps.main.extra_setting 2>/dev/null) + if [ -n "$extra_setting" ] ; then + for o in $extra_setting ;do + echo "$o" >> "$tmp_file" + done + fi + sed '/^$/d' "$tmp_file" >"$config_file" if [ "$?" = "0" ] ; then