luci-app-ssr-plus: add self-signed certificate for v2ray/trojan

This commit is contained in:
CN_SZTL 2020-02-14 14:11:03 +08:00
parent e3d74ffcf7
commit cf3beed725
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
4 changed files with 77 additions and 3 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-ssr-plus
PKG_RELEASE:=139
PKG_RELEASE:=140
PKG_VERSION:=1
define Package/$(PKG_NAME)/config

View File

@ -8,6 +8,7 @@ local fs = require "nixio.fs"
local sys = require "luci.sys"
local sid = arg[1]
local uuid = luci.sys.exec("cat /proc/sys/kernel/random/uuid")
local http = require "luci.http"
local function isKcptun(file)
if not fs.access(file, "rwx", "rx", "rx") then
@ -165,11 +166,11 @@ o.rmempty = true
o:depends("type", "ss")
-- Shadowsocks Plugin
o = s:option(Value, "plugin", "Plugin")
o = s:option(Value, "plugin", translate("Plugin"))
o.rmempty = true
o:depends("type", "ss")
o = s:option(Value, "plugin_opts", "Plugin Opts")
o = s:option(Value, "plugin_opts", translate("Plugin Opts"))
o.rmempty = true
o:depends("type", "ss")
@ -366,6 +367,54 @@ o.rmempty = true
o.default = "8"
o:depends("mux", "1")
-- [[ Cert ]]--
o = s:option(Flag, "certificate", translate("Self-signed Certificate"))
o.rmempty = true
o.default = "0"
o:depends("type", "trojan")
o:depends("type", "v2ray")
o.description = translate("If you have a self-signed certificate,please check the box")
o = s:option(DummyValue, "upload", translate("Upload"))
o.template = "shadowsocksr/certupload"
o:depends("certificate", 1)
cert_dir = "/etc/ssl/private/"
local path
http.setfilehandler(
function(meta, chunk, eof)
if not fd then
if (not meta) or (not meta.name) or (not meta.file) then return end
fd = nixio.open(cert_dir .. meta.file, "w")
if not fd then
path = translate("Create upload file error.")
return
end
end
if chunk and fd then
fd:write(chunk)
end
if eof and fd then
fd:close()
fd = nil
path = '/etc/ssl/private/' .. meta.file .. ''
end
end
)
if luci.http.formvalue("upload") then
local f = luci.http.formvalue("ulfile")
if #f <= 0 then
path = translate("No specify upload file.")
end
end
o = s:option(Value, "certpath", translate("Current Certificate Path"))
o:depends("certificate", 1)
o:value("/etc/ssl/private/")
o.description = translate("Please confirm the current certificate path")
o.default = "/etc/ssl/private/"
o = s:option(Flag, "fast_open", translate("TCP Fast Open"))
o.rmempty = true
o.default = "0"

View File

@ -0,0 +1,4 @@
<%+cbi/valueheader%>
<input class="cbi-input-file" style="width: 400px" type="file" id="ulfile" name="ulfile" />
<input type="submit" class="cbi-button cbi-input-apply" name="upload" value="<%:Upload%>" />
<%+cbi/valuefooter%>

View File

@ -794,6 +794,27 @@ msgstr "SOCKS(4/5)代理"
msgid "Enable SOCKS Proxy"
msgstr "启用 SOCKS 代理"
msgid "Self-signed Certificate"
msgstr "自签证书"
msgid "If you have a self-signed certificate,please check the box"
msgstr "如果你使用自签证书,请选择"
msgid "upload"
msgstr "上传"
msgid "Upload"
msgstr "上传"
msgid "No specify upload file."
msgstr "没有上传证书"
msgid "Current Certificate Path"
msgstr "当前证书路径"
msgid "Please confirm the current certificate path"
msgstr "请选择确认所传证书,证书不正确将无法运行"
#~ msgid "ShadowSocksR Client"
#~ msgstr "ShadowSocksR 客户端"