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

This commit is contained in:
coolsnowwolf 2020-02-14 12:56:26 +08:00
parent d5cd053f35
commit 3622accc8e
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
include $(INCLUDE_DIR)/package.mk

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

@ -546,3 +546,24 @@ msgstr "插件"
msgid "Plugin Opts"
msgstr "插件参数"
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 "请选择确认所传证书,证书不正确将无法运行"