luci-app-frpc: tidy up code (#8168)

This commit is contained in:
Beginner 2021-11-10 15:34:23 +08:00 committed by GitHub
parent ac2d41bd27
commit 0ed591b402
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 670 additions and 567 deletions

View File

@ -10,7 +10,7 @@ LUCI_TITLE:=LuCI for FRPC
LUCI_DEPENDS:=+wget +frpc
LUCI_PKGARCH:=all
PKG_VERSION:=1.4
PKG_RELEASE:=1
PKG_RELEASE:=2
include $(TOPDIR)/feeds/luci/luci.mk

View File

@ -5,14 +5,14 @@ function index()
return
end
entry({"admin", "services", "frp"}, cbi("frp/frp"), _("Frp Setting"), 100).dependent = true
entry({"admin", "services", "frp"}, cbi("frp/basic"), _("Frp Setting"), 100).dependent = true
entry({"admin", "services", "frp", "config"}, cbi("frp/config")).leaf = true
entry({"admin", "services", "frp", "status"}, call("status")).leaf = true
entry({"admin", "services", "frp", "status"}, call("act_status")).leaf = true
end
function status()
local e={}
e.running=luci.sys.call("pidof frpc > /dev/null")==0
function act_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

@ -0,0 +1,241 @@
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("frp")
a.title = translate("Frp Setting")
a.description = 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")
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"))
e.description = 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, "user", translate("User"))
e.description = translate("Commonly used to distinguish you with other clients.")
e.optional = true
e.default = ""
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("base", Value, "time", translate("Service registration interval"))
e.description = translate("0 means disable this feature, unit: min")
e.datatype = "range(0,59)"
e.default = 30
e.rmempty = false
e = t:taboption("other", Flag, "login_fail_exit", translate("Exit program when first login failed"))
e.description = 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"))
e.description = 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"))
e.description = 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"))
e.description = 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"))
e.description = 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"))
e.description = 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"))
e.description = translate("Connections will be established in advance.")
e.datatype = "uinteger"
e.default = "1"
e:depends("enable_cpool",1)
e.optional=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("other", Flag, "admin_enable", translate("Enable Web API"))
e.description = 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"
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,53 +1,71 @@
local n="frp"
local i=require"luci.dispatcher"
local o=require"luci.model.network".init()
local m=require"nixio.fs"
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"))
arg[1] = arg[1]or""
a = Map("frp")
a.title = translate("Frp Domain Config")
a.redirect = i.build_url("admin","services","frp")
t = a:section(NamedSection, arg[1], "frp")
t.title = 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: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 = t:taboption("base", Value, "custom_domains", translate("Custom Domains"))
e.description = 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 = t:taboption("base", Value, "subdomain", translate("SubDomain"))
e.description = 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 = 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: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 = 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 = t:taboption("other", Flag, "enable_plugin", translate("Use Plugin"))
e.description = 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"))
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)
@ -56,91 +74,130 @@ 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 = 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 = 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 = t:taboption("base", Value, "stcp_servername", translate("STCP Server Name"))
e.description = 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 = t:taboption("other", Flag, "enable_locations", translate("Enable URL routing"))
e.description = 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 = t:taboption("other", Value, "locations ", translate("URL routing"))
e.description = 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 = 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 = t:taboption("other", Flag, "enable_plugin_httpuserpw", translate("Proxy Authentication"))
e.description = 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 = 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 = 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 = 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 = t:taboption("other", Flag, "enable_http_auth", translate("Password protecting your web service"))
e.description = 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 = 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 = 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 = t:taboption("other", Flag, "enable_host_header_rewrite", translate("Rewriting the Host Header"))
e.description = 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 = t:taboption("other", Value, "host_header_rewrite", translate("Host Header"))
e.description = 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("other",Flag,"enable_https_plugin",translate("Use Plugin"))
e.default="0"
e = t:taboption("other", Flag, "enable_https_plugin", translate("Use Plugin"))
e.default = "0"
e:depends("type","https")
e=t:taboption("other",ListValue,"https_plugin",translate("Choose Plugin"),translate("If plugin is defined, local_ip and local_port is useless, plugin will handle connections got from frps."))
e:value("https2http",translate("https2http"))
e = t:taboption("other", ListValue, "https_plugin", translate("Choose Plugin"))
e.description = translate("If plugin is defined, local_ip and local_port is useless, plugin will handle connections got from frps.")
e:value("https2http", translate("https2http"))
e:depends("enable_https_plugin",1)
e=t:taboption("other",Value,"plugin_local_addr",translate("Plugin_Local_Addr"))
e = t:taboption("other", Value, "plugin_local_addr", translate("Plugin_Local_Addr"))
e.default="127.0.0.1:80"
e:depends("https_plugin","https2http")
e=t:taboption("other",Value,"plugin_crt_path",translate("plugin_crt_path"))
e.default="./server.crt"
e = t:taboption("other", Value, "plugin_crt_path", translate("plugin_crt_path"))
e.default = "./server.crt"
e:depends("https_plugin","https2http")
e=t:taboption("other",Value,"plugin_key_path",translate("plugin_key_path"))
e.default="./server.key"
e = t:taboption("other", Value, "plugin_key_path", translate("plugin_key_path"))
e.default = "./server.key"
e:depends("https_plugin","https2http")
e=t:taboption("other",Value,"plugin_host_header_rewrite",translate("plugin_host_header_rewrite"))
e.default="127.0.0.1"
e = t:taboption("other", Value, "plugin_host_header_rewrite", translate("plugin_host_header_rewrite"))
e.default = "127.0.0.1"
e:depends("https_plugin","https2http")
e=t:taboption("other",Value,"plugin_header_X_From_Where",translate("plugin_header_X-From-Where"))
e.default="frp"
e = t:taboption("other", Value, "plugin_header_X_From_Where", translate("plugin_header_X-From-Where"))
e.default = "frp"
e:depends("https_plugin","https2http")
e = t:taboption("base",ListValue, "proxy_protocol_version", translate("Proxy-Protocol Version"), translate("Proxy Protocol to send user's real IP to local services."))
e = t:taboption("base", ListValue, "proxy_protocol_version", translate("Proxy-Protocol Version"))
e.description = translate("Proxy Protocol to send user's real IP to local services.")
e.default = "disable"
e:value("disable",translate("Disable"))
e:value("v1",translate("V1"))
e:value("v2",translate("V2"))
e:value("disable", translate("Disable"))
e:value("v1", translate("V1"))
e:value("v2", translate("V2"))
e:depends("type","tcp")
e:depends("type","stcp")
e:depends("type","http")
e:depends("type","https")
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 = t:taboption("base",Flag, "use_encryption", translate("Use Encryption"))
e.description = 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 = t:taboption("base",Flag, "use_compression", translate("Use Compression"))
e.description = 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 = t:taboption("base",Value, "remark", translate("Service Remark Name"))
e.description = translate("<font color=\"red\">Please ensure the remark name is unique.</font>")
e.rmempty = false
return a

View File

@ -1,187 +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, "user", translate("User"), translate("Commonly used to distinguish you with other clients."))
e.optional=true
e.default = ""
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",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"))
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("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"
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

@ -4,10 +4,10 @@ XHR.poll(5, '<%=url([[admin]], [[services]], [[frp]], [[status]])%>', null,
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>';
var links = '<em><b><font color=green>Frp <%:RUNNING%></font></b></em>';
tb.innerHTML = links;
} else {
tb.innerHTML = '<em><b><font color=red><%:The Frp service is not running.%></font></b></em>';
tb.innerHTML = '<em><b><font color=red>Frp <%:NOT RUNNING%></font></b></em>';
}
}
}
@ -16,7 +16,6 @@ XHR.poll(5, '<%=url([[admin]], [[services]], [[frp]], [[status]])%>', null,
</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>

View File

@ -1,297 +1,290 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
msgid "Frp Setting"
msgstr "Frp 内网穿透"
msgid "Frp Status"
msgstr "Frp状态"
msgid "The Frp service is not running."
msgstr "Frp服务未运行"
msgid "The Frp service is running."
msgstr "Frp服务正在运行"
msgid "Frp is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet."
msgstr "Frp 是一个可用于内网穿透的高性能的反向代理应用。"
msgid "Global Setting"
msgstr "全局设置"
msgid "Basic Settings"
msgstr "基本设置"
msgid "Other Settings"
msgstr "其他设置"
msgid "Client Log"
msgstr "日志"
msgid "Enabled"
msgstr "启用"
msgid "Server"
msgstr "服务器"
msgid "Port"
msgstr "端口"
msgid "Token"
msgstr "令牌"
msgid "User"
msgstr "用户名"
msgid "Commonly used to distinguish you with other clients."
msgstr "通常用于区分你与其他客户端"
msgid "Time duration between server of frpc and frps mustn't exceed 15 minutes."
msgstr "frpc服务器与frps之间的时间间隔不得超过15分钟"
msgid "Vhost HTTP Port"
msgstr "HTTP穿透服务端口"
msgid "Vhost HTTPS Port"
msgstr "HTTPS穿透服务端口"
msgid "Exit program when first login failed"
msgstr "初始登录失败即退出程序"
msgid "TCP Stream Multiplexing"
msgstr "TCP端口复用"
msgid "decide if exit program when first login failed, otherwise continuous relogin to frps."
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 "协议类型"
msgid "Frp support kcp protocol since v0.12.0"
msgstr "从 v0.12.0 版本开始,底层通信协议支持选择 kcp 协议加速。"
msgid "TCP Protocol"
msgstr "TCP协议"
msgid "KCP Protocol"
msgstr "KCP协议"
msgid "Connect frps by HTTP PROXY"
msgstr "通过代理连接 frps"
msgid "frpc can connect frps using HTTP PROXY"
msgstr "frpc 支持通过 HTTP PROXY 和 frps 进行通信"
msgid "HTTP PROXY"
msgstr "HTTP代理"
msgid "Enable Connection Pool"
msgstr "启用连接池功能"
msgid "This feature is fit for a large number of short connections."
msgstr "适合有大量短连接请求时开启"
msgid "Connection Pool"
msgstr "指定预创建连接的数量"
msgid "Connections will be established in advance."
msgstr "frpc 会预先和服务端建立起指定数量的连接。"
msgid "Service registration interval"
msgstr "服务注册间隔"
msgid "0 means disable this feature, unit: min"
msgstr "0表示禁用定时注册功能单位分钟"
msgid "Log Level"
msgstr "日志记录等级"
msgid "Trace"
msgstr "追踪"
msgid "Debug"
msgstr "调试"
msgid "Info"
msgstr "信息"
msgid "Warning"
msgstr "警告"
msgid "Error"
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 "服务列表"
msgid "Service Remark Name"
msgstr "服务备注名"
msgid "Domain/Subdomain"
msgstr "域名/子域名"
msgid "Remote Port"
msgstr "远程主机端口"
msgid "Local Host Address"
msgstr "内网主机地址"
msgid "Local Host Port"
msgstr "内网主机端口"
msgid "Use Encryption"
msgstr "开启数据加密"
msgid "Use Compression"
msgstr "使用压缩"
msgid "Enable State"
msgstr "开启状态"
msgid "Frp Domain Config"
msgstr "Frp域名配置"
msgid "Config Frp Protocol"
msgstr "配置 Frp 协议参数"
msgid "Disable"
msgstr "关闭"
msgid "Frp Protocol Type"
msgstr "Frp 协议类型"
msgid "Domain Type"
msgstr "域名类型"
msgid "Custom Domains"
msgstr "自定义域名"
msgid "SubDomain"
msgstr "子域名"
msgid "Both the above two Domain types"
msgstr "同时使用2种域名"
msgid "If SubDomain is used, Custom Domains couldn't be subdomain or wildcard domain of the maindomain(subdomain_host)."
msgstr "如果服务端配置了主域名(subdomain_host),则自定义域名不能是属于主域名(subdomain_host) 的子域名或者泛域名。"
msgid "subdomain_host must be configured in server: frps in advance."
msgstr "使用子域名时,必须预先在服务端配置主域名(subdomain_host)参数。"
msgid "STCP Role"
msgstr "SFTP服务类型"
msgid "Use Plugin"
msgstr "使用插件"
msgid "If plugin is defined, local_ip and local_port is useless, plugin will handle connections got from frps."
msgstr "使用插件使用插件模式时,本地 IP 地址和端口无需配置,插件将会处理来自服务端的链接请求。"
msgid "STCP Screct Key"
msgstr "SFTP密钥"
msgid "STCP Server Name"
msgstr "SFTP服务名称"
msgid "Enable URL routing"
msgstr "启用 URL 路由"
msgid "Frp support forward http requests to different backward web services by url routing."
msgstr "Frp支持通过url路由将http请求转发到不同的反向web服务。"
msgid "Choose Plugin"
msgstr "选择插件"
msgid "Proxy Authentication"
msgstr "代理认证"
msgid "Other PCs could access the Internet through frpc's network by using http_proxy plugin."
msgstr "http proxy 插件,可以使其他机器通过 frpc 的网络访问互联网;开启身份验证之后需要用户名、密码才能连接到 HTTP 代理。"
msgid "HTTP Proxy UserName"
msgstr "HTTP 代理用户名"
msgid "HTTP Proxy Password"
msgstr "HTTP 代理密码"
msgid "Plugin Unix Sock Path"
msgstr "Unix Sock 插件路径"
msgid "Password protecting your web service"
msgstr "密码保护您的web服务"
msgid "HTTP UserName"
msgstr "HTTP 用户名"
msgid "HTTP PassWord"
msgstr "HTTP 密码"
msgid "Rewriting the Host Header"
msgstr "修改 Host Header"
msgid "Frp can rewrite http requests with a modified Host header."
msgstr "Frp可以用修改后的主机头重写http请求。"
msgid "Proxy-Protocol Version"
msgstr "Proxy-Protocol 版本"
msgid "Encrypted the communication between frpc and frps, will effectively prevent the traffic intercepted."
msgstr "将 frpc 与 frps 之间的通信内容加密传输,将会有效防止流量被拦截。"
msgid "The contents will be compressed to speed up the traffic forwarding speed, but this will consume some additional cpu resources."
msgstr "对传输内容进行压缩,加快流量转发速度,但是会额外消耗一些 cpu 资源。"
msgid "Http username and password are safety certification for http protocol."
msgstr "Http用户名和密码是Http协议的安全认证。"
msgid "Proxy Protocol to send user's real IP to local services."
msgstr "将用户的真实IP发送到本地服务的代理协议。"
msgid "STCP Server Name is Service Remark Name of STCP Server"
msgstr "STCP服务器别名"
msgid "<font color=\"red\">Please ensure the remark name is unique.</font>"
msgstr "<font color=\"red\">确保备注名唯一</font>"
msgid "Plugin_Local_Addr"
msgstr "插件本地地址(格式 IP:Port"
msgid "plugin_crt_path"
msgstr "插件证书路径"
msgid "plugin_key_path"
msgstr "插件私钥路径"
msgid "plugin_host_header_rewrite"
msgstr "插件 Host Header 重写"
msgid "plugin_header_X-From-Where"
msgstr "插件X-From-Where请求头"
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
msgid "Frp Setting"
msgstr "Frp 内网穿透"
msgid "NOT RUNNING"
msgstr "未运行"
msgid "RUNNING"
msgstr "运行中"
msgid "Frp is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet."
msgstr "Frp 是一个可用于内网穿透的高性能的反向代理应用。"
msgid "Basic Settings"
msgstr "基本设置"
msgid "Other Settings"
msgstr "其他设置"
msgid "Client Log"
msgstr "日志"
msgid "Enabled"
msgstr "启用"
msgid "Server"
msgstr "服务器"
msgid "Port"
msgstr "端口"
msgid "Token"
msgstr "令牌"
msgid "User"
msgstr "用户名"
msgid "Commonly used to distinguish you with other clients."
msgstr "通常用于区分你与其他客户端"
msgid "Time duration between server of frpc and frps mustn't exceed 15 minutes."
msgstr "frpc服务器与frps之间的时间间隔不得超过15分钟"
msgid "Vhost HTTP Port"
msgstr "HTTP 穿透服务端口"
msgid "Vhost HTTPS Port"
msgstr "HTTPS 穿透服务端口"
msgid "Exit program when first login failed"
msgstr "初始登录失败即退出程序"
msgid "TCP Stream Multiplexing"
msgstr "TCP 端口复用"
msgid "decide if exit program when first login failed, otherwise continuous relogin to frps."
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 "协议类型"
msgid "Frp support kcp protocol since v0.12.0"
msgstr "从 v0.12.0 版本开始,底层通信协议支持选择 kcp 协议加速。"
msgid "TCP Protocol"
msgstr "TCP 协议"
msgid "KCP Protocol"
msgstr "KCP 协议"
msgid "Connect frps by HTTP PROXY"
msgstr "通过代理连接 frps"
msgid "frpc can connect frps using HTTP PROXY"
msgstr "frpc 支持通过 HTTP PROXY 和 frps 进行通信"
msgid "HTTP PROXY"
msgstr "HTTP 代理"
msgid "Enable Connection Pool"
msgstr "启用连接池功能"
msgid "This feature is fit for a large number of short connections."
msgstr "适合有大量短连接请求时开启"
msgid "Connection Pool"
msgstr "指定预创建连接的数量"
msgid "Connections will be established in advance."
msgstr "frpc 会预先和服务端建立起指定数量的连接。"
msgid "Service registration interval"
msgstr "服务注册间隔"
msgid "0 means disable this feature, unit: min"
msgstr "0表示禁用定时注册功能单位分钟"
msgid "Log Level"
msgstr "日志记录等级"
msgid "Trace"
msgstr "追踪"
msgid "Debug"
msgstr "调试"
msgid "Info"
msgstr "信息"
msgid "Warning"
msgstr "警告"
msgid "Error"
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 "服务列表"
msgid "Service Remark Name"
msgstr "服务备注名"
msgid "Domain/Subdomain"
msgstr "域名/子域名"
msgid "Remote Port"
msgstr "远程主机端口"
msgid "Local Host Address"
msgstr "内网主机地址"
msgid "Local Host Port"
msgstr "内网主机端口"
msgid "Use Encryption"
msgstr "开启数据加密"
msgid "Use Compression"
msgstr "使用压缩"
msgid "Enable State"
msgstr "开启状态"
msgid "Frp Domain Config"
msgstr "Frp 域名配置"
msgid "Config Frp Protocol"
msgstr "配置 Frp 协议参数"
msgid "Disable"
msgstr "关闭"
msgid "Frp Protocol Type"
msgstr "Frp 协议类型"
msgid "Domain Type"
msgstr "域名类型"
msgid "Custom Domains"
msgstr "自定义域名"
msgid "SubDomain"
msgstr "子域名"
msgid "Both the above two Domain types"
msgstr "同时使用2种域名"
msgid "If SubDomain is used, Custom Domains couldn't be subdomain or wildcard domain of the maindomain(subdomain_host)."
msgstr "如果服务端配置了主域名(subdomain_host),则自定义域名不能是属于主域名(subdomain_host) 的子域名或者泛域名。"
msgid "subdomain_host must be configured in server: frps in advance."
msgstr "使用子域名时,必须预先在服务端配置主域名(subdomain_host)参数。"
msgid "STCP Role"
msgstr "SFTP 服务类型"
msgid "Use Plugin"
msgstr "使用插件"
msgid "If plugin is defined, local_ip and local_port is useless, plugin will handle connections got from frps."
msgstr "使用插件使用插件模式时,本地 IP 地址和端口无需配置,插件将会处理来自服务端的链接请求。"
msgid "STCP Screct Key"
msgstr "SFTP 密钥"
msgid "STCP Server Name"
msgstr "SFTP 服务名称"
msgid "Enable URL routing"
msgstr "启用 URL 路由"
msgid "Frp support forward http requests to different backward web services by url routing."
msgstr "Frp 支持通过url路由将http请求转发到不同的反向web服务。"
msgid "Choose Plugin"
msgstr "选择插件"
msgid "Proxy Authentication"
msgstr "代理认证"
msgid "Other PCs could access the Internet through frpc's network by using http_proxy plugin."
msgstr "http proxy 插件,可以使其他机器通过 frpc 的网络访问互联网;开启身份验证之后需要用户名、密码才能连接到 HTTP 代理。"
msgid "HTTP Proxy UserName"
msgstr "HTTP 代理用户名"
msgid "HTTP Proxy Password"
msgstr "HTTP 代理密码"
msgid "Plugin Unix Sock Path"
msgstr "Unix Sock 插件路径"
msgid "Password protecting your web service"
msgstr "密码保护您的web服务"
msgid "HTTP UserName"
msgstr "HTTP 用户名"
msgid "HTTP PassWord"
msgstr "HTTP 密码"
msgid "Rewriting the Host Header"
msgstr "修改 Host Header"
msgid "Frp can rewrite http requests with a modified Host header."
msgstr "Frp可以用修改后的主机头重写http请求。"
msgid "Proxy-Protocol Version"
msgstr "Proxy-Protocol 版本"
msgid "Encrypted the communication between frpc and frps, will effectively prevent the traffic intercepted."
msgstr "将 frpc 与 frps 之间的通信内容加密传输,将会有效防止流量被拦截。"
msgid "The contents will be compressed to speed up the traffic forwarding speed, but this will consume some additional cpu resources."
msgstr "对传输内容进行压缩,加快流量转发速度,但是会额外消耗一些 cpu 资源。"
msgid "Http username and password are safety certification for http protocol."
msgstr "Http用户名和密码是Http协议的安全认证。"
msgid "Proxy Protocol to send user's real IP to local services."
msgstr "将用户的真实IP发送到本地服务的代理协议。"
msgid "STCP Server Name is Service Remark Name of STCP Server"
msgstr "STCP服务器别名"
msgid "<font color=\"red\">Please ensure the remark name is unique.</font>"
msgstr "<font color=\"red\">确保备注名唯一</font>"
msgid "Plugin_Local_Addr"
msgstr "插件本地地址(格式 IP:Port"
msgid "plugin_crt_path"
msgstr "插件证书路径"
msgid "plugin_key_path"
msgstr "插件私钥路径"
msgid "plugin_host_header_rewrite"
msgstr "插件 Host Header 重写"
msgid "plugin_header_X-From-Where"
msgstr "插件X-From-Where请求头"