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,12 +5,12 @@ 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()
function act_status()
local e = {}
e.running = luci.sys.call("pidof frpc > /dev/null") == 0
luci.http.prepare_content("application/json")

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

@ -3,25 +3,34 @@ 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 = Map("frp")
a.title = translate("Frp Domain Config")
a.redirect = i.build_url("admin","services","frp")
t=a:section(NamedSection,arg[1],"frp",translate("Config Frp Protocol"))
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"))
@ -29,24 +38,33 @@ 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.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 = 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"))
luci.sys.net.ipv4_hints(function(x,d)
e:value(x,"%s (%s)"%{x,d})
@ -56,77 +74,109 @@ 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 = 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 = 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: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.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 = 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.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 = 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: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 = 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.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:depends("https_plugin","https2http")
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:depends("https_plugin","https2http")
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"))
@ -135,12 +185,19 @@ 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,25 +1,18 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
msgid "Frp Setting"
msgstr "Frp 内网穿透"
msgid "Frp Status"
msgstr "Frp状态"
msgid "NOT RUNNING"
msgstr "未运行"
msgid "The Frp service is not running."
msgstr "Frp服务未运行"
msgid "The Frp service is running."
msgstr "Frp服务正在运行"
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 "Global Setting"
msgstr "全局设置"
msgid "Basic Settings"
msgstr "基本设置"