frp: remove duplicate packages

This commit is contained in:
CN_SZTL 2020-03-16 04:23:05 +08:00
parent 1c251d145d
commit b872355455
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
20 changed files with 0 additions and 1773 deletions

View File

@ -1,23 +0,0 @@
#
# Copyright 2020 Weizheng Li <lwz322@qq.com>
# Licensed to the public under the MIT License.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-frpserver
PKG_VERSION:=0.0.1
PKG_RELEASE:=1
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=Weizheng Li <lwz322@qq.com>
LUCI_TITLE:=LuCI support for Frps
LUCI_PKGARCH:=all
LUCI_DEPENDS:=+openwrt-frps
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -1,43 +0,0 @@
-- Copyright 2020 Weizheng Li <lwz322@qq.com>
-- Licensed to the public under the MIT License.
local http = require "luci.http"
local uci = require "luci.model.uci".cursor()
local sys = require "luci.sys"
module("luci.controller.frps", package.seeall)
function index()
if not nixio.fs.access("/etc/config/frps") then
return
end
entry({"admin", "services", "frps"},
firstchild(), _("Frps")).dependent = false
entry({"admin", "services", "frps", "common"},
cbi("frps/common"), _("Settings"), 1)
entry({"admin", "services", "frps", "server"},
cbi("frps/server"), _("Server"), 2).leaf = true
entry({"admin", "services", "frps", "status"}, call("action_status"))
end
function action_status()
local running = false
local client = uci:get("frps", "main", "client_file")
if client and client ~= "" then
local file_name = client:match(".*/([^/]+)$") or ""
if file_name ~= "" then
running = sys.call("pidof %s >/dev/null" % file_name) == 0
end
end
http.prepare_content("application/json")
http.write_json({
running = running
})
end

View File

@ -1,110 +0,0 @@
-- Copyright 2020 Weizheng Li <lwz322@qq.com>
-- Licensed to the public under the MIT License.
local uci = require "luci.model.uci".cursor()
local util = require "luci.util"
local fs = require "nixio.fs"
local sys = require "luci.sys"
local m, s, o
local server_table = { }
local function frps_version()
local file = uci:get("frps", "main", "client_file")
if not file or file == "" or not fs.stat(file) then
return "<em style=\"color: red;\">%s</em>" % translate("Invalid client file")
end
if not fs.access(file, "rwx", "rx", "rx") then
fs.chmod(file, 755)
end
local version = util.trim(sys.exec("%s -v 2>/dev/null" % file))
if version == "" then
return "<em style=\"color: red;\">%s</em>" % translate("Can't get client version")
end
return translatef("Version: %s", version)
end
m = Map("frps", "%s - %s" % { translate("Frps"), translate("Common Settings") },
"<p>%s</p><p>%s</p>" % {
translate("Frp is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet."),
translatef("For more information, please visit: %s",
"<a href=\"https://github.com/fatedier/frp\" target=\"_blank\">https://github.com/fatedier/frp</a>")
})
m:append(Template("frps/status_header"))
s = m:section(NamedSection, "main", "frps")
s.addremove = false
s.anonymous = true
s:tab("general", translate("General Options"))
s:tab("advanced", translate("Advanced Options"))
s:tab("dashboard", translate("Dashboard Options"))
o = s:taboption("general", Flag, "enabled", translate("Enabled"))
o = s:taboption("general", Value, "client_file", translate("Client file"), frps_version())
o.datatype = "file"
o.rmempty = false
o = s:taboption("general", ListValue, "run_user", translate("Run daemon as user"))
o:value("", translate("-- default --"))
local user
for user in util.execi("cat /etc/passwd | cut -d':' -f1") do
o:value(user)
end
o = s:taboption("general", Flag, "enable_logging", translate("Enable logging"))
o = s:taboption("general", Value, "log_file", translate("Log file"))
o:depends("enable_logging", "1")
o.placeholder = "/var/log/frps.log"
o = s:taboption("general", ListValue, "log_level", translate("Log level"))
o:depends("enable_logging", "1")
o:value("trace", translate("Trace"))
o:value("debug", translate("Debug"))
o:value("info", translate("Info"))
o:value("warn", translate("Warn"))
o:value("error", translate("Error"))
o.default = "warn"
o = s:taboption("general", Value, "log_max_days", translate("Log max days"))
o:depends("enable_logging", "1")
o.datatype = "uinteger"
o.placeholder = '3'
o = s:taboption("general", Value, "disable_log_color", translate("Disable log color"))
o:depends("enable_logging", "1")
o.enabled = "true"
o.disabled = "false"
o = s:taboption("advanced", Value, "max_pool_count", translate("Max pool count"),
translate("pool_count in each proxy will change to max_pool_count if they exceed the maximum value"))
o.datatype = "uinteger"
o = s:taboption("advanced", Value, "max_ports_per_client", translate("Max ports per-client"),
translate("max ports can be used for each client, default value is 0 means no limit"))
o.datatype = "uinteger"
o.defalut = '0'
o.placeholder = '0'
o = s:taboption("advanced", Value, "subdomain_host", translate("Subdomain host"),
translatef("if subdomain_host is not empty, you can set subdomain when type is http or https in frpc's configure file; when subdomain is test, the host used by routing is test.frps.com"))
o.datatype = "host"
o = s:taboption("dashboard", Value, "dashboard_addr", translate("Dashboard addr"), translatef("dashboard addr's default value is same with bind_addr"))
o.datatype = "host"
o = s:taboption("dashboard", Value, "dashboard_port", translate("Dashboard port"), translatef("dashboard is available only if dashboard_port is set"))
o.datatype = "port"
o = s:taboption("dashboard", Value, "dashboard_user", translate("Dashboard user"), translatef("dashboard user and passwd for basic auth protect, if not set, both default value is admin"))
o = s:taboption("dashboard", Value, "dashboard_pwd", translate("Dashboard password"))
o.password = true
return m

View File

@ -1,43 +0,0 @@
-- Copyright 2020 Weizheng Li <lwz322@qq.com>
-- Licensed to the public under the MIT License.
local dsp = require "luci.dispatcher"
local m, s, o
m = Map("frps", "%s - %s" % { translate("Frps"), translate("FRPS Server setting") })
s = m:section(NamedSection, "main", "frps")
s.anonymous = true
s.addremove = false
o = s:option(Value, "bind_port", translate("Bind port"))
o.datatype = "port"
o.rmempty = false
o = s:option(Value, "token", translate("Token"))
o.password = true
o = s:option(Flag, "tcp_mux", translate("TCP mux"))
o.enabled = "true"
o.disabled = "false"
o.defalut = o.enabled
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"
o = s:option(Value, "kcp_bind_port", translate("KCP bind port"),
translatef("Optional: udp port used for kcp protocol, it can be same with 'bind port'; if not set, kcp is disabled in frps"))
o.datatype = "port"
o = s:option(Value, "vhost_http_port", translate("vhost http port"),
translatef("Optional: if you want to support virtual host, you must set the http port for listening"))
o.datatype = "port"
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"
return m

View File

@ -1,29 +0,0 @@
<%#
Copyright 2020 Weizheng Li <lwz322@qq.com>
Licensed to the public under the MIT License.
-%>
<%
local dsp = require "luci.dispatcher"
-%>
<fieldset class="cbi-section">
<p id="frps_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>
<script type="text/javascript">//<![CDATA[
XHR.poll(5, '<%=dsp.build_url("admin/services/frps/status")%>', null,
function (x, data) {
if (x.status !== 200 || !data) {
return;
}
var frpsStatusElm = document.getElementById('frps_status');
frpsStatusElm.innerHTML = data.running
? '<%:Running%>'
: '<%:Not Running%>';
}
);
//]]></script>

View File

@ -1,233 +0,0 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
#: luasrc/model/cbi/frps/common.lua:54
msgid "-- default --"
msgstr "-- 默认 --"
#: luasrc/model/cbi/frps/common.lua:44
msgid "Advanced Options"
msgstr "高级选项"
#: luasrc/model/cbi/frps/server.lua:14
msgid "Bind port"
msgstr "绑定端口"
#: luasrc/model/cbi/frps/common.lua:25
msgid "Can't get client version"
msgstr "无法获取到客户端版本"
#: luasrc/model/cbi/frps/common.lua:49
msgid "Client file"
msgstr "客户端文件"
#: luasrc/view/frps/status_header.htm:12
msgid "Collecting data..."
msgstr "正在收集数据..."
#: luasrc/model/cbi/frps/common.lua:30
msgid "Common Settings"
msgstr "通用设置"
#: luasrc/model/cbi/frps/common.lua:45
msgid "Dashboard Options"
msgstr "面板选项"
#: luasrc/model/cbi/frps/common.lua:99
msgid "Dashboard addr"
msgstr "面板绑定地址"
#: luasrc/model/cbi/frps/common.lua:107
msgid "Dashboard password"
msgstr "面板登录密码"
#: luasrc/model/cbi/frps/common.lua:102
msgid "Dashboard port"
msgstr "面板绑定端口"
#: luasrc/model/cbi/frps/common.lua:105
msgid "Dashboard user"
msgstr "面板登录用户名"
#: luasrc/model/cbi/frps/common.lua:69
msgid "Debug"
msgstr "调试"
#: luasrc/model/cbi/frps/common.lua:80
msgid "Disable log color"
msgstr "禁用日志颜色"
#: luasrc/model/cbi/frps/common.lua:60
msgid "Enable logging"
msgstr "启用日志"
#: luasrc/model/cbi/frps/common.lua:47
msgid "Enabled"
msgstr "已启用"
#: luasrc/model/cbi/frps/common.lua:72
msgid "Error"
msgstr "错误"
#: luasrc/model/cbi/frps/server.lua:8
msgid "FRPS Server setting"
msgstr "Frps 服务器设定"
#: luasrc/model/cbi/frps/common.lua:33
msgid "For more information, please visit: %s"
msgstr "获取更多信息,请访问:%s"
#: luasrc/model/cbi/frps/common.lua:32
msgid ""
"Frp is a fast reverse proxy to help you expose a local server behind a NAT "
"or firewall to the internet."
msgstr "Frp 是一个可用于内网穿透的高性能的反向代理应用。"
#: luasrc/controller/frps.lua:16 luasrc/model/cbi/frps/common.lua:30
#: luasrc/model/cbi/frps/server.lua:8
msgid "Frps"
msgstr "Frps"
#: luasrc/model/cbi/frps/common.lua:43
msgid "General Options"
msgstr "常规选项"
#: luasrc/model/cbi/frps/common.lua:70
msgid "Info"
msgstr "信息"
#: luasrc/model/cbi/frps/common.lua:16
msgid "Invalid client file"
msgstr "客户端文件无效"
#: luasrc/model/cbi/frps/server.lua:31
msgid "KCP bind port"
msgstr "KCP绑定端口"
#: luasrc/model/cbi/frps/common.lua:62
msgid "Log file"
msgstr "日志文件"
#: luasrc/model/cbi/frps/common.lua:66
msgid "Log level"
msgstr "日志等级"
#: luasrc/model/cbi/frps/common.lua:75
msgid "Log max days"
msgstr "日志保存天数"
#: luasrc/model/cbi/frps/common.lua:85
msgid "Max pool count"
msgstr "最大连接数"
#: luasrc/model/cbi/frps/common.lua:89
msgid "Max ports per-client"
msgstr "单客户端最大端口映射数"
#: luasrc/view/frps/status_header.htm:26
msgid "Not Running"
msgstr "服务未运行"
#: luasrc/model/cbi/frps/server.lua:40
msgid "Optional: Note: http port and https port can be same with bind_port"
msgstr "可选提示http/https端口可以和绑定端口设定为一致"
#: luasrc/model/cbi/frps/server.lua:36
msgid ""
"Optional: if you want to support virtual host, you must set the http port "
"for listening"
msgstr "可选如果您希望支持虚拟主机则必须设定http端口"
#: luasrc/model/cbi/frps/server.lua:28
msgid "Optional: udp port to help make udp hole to penetrate nat"
msgstr "可选设定UDP端口以帮助UDP协议穿透NAT"
#: luasrc/model/cbi/frps/server.lua:32
msgid ""
"Optional: udp port used for kcp protocol, it can be same with 'bind port'; "
"if not set, kcp is disabled in frps"
msgstr "可选UDP端口用于KCP协议可与绑定端口设定为一致留空以禁用KCP"
#: luasrc/model/cbi/frps/common.lua:53
msgid "Run daemon as user"
msgstr "以用户身份运行"
#: luasrc/view/frps/status_header.htm:25
msgid "Running"
msgstr "服务正在运行"
#: luasrc/controller/frps.lua:22
msgid "Server"
msgstr "服务端"
#: luasrc/controller/frps.lua:19
msgid "Settings"
msgstr "设置"
#: luasrc/model/cbi/frps/common.lua:95
msgid "Subdomain host"
msgstr "子域名"
#: luasrc/model/cbi/frps/server.lua:21
msgid "TCP mux"
msgstr "TCP 复用"
#: luasrc/model/cbi/frps/server.lua:18
msgid "Token"
msgstr "令牌"
#: luasrc/model/cbi/frps/common.lua:68
msgid "Trace"
msgstr "追踪"
#: luasrc/model/cbi/frps/server.lua:27
msgid "UDP bind port"
msgstr "UDP绑定端口"
#: luasrc/model/cbi/frps/common.lua:27
msgid "Version: %s"
msgstr "版本:%s"
#: luasrc/model/cbi/frps/common.lua:71
msgid "Warn"
msgstr "警告"
#: luasrc/model/cbi/frps/common.lua:99
msgid "dashboard addr's default value is same with bind_addr"
msgstr "面板地址默认和绑定地址一致"
#: luasrc/model/cbi/frps/common.lua:102
msgid "dashboard is available only if dashboard_port is set"
msgstr "仅在设定面板绑定端口后才可使用面板功能"
#: luasrc/model/cbi/frps/common.lua:105
msgid ""
"dashboard user and passwd for basic auth protect, if not set, both default "
"value is admin"
msgstr "面板用户名/密码用于基本安全认证;若留空,则用户名/密码均为admin"
#: luasrc/model/cbi/frps/common.lua:96
msgid ""
"if subdomain_host is not empty, you can set subdomain when type is http or "
"https in frpc's configure file; when subdomain is test, the host used by "
"routing is test.frps.com"
msgstr "如果subdomain_host不为空可以在frpc配置文件中设置类型为http(s)的subdomainsubdomain为test路由将使用test.frps.com"
#: luasrc/model/cbi/frps/common.lua:90
msgid ""
"max ports can be used for each client, default value is 0 means no limit"
msgstr "每个客户端最多可映射端口数留空则默认为0不限制"
#: luasrc/model/cbi/frps/common.lua:86
msgid ""
"pool_count in each proxy will change to max_pool_count if they exceed the "
"maximum value"
msgstr "代理连接数(pool_count)超过最大值时将变更为最大连接数(max_pool_count)"
#: luasrc/model/cbi/frps/server.lua:35
msgid "vhost http port"
msgstr "虚拟主机http绑定端口"
#: luasrc/model/cbi/frps/server.lua:39
msgid "vhost https port"
msgstr "虚拟主机https绑定端口"

View File

@ -1,6 +0,0 @@
config frps 'main'
option enabled '0'
option server 'frps'
option client_file '/usr/bin/frps'
option bind_port '7000'
option tcp_mux 'true'

View File

@ -1,189 +0,0 @@
#!/bin/sh /etc/rc.common
#
# Copyright 2020 Weizheng Li <lwz322@qq.com>
# Licensed to the public under the MIT License.
#
START=99
USE_PROCD=1
NAME="frps"
CONFIG_FOLDER="/var/etc/$NAME"
_log() {
local level="$1" ; shift
local msg="$@"
logger -p "daemon.$level" -t "$NAME" "$msg"
echo "[$level] $msg" >&2
}
_info() {
_log "info" $@
}
_err() {
_log "err" $@
}
append_options() {
local file="$1" ; shift
local o v
for o in "$@" ; do
v="$(eval echo "\$$o")"
if [ -n "$v" ] ; then
# add brackets when ipv6 address
if ( echo "$o" | grep -qE 'addr|ip' ) &&
( echo "$v" | grep -q ':' ) ; then
v="[$v]"
fi
echo "${o} = $v" >>"$file"
fi
done
}
append_setting() {
local file="$1" ; shift
local s="$1"
if [ -n "$s" ] ; then
echo "$s" >>"$file"
fi
}
frps_scetion_validate() {
uci_validate_section "$NAME" "frps" "$1" \
'enabled:bool:0' \
'client_file:file:/usr/bin/frps' \
'run_user:string' \
'enable_logging:bool:0' \
'log_file:string:/var/log/frps.log' \
'log_level:or("trace", "debug", "info", "warn", "error"):warn' \
'log_max_days:uinteger:3' \
'disable_log_color:or("true", "false")' \
'max_pool_count:uinteger' \
'max_ports_per_client:uinteger:0' \
'subdomain_host:host' \
'dashboard_addr:host' \
'dashboard_port:port' \
'dashboard_user:string' \
'dashboard_pwd:string' \
'bind_port:port' \
'token:string' \
'tcp_mux:or("true", "false"):true' \
'bind_udp_port:port' \
'kcp_bind_port:port' \
'vhost_http_port:port' \
'vhost_https_port:port'
}
client_file_validate() {
local file="$1"
test -f "$file" || return 1
test -x "$file" || chmod 755 "$file"
eval "$file" -h | grep -q "$NAME"
return $?
}
add_rule_extra_option() {
append_setting "$2" "$1"
}
create_config_file() {
local config_file="$1"
local tmp_file="$(mktemp /tmp/frps-XXXXXX)"
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"
if [ "x$enable_logging" = "x1" ] ; then
if [ -z "$log_file" ]; then
log_file="/var/log/frps.log"
fi
append_options "$tmp_file" \
"log_file" "log_level" "log_max_days" "disable_log_color"
if [ -f "$log_file" ] ; then
echo > "$log_file"
else
local log_folder="$(dirname "$log_file")"
if [ ! -d "$log_folder" ] ; then
mkdir -p "$log_folder"
fi
fi
if [ -n "$run_user" ] && ( user_exists "$run_user" ) ; then
chmod 644 "$log_file"
chown "$run_user" "$log_file"
else
run_user=""
fi
fi
append_options "$tmp_file" \
"max_pool_count" "max_ports_per_client" "subdomain_host" "dashboard_addr" "dashboard_port" "dashboard_user" "dashboard_pwd"
sed '/^$/d' "$tmp_file" >"$config_file"
if [ "$?" = "0" ] ; then
rm -f "$tmp_file"
fi
}
start_instance() {
local section="$1"
if ! frps_scetion_validate "$section" ; then
_err "Config validate failed."
return 1
fi
if [ "x$enabled" != "x1" ] ; then
_info "Instance \"$section\" disabled."
return 1
fi
if [ -z "$client_file" ] || ( ! client_file_validate "$client_file" ) ; then
_err "Client file not valid."
return 1
fi
test -d "$CONFIG_FOLDER" || mkdir -p "$CONFIG_FOLDER"
local config_file="$CONFIG_FOLDER/frps.$section.ini"
create_config_file "$config_file"
if [ ! -f "$config_file" ] ; then
_err "Could not create config file: \"$config_file\""
return 1
fi
procd_open_instance "$NAME.$section"
procd_set_param command "$client_file"
procd_append_param command -c "$config_file"
procd_set_param respawn
procd_set_param file "$config_file"
if [ -n "$run_user" ] ; then
procd_set_param user "$run_user"
fi
procd_close_instance
}
service_triggers() {
procd_add_reload_trigger "$NAME"
}
start_service() {
config_load "$NAME"
config_foreach start_instance "frps"
}

View File

@ -1,25 +0,0 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete ucitrack.@frps[-1]
add ucitrack frps
set ucitrack.@frps[-1].init=frps
commit ucitrack
EOF
frps=$(uci -q get frps.@frps[-1])
if [ -z "$frps" ]; then
uci -q add frps frps
fi
if [ "x$frps" != "xmain" ]; then
uci -q batch <<-EOF >/dev/null
rename frps.@frps[-1]="main"
set frps.main.enabled="0"
commit frps
EOF
fi
rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
exit 0

View File

@ -1,19 +0,0 @@
#
# Copyright (C) 2008-2014 The LuCI Team <luci@lists.subsignal.org>
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI for FRPC
LUCI_DEPENDS:=+wget +openwrt-frpc
LUCI_PKGARCH:=all
PKG_VERSION:=1.1
PKG_RELEASE:=2
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -1,18 +0,0 @@
module("luci.controller.frp", package.seeall)
function index()
if not nixio.fs.access("/etc/config/frp") then
return
end
entry({"admin","services","frp"},cbi("frp/frp"), _("Frp Setting"),100).dependent=true
entry({"admin","services","frp","config"},cbi("frp/config")).leaf=true
entry({"admin","services","frp","status"},call("status")).leaf=true
end
function status()
local e={}
e.running=luci.sys.call("pidof frpc > /dev/null")==0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end

View File

@ -1,116 +0,0 @@
local n="frp"
local i=require"luci.dispatcher"
local o=require"luci.model.network".init()
local m=require"nixio.fs"
local a,t,e
arg[1]=arg[1]or""
a=Map(n,translate("Frp Domain Config"))
a.redirect=i.build_url("admin","services","frp")
t=a:section(NamedSection,arg[1],"frp",translate("Config Frp Protocol"))
t.addremove=false
t.dynamic=false
t:tab("base",translate("Basic Settings"))
t:tab("other",translate("Other Settings"))
e=t:taboption("base",ListValue,"enable",translate("Enable State"))
e.default="1"
e.rmempty=false
e:value("1",translate("Enable"))
e:value("0",translate("Disable"))
e=t:taboption("base",ListValue, "type", translate("Frp Protocol Type"))
e:value("http",translate("HTTP"))
e:value("https",translate("HTTPS"))
e:value("tcp",translate("TCP"))
e:value("udp",translate("UDP"))
e:value("stcp",translate("STCP"))
e = t:taboption("base",ListValue, "domain_type", translate("Domain Type"))
e.default = "custom_domains"
e:value("custom_domains",translate("Custom Domains"))
e:value("subdomain",translate("SubDomain"))
e:value("both_dtype",translate("Both the above two Domain types"))
e:depends("type","http")
e:depends("type","https")
e = t:taboption("base",Value, "custom_domains", translate("Custom Domains"), translate("If SubDomain is used, Custom Domains couldn't be subdomain or wildcard domain of the maindomain(subdomain_host)."))
e:depends("domain_type","custom_domains")
e:depends("domain_type","both_dtype")
e = t:taboption("base",Value, "subdomain", translate("SubDomain"), translate("subdomain_host must be configured in server: frps in advance."))
e:depends("domain_type","subdomain")
e:depends("domain_type","both_dtype")
e = t:taboption("base",ListValue, "stcp_role", translate("STCP Role"))
e.default = "server"
e:value("server",translate("STCP Server"))
e:value("visitor",translate("STCP Vistor"))
e:depends("type","stcp")
e = t:taboption("base",Value, "remote_port", translate("Remote Port"))
e.datatype = "port"
e:depends("type","tcp")
e:depends("type","udp")
e = t:taboption("other",Flag, "enable_plugin", translate("Use Plugin"),translate("If plugin is defined, local_ip and local_port is useless, plugin will handle connections got from frps."))
e.default = "0"
e:depends("type","tcp")
e = t:taboption("base",Value, "local_ip", translate("Local Host Address"))
luci.sys.net.ipv4_hints(function(x,d)
e:value(x,"%s (%s)"%{x,d})
end)
e.datatype = "ip4addr"
e:depends("type","udp")
e:depends("type","http")
e:depends("type","https")
e:depends("enable_plugin",0)
e = t:taboption("base",Value, "local_port", translate("Local Host Port"))
e.datatype = "port"
e:depends("type","udp")
e:depends("type","http")
e:depends("type","https")
e:depends("enable_plugin",0)
e = t:taboption("base",Value, "stcp_secretkey", translate("STCP Screct Key"))
e.default = "abcdefg"
e:depends("type","stcp")
e = t:taboption("base",Value, "stcp_servername", translate("STCP Server Name"), translate("STCP Server Name is Service Remark Name of STCP Server"))
e.default = "secret_tcp"
e:depends("stcp_role","visitor")
e = t:taboption("other",Flag, "enable_locations", translate("Enable URL routing"), translate("Frp support forward http requests to different backward web services by url routing."))
e:depends("type","http")
e = t:taboption("other",Value, "locations ", translate("URL routing"), translate("Http requests with url prefix /news will be forwarded to this service."))
e.default="locations=/"
e:depends("enable_locations",1)
e = t:taboption("other",ListValue, "plugin", translate("Choose Plugin"))
e:value("http_proxy",translate("http_proxy"))
e:value("socks5",translate("socks5"))
e:value("unix_domain_socket",translate("unix_domain_socket"))
e:depends("enable_plugin",1)
e = t:taboption("other",Flag, "enable_plugin_httpuserpw", translate("Proxy Authentication"),translate("Other PCs could access the Internet through frpc's network by using http_proxy plugin."))
e.default = "0"
e:depends("plugin","http_proxy")
e = t:taboption("other",Value, "plugin_http_user", translate("HTTP Proxy UserName"))
e.default = "abc"
e:depends("enable_plugin_httpuserpw",1)
e = t:taboption("other",Value, "plugin_http_passwd", translate("HTTP Proxy Password"))
e.default = "abc"
e:depends("enable_plugin_httpuserpw",1)
e = t:taboption("other",Value, "plugin_unix_path", translate("Plugin Unix Sock Path"))
e.default = "/var/run/docker.sock"
e:depends("plugin","unix_domain_socket")
e = t:taboption("other",Flag, "enable_http_auth", translate("Password protecting your web service"), translate("Http username and password are safety certification for http protocol."))
e.default = "0"
e:depends("type","http")
e = t:taboption("other",Value, "http_user", translate("HTTP UserName"))
e.default = "frp"
e:depends("enable_http_auth",1)
e = t:taboption("other",Value, "http_pwd", translate("HTTP PassWord"))
e.default = "frp"
e:depends("enable_http_auth",1)
e = t:taboption("other",Flag, "enable_host_header_rewrite", translate("Rewriting the Host Header"), translate("Frp can rewrite http requests with a modified Host header."))
e.default = "0"
e:depends("type","http")
e = t:taboption("other",Value, "host_header_rewrite", translate("Host Header"), translate("The Host header will be rewritten to match the hostname portion of the forwarding address."))
e.default = "dev.yourdomain.com"
e:depends("enable_host_header_rewrite",1)
e = t:taboption("base",Flag, "use_encryption", translate("Use Encryption"), translate("Encrypted the communication between frpc and frps, will effectively prevent the traffic intercepted."))
e.default = "1"
e.rmempty = false
e = t:taboption("base",Flag, "use_compression", translate("Use Compression"), translate("The contents will be compressed to speed up the traffic forwarding speed, but this will consume some additional cpu resources."))
e.default = "1"
e.rmempty = false
e = t:taboption("base",Value, "remark", translate("Service Remark Name"), translate("<font color=\"red\">Please ensure the remark name is unique.</font>"))
e.rmempty = false
return a

View File

@ -1,160 +0,0 @@
local o=require"luci.dispatcher"
local e=require("luci.model.ipkg")
local s=require"nixio.fs"
local e=luci.model.uci.cursor()
local i="frp"
local a,t,e
local n={}
a=Map(i,translate("Frp Setting"), translate("Frp is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet."))
a:section(SimpleSection).template="frp/frp_status"
t=a:section(NamedSection,"common","frp",translate("Global Setting"))
t.anonymous=true
t.addremove=false
t:tab("base",translate("Basic Settings"))
t:tab("other",translate("Other Settings"))
t:tab("log",translate("Client Log"))
e=t:taboption("base",Flag, "enabled", translate("Enabled"))
e.rmempty=false
e=t:taboption("base",Value, "server_addr", translate("Server"))
e.optional=false
e.rmempty=false
e=t:taboption("base",Value, "server_port", translate("Port"))
e.datatype = "port"
e.optional=false
e.rmempty=false
e=t:taboption("base",Value, "token", translate("Token"), translate("Time duration between server of frpc and frps mustn't exceed 15 minutes."))
e.optional=false
e.password=true
e.rmempty=false
e=t:taboption("base",Value, "vhost_http_port", translate("Vhost HTTP Port"))
e.datatype = "port"
e.rmempty=false
e=t:taboption("base",Value, "vhost_https_port", translate("Vhost HTTPS Port"))
e.datatype = "port"
e.rmempty=false
e=t:taboption("other",Flag, "login_fail_exit", translate("Exit program when first login failed"),translate("decide if exit program when first login failed, otherwise continuous relogin to frps."))
e.default = "1"
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",ListValue, "protocol", translate("Protocol Type"),translate("Frp support kcp protocol since v0.12.0"))
e.default = "tcp"
e:value("tcp",translate("TCP Protocol"))
e:value("kcp",translate("KCP Protocol"))
e=t:taboption("other",Flag, "enable_http_proxy", translate("Connect frps by HTTP PROXY"), translate("frpc can connect frps using HTTP PROXY"))
e.default = "0"
e.rmempty=false
e:depends("protocol","tcp")
e=t:taboption("other",Value, "http_proxy", translate("HTTP PROXY"))
e.datatype="uinteger"
e.placeholder="http://user:pwd@192.168.1.128:8080"
e:depends("enable_http_proxy",1)
e.optional=false
e=t:taboption("other",Flag, "enable_cpool", translate("Enable Connection Pool"), translate("This feature is fit for a large number of short connections."))
e.rmempty=false
e=t:taboption("other",Value, "pool_count", translate("Connection Pool"), translate("Connections will be established in advance."))
e.datatype="uinteger"
e.default = "1"
e:depends("enable_cpool",1)
e.optional=false
e=t:taboption("base",Value,"time",translate("Service registration interval"),translate("0 means disable this feature, unit: min"))
e.datatype="range(0,59)"
e.default=30
e.rmempty=false
e=t:taboption("other",ListValue, "log_level", translate("Log Level"))
e.default = "warn"
e:value("trace",translate("Trace"))
e:value("debug",translate("Debug"))
e:value("info",translate("Info"))
e:value("warn",translate("Warning"))
e:value("error",translate("Error"))
e=t:taboption("other",Value, "log_max_days", translate("Log Keepd Max Days"))
e.datatype = "uinteger"
e.default = "3"
e.rmempty=false
e.optional=false
e=t:taboption("log",TextValue,"log")
e.rows=26
e.wrap="off"
e.readonly=true
e.cfgvalue=function(t,t)
return s.readfile("/var/etc/frp/frpc.log")or""
end
e.write=function(e,e,e)
end
t=a:section(TypedSection,"proxy",translate("Services List"))
t.anonymous=true
t.addremove=true
t.template="cbi/tblsection"
t.extedit=o.build_url("admin","services","frp","config","%s")
function t.create(e,t)
new=TypedSection.create(e,t)
luci.http.redirect(e.extedit:format(new))
end
function t.remove(e,t)
e.map.proceed=true
e.map:del(t)
luci.http.redirect(o.build_url("admin","services","frp"))
end
local o=""
e=t:option(DummyValue,"remark",translate("Service Remark Name"))
e.width="10%"
e=t:option(DummyValue,"type",translate("Frp Protocol Type"))
e.width="10%"
e=t:option(DummyValue,"custom_domains",translate("Domain/Subdomain"))
e.width="20%"
e.cfgvalue=function(t,n)
local t=a.uci:get(i,n,"domain_type")or""
local m=a.uci:get(i,n,"type")or""
if t=="custom_domains" then
local b=a.uci:get(i,n,"custom_domains")or"" return b end
if t=="subdomain" then
local b=a.uci:get(i,n,"subdomain")or"" return b end
if t=="both_dtype" then
local b=a.uci:get(i,n,"custom_domains")or""
local c=a.uci:get(i,n,"subdomain")or""
b="%s/%s"%{b,c} return b end
if m=="tcp" or m=="udp" then
local b=a.uci:get(i,"common","server_addr")or"" return b end
end
e=t:option(DummyValue,"remote_port",translate("Remote Port"))
e.width="10%"
e.cfgvalue=function(t,b)
local t=a.uci:get(i,b,"type")or""
if t==""or b==""then return""end
if t=="http" then
local b=a.uci:get(i,"common","vhost_http_port")or"" return b end
if t=="https" then
local b=a.uci:get(i,"common","vhost_https_port")or"" return b end
if t=="tcp" or t=="udp" then
local b=a.uci:get(i,b,"remote_port")or"" return b end
end
e=t:option(DummyValue,"local_ip",translate("Local Host Address"))
e.width="15%"
e=t:option(DummyValue,"local_port",translate("Local Host Port"))
e.width="10%"
e=t:option(DummyValue,"use_encryption",translate("Use Encryption"))
e.width="15%"
e.cfgvalue=function(t,n)
local t=a.uci:get(i,n,"use_encryption")or""
local b
if t==""or b==""then return""end
if t=="1" then b="ON"
else b="OFF" end
return b
end
e=t:option(DummyValue,"use_compression",translate("Use Compression"))
e.width="15%"
e.cfgvalue=function(t,n)
local t=a.uci:get(i,n,"use_compression")or""
local b
if t==""or b==""then return""end
if t=="1" then b="ON"
else b="OFF" end
return b
end
e=t:option(Flag,"enable",translate("Enable State"))
e.width="10%"
e.rmempty=false
return a

View File

@ -1,23 +0,0 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(5, '<%=url([[admin]], [[services]], [[frp]], [[status]])%>', null,
function(x, data) {
var tb = document.getElementById('frp_status');
if (data && tb) {
if (data.running) {
var links = '<em><b><font color=green><%:The Frp service is running.%></font></b></em>';
tb.innerHTML = links;
} else {
tb.innerHTML = '<em><b><font color=red><%:The Frp service is not running.%></font></b></em>';
}
}
}
);
//]]>
</script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
<fieldset class="cbi-section">
<legend><%:Frp Status%></legend>
<p id="frp_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>

View File

@ -1,420 +0,0 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: PACKAGE VERSION\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: zh-Hans\n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
#: luasrc/model/cbi/frp/frp.lua:61
msgid "0 means disable this feature, unit: min"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:114
msgid "<font color=\"red\">Please ensure the remark name is unique.</font>"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:12 luasrc/model/cbi/frp/frp.lua:13
msgid "Basic Settings"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:29
msgid "Both the above two Domain types"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:76
msgid "Choose Plugin"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:15
msgid "Client Log"
msgstr ""
#: luasrc/view/frp/frp_status.htm:21
msgid "Collecting data..."
msgstr ""
#: luasrc/model/cbi/frp/config.lua:9
msgid "Config Frp Protocol"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:45
msgid "Connect frps by HTTP PROXY"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:56
msgid "Connection Pool"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:56
msgid "Connections will be established in advance."
msgstr ""
#: luasrc/model/cbi/frp/config.lua:27 luasrc/model/cbi/frp/config.lua:32
msgid "Custom Domains"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:68
msgid "Debug"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:38
msgid "Default is Ture. This feature in frps.ini and frpc.ini must be same."
msgstr ""
#: luasrc/model/cbi/frp/config.lua:18
msgid "Disable"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:25
msgid "Domain Type"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:105
msgid "Domain/Subdomain"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:17
msgid "Enable"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:54
msgid "Enable Connection Pool"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:14 luasrc/model/cbi/frp/frp.lua:157
msgid "Enable State"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:71
msgid "Enable URL routing"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:16
msgid "Enabled"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:108
msgid ""
"Encrypted the communication between frpc and frps, will effectively prevent "
"the traffic intercepted."
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:71
msgid "Error"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:35
msgid "Exit program when first login failed"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:7
msgid "Frp Domain Config"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:19 luasrc/model/cbi/frp/frp.lua:103
msgid "Frp Protocol Type"
msgstr ""
#: luasrc/controller/frp.lua:8 luasrc/model/cbi/frp/frp.lua:8
msgid "Frp Setting"
msgstr ""
#: luasrc/view/frp/frp_status.htm:19
msgid "Frp Status"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:102
msgid "Frp can rewrite http requests with a modified Host header."
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:8
msgid ""
"Frp is a fast reverse proxy to help you expose a local server behind a NAT "
"or firewall to the internet."
msgstr ""
#: luasrc/model/cbi/frp/config.lua:71
msgid ""
"Frp support forward http requests to different backward web services by url "
"routing."
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:41
msgid "Frp support kcp protocol since v0.12.0"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:10
msgid "Global Setting"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:20
msgid "HTTP"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:49
msgid "HTTP PROXY"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:99
msgid "HTTP PassWord"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:87
msgid "HTTP Proxy Password"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:84
msgid "HTTP Proxy UserName"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:96
msgid "HTTP UserName"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:21
msgid "HTTPS"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:105
msgid "Host Header"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:73
msgid "Http requests with url prefix /news will be forwarded to this service."
msgstr ""
#: luasrc/model/cbi/frp/config.lua:93
msgid "Http username and password are safety certification for http protocol."
msgstr ""
#: luasrc/model/cbi/frp/config.lua:32
msgid ""
"If SubDomain is used, Custom Domains couldn't be subdomain or wildcard "
"domain of the maindomain(subdomain_host)."
msgstr ""
#: luasrc/model/cbi/frp/config.lua:47
msgid ""
"If plugin is defined, local_ip and local_port is useless, plugin will handle "
"connections got from frps."
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:69
msgid "Info"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:44
msgid "KCP Protocol"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:50 luasrc/model/cbi/frp/frp.lua:133
msgid "Local Host Address"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:59 luasrc/model/cbi/frp/frp.lua:135
msgid "Local Host Port"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:72
msgid "Log Keepd Max Days"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:65
msgid "Log Level"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:81
msgid ""
"Other PCs could access the Internet through frpc's network by using "
"http_proxy plugin."
msgstr ""
#: luasrc/model/cbi/frp/config.lua:13 luasrc/model/cbi/frp/frp.lua:14
msgid "Other Settings"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:93
msgid "Password protecting your web service"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:90
msgid "Plugin Unix Sock Path"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:21
msgid "Port"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:41
msgid "Protocol Type"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:81
msgid "Proxy Authentication"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:43 luasrc/model/cbi/frp/frp.lua:121
msgid "Remote Port"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:102
msgid "Rewriting the Host Header"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:24
msgid "STCP"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:38
msgid "STCP Role"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:65
msgid "STCP Screct Key"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:40
msgid "STCP Server"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:68
msgid "STCP Server Name"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:68
msgid "STCP Server Name is Service Remark Name of STCP Server"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:41
msgid "STCP Vistor"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:18
msgid "Server"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:114 luasrc/model/cbi/frp/frp.lua:101
msgid "Service Remark Name"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:61
msgid "Service registration interval"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:86
msgid "Services List"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:28 luasrc/model/cbi/frp/config.lua:35
msgid "SubDomain"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:22
msgid "TCP"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:43
msgid "TCP Protocol"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:38
msgid "TCP Stream Multiplexing"
msgstr ""
#: luasrc/view/frp/frp_status.htm:10
msgid "The Frp service is not running."
msgstr ""
#: luasrc/view/frp/frp_status.htm:7
msgid "The Frp service is running."
msgstr ""
#: luasrc/model/cbi/frp/config.lua:105
msgid ""
"The Host header will be rewritten to match the hostname portion of the "
"forwarding address."
msgstr ""
#: luasrc/model/cbi/frp/config.lua:111
msgid ""
"The contents will be compressed to speed up the traffic forwarding speed, "
"but this will consume some additional cpu resources."
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:54
msgid "This feature is fit for a large number of short connections."
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:25
msgid ""
"Time duration between server of frpc and frps mustn't exceed 15 minutes."
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:25
msgid "Token"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:67
msgid "Trace"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:23
msgid "UDP"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:73
msgid "URL routing"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:111 luasrc/model/cbi/frp/frp.lua:147
msgid "Use Compression"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:108 luasrc/model/cbi/frp/frp.lua:137
msgid "Use Encryption"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:47
msgid "Use Plugin"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:29
msgid "Vhost HTTP Port"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:32
msgid "Vhost HTTPS Port"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:70
msgid "Warning"
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:35
msgid ""
"decide if exit program when first login failed, otherwise continuous relogin "
"to frps."
msgstr ""
#: luasrc/model/cbi/frp/frp.lua:45
msgid "frpc can connect frps using HTTP PROXY"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:77
msgid "http_proxy"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:78
msgid "socks5"
msgstr ""
#: luasrc/model/cbi/frp/config.lua:35
msgid "subdomain_host must be configured in server: frps in advance."
msgstr ""
#: luasrc/model/cbi/frp/config.lua:79
msgid "unix_domain_socket"
msgstr ""

View File

@ -1,16 +0,0 @@
config frp 'common'
option log_max_days '3'
option login_fail_exit '0'
option enable_cpool '0'
option time '40'
option tcp_mux '1'
option enabled '0'
option vhost_http_port '80'
option vhost_https_port '443'
option server_addr 'yourdomain.com'
option server_port '7000'
option token '1234567'
option log_level 'info'
option enable_http_proxy '0'
option protocol 'tcp'

View File

@ -1,214 +0,0 @@
#!/bin/sh /etc/rc.common
#Author: monokoo <realstones2012@gmail.com>
#Thanks to FW867's help
START=99
SERVICE_WRITE_PID=1
SERVICE_DAEMONIZE=1
LOGFILE="/var/etc/frp/frpc.log"
echo_date(){
local log=$1
echo $(date +%Y/%m/%d\ %X): "$log" >> $LOGFILE
}
Reduce_Log(){
local log=$1
[ ! -f "$log" ] && return
local sc=200
[ -n "$2" ] && sc=$2
local count=$(grep -c "" $log)
if [ $count -gt $sc ];then
let count=count-$sc
sed -i "1,$count d" $log
fi
}
conf_proxy_add() {
local cfg="$1"
local tmpconf="$2"
local enable type domain_type custom_domains remote_port local_ip local_port enable_http_auth enable_host_header_rewrite host_header_rewrite
local subdomain use_encryption use_compression http_user http_pwd remark locations
local enable_plugin plugin plugin_http_user plugin_http_passwd plugin_unix_path stcp_role stcp_secretkey stcp_servername
config_get_bool enable "$cfg" enable 1
[ "$enable" -gt 0 ] || return 1
config_get type "$cfg" type
config_get custom_domains "$cfg" custom_domains
config_get subdomain "$cfg" subdomain
config_get remote_port "$cfg" remote_port
config_get local_ip "$cfg" local_ip
config_get local_port "$cfg" local_port
config_get locations "$cfg" locations
config_get host_header_rewrite "$cfg" host_header_rewrite
config_get http_user "$cfg" http_user
config_get http_pwd "$cfg" http_pwd
config_get remark "$cfg" remark
config_get plugin "$cfg" plugin
config_get plugin_http_user "$cfg" plugin_http_user
config_get plugin_http_passwd "$cfg" plugin_http_passwd
config_get plugin_unix_path "$cfg" plugin_unix_path
config_get stcp_role "$cfg" stcp_role
config_get stcp_secretkey "$cfg" stcp_secretkey
config_get stcp_servername "$cfg" stcp_servername
[ -n "$remark" ] && [ -n "$type" ] || return 1
echo "" >>$tmpconf
echo "[$remark]" >>$tmpconf
echo "type=$type" >>$tmpconf
[ -n "$custom_domains" ] && echo "custom_domains=$custom_domains" >>$tmpconf
[ -n "$subdomain" ] && echo "subdomain=$subdomain" >>$tmpconf
[ -n "$remote_port" ] && echo "remote_port=$remote_port" >>$tmpconf
[ -z "$stcp_role" ] && [ -n "$local_ip" ] && echo "local_ip=$local_ip" >>$tmpconf
[ -z "$stcp_role" ] && [ -n "$local_port" ] && echo "local_port=$local_port" >>$tmpconf
[ -n "$locations" ] && echo "locations=$locations" >>$tmpconf
[ -n "$http_user" -a -n "$http_pwd" ] && {
echo "http_user=$http_user" >>$tmpconf
echo "http_pwd=$http_pwd" >>$tmpconf
}
[ -n "$host_header_rewrite" ] && echo "host_header_rewrite=$host_header_rewrite" >>$tmpconf
[ -n "$plugin" ] && echo "plugin=$plugin" >>$tmpconf
[ -n "$plugin_http_user" -a -n "$plugin_http_passwd" ] && {
echo "plugin_http_user=$plugin_http_user" >>$tmpconf
echo "plugin_http_passwd=$plugin_http_passwd" >>$tmpconf
}
[ -n "$plugin_unix_path" ] && echo "plugin_unix_path=$plugin_unix_path" >>$tmpconf
[ -n "$stcp_role" ] && {
if [ "$stcp_role" == "visitor" ]; then
echo "role=$stcp_role" >>$tmpconf
[ -n "$local_ip" ] && echo "bind_addr=$local_ip" >>$tmpconf
[ -n "$local_port" ] && echo "bind_port=$local_port" >>$tmpconf
[ -n "$stcp_servername" ] && echo "server_name=$stcp_servername" >>$tmpconf || return 1
else
[ -n "$local_ip" ] && echo "local_ip=$local_ip" >>$tmpconf
[ -n "$local_port" ] && echo "local_port=$local_port" >>$tmpconf
fi
[ -n "$stcp_secretkey" ] && echo "sk=$stcp_secretkey" >>$tmpconf || return 1
}
frp_write_bool use_encryption $cfg 1
frp_write_bool use_compression $cfg 1
}
frp_write_bool() {
local opt="$1"
local config="$2"
local def="$3"
local val
config_get_bool val $config "$opt" "$def"
if [ "$val" -eq 0 ]; then
echo "${opt}=false" >> $tmpconf
else
echo "${opt}=true" >> $tmpconf
fi
}
frp_add_cru(){
time=$1
if [ ! -f "/etc/crontabs/root" ] || [ -z "$(cat /etc/crontabs/root | grep frp)" ]; then
sed -i '/frp/d' /etc/crontabs/root >/dev/null 2>&1
echo "*/$time * * * * /etc/init.d/frp restart" >> /etc/crontabs/root
fi
}
frp_del_cru(){
if [ ! -f "/etc/crontabs/root" ] || [ -n "$(cat /etc/crontabs/root | grep frp)" ]; then
sed -i '/frp/d' /etc/crontabs/root >/dev/null 2>&1
fi
}
download_binary(){
echo_date "开始下载frpc二进制文件..."
/usr/bin/wget --no-check-certificate --timeout=10 --tries=1 -o $LOGFILE https://github.com/fatedier/frp/releases/download/v0.13.0/frp_0.13.0_linux_arm.tar.gz -O /tmp/frp_0.13.0_linux_arm.tar.gz
[ ! -s "/tmp/frp_0.13.0_linux_arm.tar.gz" ] && /usr/bin/wget -q --no-check-certificate --timeout=10 --tries=1 https://any.mokoo.xyz/app/frp_0.13.0_linux_arm.tar.gz -O /tmp/frp_0.13.0_linux_arm.tar.gz
[ -f "/tmp/frp_0.13.0_linux_arm.tar.gz" ] && tar -xf /tmp/frp_0.13.0_linux_arm.tar.gz -C /tmp && \
mv /tmp/frp_0.13.0_linux_arm/frpc /usr/bin/frpc
rm -rf /tmp/frp_0.13.0_linux_arm*
if [ -f "/usr/bin/frpc" ]; then
chmod +x /usr/bin/frpc && echo_date "成功下载frpc二进制文件"
else
echo_date "下载frpc二进制文件失败请重试"
fi
}
boot() {
sleep 10s
start
}
start() {
config_load "frp"
local enabled server_addr server_port time privilege_token tcp_mux enable_cpool
local pool_count log_level log_max_days login_fail_exit http_proxy protocol
config_get_bool enabled common enabled 1
[ "$enabled" -gt 0 ] || return 1
config_get server_addr common server_addr
config_get server_port common server_port
config_get token common token
config_get enable_cpool common enable_cpool
config_get pool_count common pool_count
config_get log_level common log_level
config_get log_max_days common log_max_days
config_get http_proxy common http_proxy
config_get protocol common protocol
config_get time common time
mkdir -p /var/etc/frp
[ ! -f "$LOGFILE" ] && touch $LOGFILE
[ ! -f "/usr/bin/frpc" ] && download_binary
[ ! -f "/usr/bin/frpc" ] && logger -t Frp 'Download frpc failed, please retry.' && exit 0
local tmpconf="/var/etc/frp/frpc.conf"
echo "[common]" >$tmpconf
echo "server_addr=${server_addr}" >>$tmpconf
echo "server_port=${server_port}" >>$tmpconf
echo "token=${token}" >>$tmpconf
echo "log_level=${log_level}" >>$tmpconf
echo "log_max_days=${log_max_days}" >>$tmpconf
echo "protocol=${protocol}" >>$tmpconf
echo "log_file=$LOGFILE" >>$tmpconf
[ -n "$http_proxy" ] && echo "http_proxy=$http_proxy" >>$tmpconf
[ -n "$pool_count" ] && echo "pool_count=$pool_count" >>$tmpconf
config_load "frp"
frp_write_bool tcp_mux common 1
frp_write_bool login_fail_exit common 1
config_foreach conf_proxy_add proxy "$tmpconf"
[ "$(cat "$tmpconf" | grep -c "type=")" -gt 0 ] || (echo_date "frp服务启动失败请首先添加服务列表" && exit 0)
logger -t FRPC 'Starting frp service'
SERVICE_DAEMONIZE=1 \
service_start /usr/bin/frpc -c $tmpconf
[ "$time" -gt 0 ] && frp_add_cru $time
[ -z "$(pgrep /usr/bin/frpc)" ] && echo_date "frp服务启动失败请检查服务端 “TCP多路复用(tcp_mux)”设置,确保与客户端完全一致!"
return 0
}
stop() {
frp_del_cru
if [ -n "`pidof frpc`" ]; then
logger -t FRPC 'Shutting down frp service'
service_stop /usr/bin/frpc
Reduce_Log $LOGFILE
fi
return 0
}

View File

@ -1,11 +0,0 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete ucitrack.@frp[-1]
add ucitrack frp
set ucitrack.@frp[-1].init=frp
commit ucitrack
EOF
rm -f /tmp/luci-indexcache
exit 0

View File

@ -1,75 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=openwrt-frp
PKG_VERSION:=0.32.0
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/fatedier/frp/tar.gz/v${PKG_VERSION}?
PKG_HASH:=790a18f5651cc645a3d73fc147c719f5b212fc21db0c51c620011ee836b7a28f
PKG_MAINTAINER:=Richard Yu <yurichard3839@gmail.com>
PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILES:=LICENSE
PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0
GO_PKG:=github.com/fatedier/frp
GO_PKG_BUILD_PKG:=github.com/fatedier/frp/cmd/...
include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
define Package/openwrt-frp/template
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
TITLE:=frp - fast reverse proxy
URL:=https://github.com/fatedier/frp
DEPENDS:=$(GO_ARCH_DEPENDS)
endef
define Package/openwrt-frpc
$(call Package/openwrt-frp/template)
TITLE+= (client)
endef
define Package/openwrt-frps
$(call Package/openwrt-frp/template)
TITLE+= (server)
endef
define Package/openwrt-frp/description
frp is a fast reverse proxy to help you expose a local server behind
a NAT or firewall to the internet.
endef
Package/openwrt-frpc/description = $(Package/openwrt-frp/description)
Package/openwrt-frps/description = $(Package/openwrt-frp/description)
define Package/openwrt-frp/install
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
$(INSTALL_DIR) $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/$(2) $(1)/usr/bin/
$(INSTALL_DIR) $(1)/etc/frp/$(2).d/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/conf/$(2)_full.ini $(1)/etc/frp/$(2).d/
$(INSTALL_DIR) $(1)/etc/config/
$(INSTALL_CONF) ./files/$(2).config $(1)/etc/config/$(2)
$(INSTALL_DIR) $(1)/etc/init.d/
$(INSTALL_BIN) ./files/$(2).init $(1)/etc/init.d/$(2)
endef
define Package/openwrt-frpc/install
$(call Package/openwrt-frp/install,$(1),frpc)
endef
define Package/openwrt-frps/install
$(call Package/openwrt-frp/install,$(1),frps)
endef
$(eval $(call GoBinPackage,openwrt-frpc))
$(eval $(call BuildPackage,openwrt-frpc))
$(eval $(call GoBinPackage,openwrt-frps))
$(eval $(call BuildPackage,openwrt-frps))