From 45e68bf52786c033a68d726e6cd79406cbf08baf Mon Sep 17 00:00:00 2001 From: CN_SZTL Date: Sun, 19 Jul 2020 17:27:49 +0800 Subject: [PATCH] luci-app-passwall: sync with upstream source --- package/lienol/luci-app-passwall/Makefile | 2 +- .../luasrc/controller/passwall.lua | 36 +- .../model/cbi/passwall/api/gen_v2ray.lua | 5 +- .../luasrc/model/cbi/passwall/node_config.lua | 127 ++-- .../model/cbi/passwall/server/api/trojan.lua | 5 - .../model/cbi/passwall/server/api/v2ray.lua | 49 +- .../luasrc/model/cbi/passwall/server/user.lua | 56 +- .../view/passwall/node_list/link_add_node.htm | 40 +- .../passwall/node_list/link_share_man.htm | 604 ++++++++++++++++++ .../luci-app-passwall/po/zh_Hans/passwall.po | 38 +- 10 files changed, 807 insertions(+), 155 deletions(-) create mode 100644 package/lienol/luci-app-passwall/luasrc/view/passwall/node_list/link_share_man.htm diff --git a/package/lienol/luci-app-passwall/Makefile b/package/lienol/luci-app-passwall/Makefile index 5a29e8b106..d2ff496ecb 100644 --- a/package/lienol/luci-app-passwall/Makefile +++ b/package/lienol/luci-app-passwall/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall PKG_VERSION:=3.9 -PKG_RELEASE:=18 +PKG_RELEASE:=19 PKG_DATE:=20200717 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) diff --git a/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua b/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua index c37c07e3e4..bb91db2301 100644 --- a/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua +++ b/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua @@ -37,6 +37,9 @@ function index() entry({"admin", "vpn", "passwall", "server_user_status"}, call("server_user_status")).leaf = true entry({"admin", "vpn", "passwall", "server_get_log"}, call("server_get_log")).leaf = true entry({"admin", "vpn", "passwall", "server_clear_log"}, call("server_clear_log")).leaf = true + entry({"admin", "vpn", "passwall", "link_append_temp"}, call("link_append_temp")).leaf = true + entry({"admin", "vpn", "passwall", "link_load_temp"}, call("link_load_temp")).leaf = true + entry({"admin", "vpn", "passwall", "link_clear_temp"}, call("link_clear_temp")).leaf = true entry({"admin", "vpn", "passwall", "link_add_node"}, call("link_add_node")).leaf = true entry({"admin", "vpn", "passwall", "get_log"}, call("get_log")).leaf = true entry({"admin", "vpn", "passwall", "clear_log"}, call("clear_log")).leaf = true @@ -82,9 +85,38 @@ function hide_menu() luci.http.redirect(luci.dispatcher.build_url("admin", "status", "overview")) end -function link_add_node() +function link_append_temp() local link = luci.http.formvalue("link") - luci.sys.call('rm -f /tmp/links.conf && echo "' .. link .. '" >> /tmp/links.conf') + local lfile = "/tmp/links.conf" + local ret, ldata="empty", {} + luci.sys.call('touch ' .. lfile .. ' && echo \'' .. link .. '\' >> ' .. lfile) + ret = luci.sys.exec([[awk -F'://' 'BEGIN{ all=0 } /.{2,9}:\/\/.{4,}$/ {gsub(/:\/\/.*$/,""); arr[$0]++; all++ } END { for(typ in arr) { printf("%s: %d, ", typ, arr[typ]) }; printf("\ntotal: %d", all) }' ]] .. lfile) + luci.http.prepare_content("application/json") + luci.http.write_json({counter = ret}) +end + +function link_load_temp() + local lfile = "/tmp/links.conf" + local ret, ldata="empty", {} + ldata[#ldata+1] = nixio.fs.readfile(lfile) or "_nofile_" + if ldata[1] == "" then + ldata[1] = "_nodata_" + else + ret = luci.sys.exec([[awk -F'://' 'BEGIN{ all=0 } /.{2,9}:\/\/.{4,}$/ {gsub(/:\/\/.*$/,""); arr[$0]++; all++ } END { for(typ in arr) { printf("%s: %d, ", typ, arr[typ]) }; printf("\ntotal: %d", all) }' ]] .. lfile) + end + luci.http.prepare_content("application/json") + luci.http.write_json({counter = ret, data = ldata}) +end + +function link_clear_temp() + local lfile = "/tmp/links.conf" + luci.sys.call('cat /dev/null > ' .. lfile) +end + +function link_add_node() + local lfile = "/tmp/links.conf" + local link = luci.http.formvalue("link") + luci.sys.call('echo \'' .. link .. '\' >> ' .. lfile) luci.sys.call("lua /usr/share/passwall/subscribe.lua add log") end diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua index 1da513ba53..d17549f924 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua @@ -48,7 +48,7 @@ local function gen_outbound(node, tag) concurrency = (node.mux_concurrency) and tonumber(node.mux_concurrency) or 8 }, -- 底层传输配置 - streamSettings = (node.protocol == "vmess") and { + streamSettings = (node.protocol == "vmess" or node.protocol == "socks" or node.protocol == "shadowsocks") and { network = node.transport, security = node.stream_security, tlsSettings = (node.stream_security == "tls") and { @@ -56,8 +56,7 @@ local function gen_outbound(node, tag) serverName = node.tls_serverName, allowInsecure = (node.tls_allowInsecure == "1") and true or false } or nil, - tcpSettings = (node.transport == "tcp" and - node.protocol ~= "socks") and { + tcpSettings = (node.transport == "tcp" and node.protocol ~= "socks") and { header = { type = node.tcp_guise, request = { diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_config.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_config.lua index 6aac3202f8..be5a53e73b 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_config.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_config.lua @@ -10,8 +10,7 @@ local function get_customed_path(e) end local function is_finded(e) - return luci.sys.exec("find /usr/*bin %s -iname %s -type f" % - {get_customed_path(e), e}) ~= "" and true or false + return luci.sys.exec("find /usr/*bin %s -iname %s -type f" % {get_customed_path(e), e}) ~= "" and true or false end local function is_installed(e) return ipkg.installed(e) end @@ -73,13 +72,17 @@ s = m:section(NamedSection, arg[1], "nodes", "") s.addremove = false s.dynamic = false +share = s:option(DummyValue, "share_url", translate("Share Current")) +share.rawhtml = true +share.template = "passwall/node_list/link_share_man" +share.value = arg[1] + remarks = s:option(Value, "remarks", translate("Node Remarks")) remarks.default = translate("Remarks") remarks.rmempty = false type = s:option(ListValue, "type", translate("Type")) -if ((is_installed("redsocks2") or is_finded("redsocks2")) or - (is_installed("ipt2socks") or is_finded("ipt2socks"))) then +if is_installed("ipt2socks") or is_finded("ipt2socks") then type:value("Socks", translate("Socks")) end if is_finded("ss-redir") then @@ -145,8 +148,7 @@ for k, v in pairs(nodes_table) do default_node:value(v.id, v.remarks) end default_node:depends("protocol", "_shunt") -- Brook协议 -brook_protocol = s:option(ListValue, "brook_protocol", - translate("Brook Protocol")) +brook_protocol = s:option(ListValue, "brook_protocol", translate("Brook Protocol")) brook_protocol:value("client", translate("Brook")) brook_protocol:value("wsclient", translate("WebSocket")) brook_protocol:depends("type", "Brook") @@ -213,28 +215,23 @@ password:depends("protocol", "http") password:depends("protocol", "socks") password:depends("protocol", "shadowsocks") -ss_encrypt_method = s:option(ListValue, "ss_encrypt_method", - translate("Encrypt Method")) +ss_encrypt_method = s:option(ListValue, "ss_encrypt_method", translate("Encrypt Method")) for a, t in ipairs(ss_encrypt_method_list) do ss_encrypt_method:value(t) end ss_encrypt_method:depends("type", "SS") -ssr_encrypt_method = s:option(ListValue, "ssr_encrypt_method", - translate("Encrypt Method")) +ssr_encrypt_method = s:option(ListValue, "ssr_encrypt_method", translate("Encrypt Method")) for a, t in ipairs(ssr_encrypt_method_list) do ssr_encrypt_method:value(t) end ssr_encrypt_method:depends("type", "SSR") -security = s:option(ListValue, "security", - translate("Encrypt Method")) +security = s:option(ListValue, "security", translate("Encrypt Method")) for a, t in ipairs(security_list) do security:value(t) end security:depends("protocol", "vmess") -v_ss_encrypt_method = s:option(ListValue, "v_ss_encrypt_method", - translate("Encrypt Method")) +v_ss_encrypt_method = s:option(ListValue, "v_ss_encrypt_method", translate("Encrypt Method")) for a, t in ipairs(v_ss_encrypt_method_list) do v_ss_encrypt_method:value(t) end v_ss_encrypt_method:depends("protocol", "shadowsocks") -ss_ota = s:option(Flag, "ss_ota", translate("OTA"), translate( - "When OTA is enabled, V2Ray will reject connections that are not OTA enabled. This option is invalid when using AEAD encryption.")) +ss_ota = s:option(Flag, "ss_ota", translate("OTA"), translate("When OTA is enabled, V2Ray will reject connections that are not OTA enabled. This option is invalid when using AEAD encryption.")) ss_ota.default = "0" ss_ota:depends("protocol", "shadowsocks") @@ -258,8 +255,7 @@ timeout.default = 300 timeout:depends("type", "SS") timeout:depends("type", "SSR") -tcp_fast_open = s:option(ListValue, "tcp_fast_open", translate("TCP Fast Open"), - translate("Need node support required")) +tcp_fast_open = s:option(ListValue, "tcp_fast_open", translate("TCP Fast Open"), translate("Need node support required")) tcp_fast_open:value("false") tcp_fast_open:value("true") tcp_fast_open:depends("type", "SS") @@ -278,9 +274,7 @@ ss_plugin_opts:depends("ss_plugin", "v2ray-plugin") ss_plugin_opts:depends("ss_plugin", "obfs-local") use_kcp = s:option(Flag, "use_kcp", translate("Use Kcptun"), - "" .. translate( - "Please confirm whether the Kcptun is installed. If not, please go to Rule Update download installation.") .. - "") + "" .. translate("Please confirm whether the Kcptun is installed. If not, please go to Rule Update download installation.") .. "") use_kcp.default = 0 use_kcp:depends("type", "SS") use_kcp:depends("type", "SSR") @@ -294,34 +288,27 @@ kcp_port = s:option(Value, "kcp_port", translate("Kcptun Port")) kcp_port.datatype = "port" kcp_port:depends("use_kcp", "1") -kcp_opts = s:option(TextValue, "kcp_opts", translate("Kcptun Config"), - translate( - "--crypt aes192 --key abc123 --mtu 1350 --sndwnd 128 --rcvwnd 1024 --mode fast")) -kcp_opts.placeholder = - "--crypt aes192 --key abc123 --mtu 1350 --sndwnd 128 --rcvwnd 1024 --mode fast" +kcp_opts = s:option(TextValue, "kcp_opts", translate("Kcptun Config"), translate("--crypt aes192 --key abc123 --mtu 1350 --sndwnd 128 --rcvwnd 1024 --mode fast")) +kcp_opts.placeholder = "--crypt aes192 --key abc123 --mtu 1350 --sndwnd 128 --rcvwnd 1024 --mode fast" kcp_opts:depends("use_kcp", "1") vmess_id = s:option(Value, "vmess_id", translate("ID")) vmess_id.password = true vmess_id:depends("protocol", "vmess") -alter_id = s:option(Value, "alter_id", - translate("Alter ID")) +alter_id = s:option(Value, "alter_id", translate("Alter ID")) alter_id:depends("protocol", "vmess") -vmess_level = - s:option(Value, "vmess_level", translate("User Level")) +vmess_level = s:option(Value, "vmess_level", translate("User Level")) vmess_level.default = 1 vmess_level:depends("protocol", "vmess") -stream_security = s:option(ListValue, "stream_security", - translate("Transport Layer Encryption"), - translate( - 'Whether or not transport layer encryption is enabled, the supported options are "none" for unencrypted (default) and "TLS" for using TLS.')) +stream_security = s:option(ListValue, "stream_security", translate("Transport Layer Encryption"), translate('Whether or not transport layer encryption is enabled, the supported options are "none" for unencrypted (default) and "TLS" for using TLS.')) stream_security:value("none", "none") stream_security:value("tls", "tls") stream_security.default = "tls" stream_security:depends("protocol", "vmess") +stream_security:depends("protocol", "socks") stream_security:depends("protocol", "shadowsocks") stream_security:depends("type", "Trojan") stream_security:depends("type", "Trojan-Go") @@ -333,13 +320,11 @@ stream_security.validate = function(self, value) end -- [[ TLS部分 ]] -- - tls_sessionTicket = s:option(Flag, "tls_sessionTicket", translate("Session Ticket")) tls_sessionTicket.default = "0" tls_sessionTicket:depends("stream_security", "tls") -- [[ Trojan TLS ]]-- - trojan_force_fp = s:option(ListValue, "fingerprint", translate("Finger Print")) for a, t in ipairs(force_fp) do trojan_force_fp:value(t) end trojan_force_fp.default = "firefox" @@ -348,13 +333,11 @@ trojan_force_fp:depends({ type = "Trojan-Go", stream_security = "tls" }) tls_serverName = s:option(Value, "tls_serverName", translate("Domain")) tls_serverName:depends("stream_security", "tls") -tls_allowInsecure = s:option(Flag, "tls_allowInsecure", translate("allowInsecure"), translate( - "Whether unsafe connections are allowed. When checked, V2Ray does not check the validity of the TLS certificate provided by the remote host.")) +tls_allowInsecure = s:option(Flag, "tls_allowInsecure", translate("allowInsecure"), translate("Whether unsafe connections are allowed. When checked, V2Ray does not check the validity of the TLS certificate provided by the remote host.")) tls_allowInsecure.default = "0" tls_allowInsecure:depends("stream_security", "tls") -- [[ Trojan Cert ]]-- - trojan_cert_path = s:option(Value, "trojan_cert_path", translate("Trojan Cert Path")) trojan_cert_path.default = "" trojan_cert_path:depends({ stream_security = "tls", tls_allowInsecure = false }) @@ -397,12 +380,13 @@ transport:value("h2", "HTTP/2") transport:value("ds", "DomainSocket") transport:value("quic", "QUIC") transport:depends("protocol", "vmess") +transport:depends("protocol", "socks") +transport:depends("protocol", "shadowsocks") --[[ ss_transport = s:option(ListValue, "ss_transport", translate("Transport")) ss_transport:value("ws", "WebSocket") ss_transport:value("h2", "HTTP/2") -ss_transport:value("ws", "WebSocket") ss_transport:value("h2+ws", "HTTP/2 & WebSocket") ss_transport:depends("protocol", "shadowsocks") ]]-- @@ -410,27 +394,22 @@ ss_transport:depends("protocol", "shadowsocks") -- [[ TCP部分 ]]-- -- TCP伪装 -tcp_guise = s:option(ListValue, "tcp_guise", - translate("Camouflage Type")) +tcp_guise = s:option(ListValue, "tcp_guise", translate("Camouflage Type")) tcp_guise:value("none", "none") tcp_guise:value("http", "http") tcp_guise:depends("transport", "tcp") -- HTTP域名 -tcp_guise_http_host = s:option(DynamicList, "tcp_guise_http_host", - translate("HTTP Host")) +tcp_guise_http_host = s:option(DynamicList, "tcp_guise_http_host", translate("HTTP Host")) tcp_guise_http_host:depends("tcp_guise", "http") -- HTTP路径 -tcp_guise_http_path = s:option(DynamicList, "tcp_guise_http_path", - translate("HTTP Path")) +tcp_guise_http_path = s:option(DynamicList, "tcp_guise_http_path", translate("HTTP Path")) tcp_guise_http_path:depends("tcp_guise", "http") -- [[ mKCP部分 ]]-- -mkcp_guise = s:option(ListValue, "mkcp_guise", - translate("Camouflage Type"), translate( - '
none: default, no masquerade, data sent is packets with no characteristics.
srtp: disguised as an SRTP packet, it will be recognized as video call data (such as FaceTime).
utp: packets disguised as uTP will be recognized as bittorrent downloaded data.
wechat-video: packets disguised as WeChat video calls.
dtls: disguised as DTLS 1.2 packet.
wireguard: disguised as a WireGuard packet. (not really WireGuard protocol)')) +mkcp_guise = s:option(ListValue, "mkcp_guise", translate("Camouflage Type"), translate('
none: default, no masquerade, data sent is packets with no characteristics.
srtp: disguised as an SRTP packet, it will be recognized as video call data (such as FaceTime).
utp: packets disguised as uTP will be recognized as bittorrent downloaded data.
wechat-video: packets disguised as WeChat video calls.
dtls: disguised as DTLS 1.2 packet.
wireguard: disguised as a WireGuard packet. (not really WireGuard protocol)')) for a, t in ipairs(header_type_list) do mkcp_guise:value(t) end mkcp_guise:depends("transport", "mkcp") @@ -440,28 +419,22 @@ mkcp_mtu:depends("transport", "mkcp") mkcp_tti = s:option(Value, "mkcp_tti", translate("KCP TTI")) mkcp_tti:depends("transport", "mkcp") -mkcp_uplinkCapacity = s:option(Value, "mkcp_uplinkCapacity", - translate("KCP uplinkCapacity")) +mkcp_uplinkCapacity = s:option(Value, "mkcp_uplinkCapacity", translate("KCP uplinkCapacity")) mkcp_uplinkCapacity:depends("transport", "mkcp") -mkcp_downlinkCapacity = s:option(Value, "mkcp_downlinkCapacity", - translate("KCP downlinkCapacity")) +mkcp_downlinkCapacity = s:option(Value, "mkcp_downlinkCapacity", translate("KCP downlinkCapacity")) mkcp_downlinkCapacity:depends("transport", "mkcp") -mkcp_congestion = s:option(Flag, "mkcp_congestion", - translate("KCP Congestion")) +mkcp_congestion = s:option(Flag, "mkcp_congestion", translate("KCP Congestion")) mkcp_congestion:depends("transport", "mkcp") -mkcp_readBufferSize = s:option(Value, "mkcp_readBufferSize", - translate("KCP readBufferSize")) +mkcp_readBufferSize = s:option(Value, "mkcp_readBufferSize", translate("KCP readBufferSize")) mkcp_readBufferSize:depends("transport", "mkcp") -mkcp_writeBufferSize = s:option(Value, "mkcp_writeBufferSize", - translate("KCP writeBufferSize")) +mkcp_writeBufferSize = s:option(Value, "mkcp_writeBufferSize", translate("KCP writeBufferSize")) mkcp_writeBufferSize:depends("transport", "mkcp") -- [[ WebSocket部分 ]]-- - ws_host = s:option(Value, "ws_host", translate("WebSocket Host")) ws_host:depends("transport", "ws") ws_host:depends("ss_transport", "ws") @@ -475,7 +448,6 @@ ws_path:depends("trojan_transport", "h2+ws") ws_path:depends("trojan_transport", "ws") -- [[ HTTP/2部分 ]]-- - h2_host = s:option(Value, "h2_host", translate("HTTP/2 Host")) h2_host:depends("transport", "h2") h2_host:depends("ss_transport", "h2") @@ -489,30 +461,24 @@ h2_path:depends("trojan_transport", "h2+ws") h2_path:depends("trojan_transport", "h2") -- [[ DomainSocket部分 ]]-- - -ds_path = s:option(Value, "ds_path", "Path", translate( - "A legal file path. This file must not exist before running V2Ray.")) +ds_path = s:option(Value, "ds_path", "Path", translate("A legal file path. This file must not exist before running V2Ray.")) ds_path:depends("transport", "ds") -- [[ QUIC部分 ]]-- -quic_security = s:option(ListValue, "quic_security", - translate("Encrypt Method")) +quic_security = s:option(ListValue, "quic_security", translate("Encrypt Method")) quic_security:value("none") quic_security:value("aes-128-gcm") quic_security:value("chacha20-poly1305") quic_security:depends("transport", "quic") -quic_key = s:option(Value, "quic_key", - translate("Encrypt Method") .. translate("Key")) +quic_key = s:option(Value, "quic_key", translate("Encrypt Method") .. translate("Key")) quic_key:depends("transport", "quic") -quic_guise = s:option(ListValue, "quic_guise", - translate("Camouflage Type")) +quic_guise = s:option(ListValue, "quic_guise", translate("Camouflage Type")) for a, t in ipairs(header_type_list) do quic_guise:value(t) end quic_guise:depends("transport", "quic") -- [[ Trojan-Go Shadowsocks2 ]] -- - ss_aead = s:option(Flag, "ss_aead", translate("Shadowsocks2")) ss_aead:depends("type", "Trojan-Go") ss_aead.default = "0" @@ -540,33 +506,24 @@ mux_concurrency:depends("mux", "1") -- [[ 当作为TCP节点时,是否同时开启socks代理 ]]-- --[[ -tcp_socks = s:option(Flag, "tcp_socks", translate("TCP Open Socks"), - translate( - "When using this TCP node, whether to open the socks proxy at the same time")) +tcp_socks = s:option(Flag, "tcp_socks", translate("TCP Open Socks"), translate("When using this TCP node, whether to open the socks proxy at the same time")) tcp_socks.default = 0 tcp_socks:depends("type", "V2ray") -tcp_socks_port = s:option(Value, "tcp_socks_port", - "Socks " .. translate("Port"), - translate("Do not conflict with other ports")) +tcp_socks_port = s:option(Value, "tcp_socks_port", "Socks " .. translate("Port"), translate("Do not conflict with other ports")) tcp_socks_port.datatype = "port" tcp_socks_port.default = 1080 tcp_socks_port:depends("tcp_socks", "1") -tcp_socks_auth = s:option(ListValue, "tcp_socks_auth", - translate("Socks for authentication"), - translate( - 'Socks protocol authentication, support anonymous and password.')) +tcp_socks_auth = s:option(ListValue, "tcp_socks_auth", translate("Socks for authentication"), translate('Socks protocol authentication, support anonymous and password.')) tcp_socks_auth:value("noauth", translate("anonymous")) tcp_socks_auth:value("password", translate("User Password")) tcp_socks_auth:depends("tcp_socks", "1") -tcp_socks_auth_username = s:option(Value, "tcp_socks_auth_username", - "Socks " .. translate("Username")) +tcp_socks_auth_username = s:option(Value, "tcp_socks_auth_username", "Socks " .. translate("Username")) tcp_socks_auth_username:depends("tcp_socks_auth", "password") -tcp_socks_auth_password = s:option(Value, "tcp_socks_auth_password", - "Socks " .. translate("Password")) +tcp_socks_auth_password = s:option(Value, "tcp_socks_auth_password", "Socks " .. translate("Password")) tcp_socks_auth_password:depends("tcp_socks_auth", "password") --]] diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/trojan.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/trojan.lua index a32319fcf2..e9a5734ca0 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/trojan.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/trojan.lua @@ -30,11 +30,6 @@ function gen_config(user) udp_timeout = 60, disable_http_check = true, tcp = { - mux = (user.mux == "1") and { - enabled = true, - concurrency = tonumber(user.mux_concurrency), - idle_timeout = 60, - } or nil, transport_plugin = user.stream_security == "none" and user.trojan_transport == "original" and { enabled = user.plugin_type ~= nil, type = user.plugin_type or "plaintext", diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/v2ray.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/v2ray.lua index bc6023565b..a0d8e5250c 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/v2ray.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/v2ray.lua @@ -14,7 +14,7 @@ function gen_config(user) for i = 1, #user.vmess_id do clients[i] = { id = user.vmess_id[i], - level = tonumber(user.vmess_level), + level = tonumber(user.level), alterId = tonumber(user.alter_id) } end @@ -42,12 +42,21 @@ function gen_config(user) } elseif user.protocol == "shadowsocks" then settings = { - method = user.ss_encrypt_method, + method = user.v_ss_encrypt_method, password = user.password, - level = tonumber(user.vmess_level) or 1, + level = tonumber(user.level) or 1, network = user.ss_network or "TCP,UDP", ota = (user.ss_ota == '1') and true or false } + elseif user.protocol == "mtproto" then + settings = { + users = { + { + level = tonumber(user.level) or 1, + secret = (user.password == nil) and "" or user.password + } + } + } end if user.accept_lan == nil or user.accept_lan == "0" then @@ -74,7 +83,7 @@ function gen_config(user) concurrency = (node.mux_concurrency) and tonumber(node.mux_concurrency) or 8 }, -- 底层传输配置 - streamSettings = (node.protocol == "vmess") and { + streamSettings = { network = node.transport, security = node.stream_security, tlsSettings = (node.stream_security == "tls") and { @@ -122,7 +131,7 @@ function gen_config(user) key = node.quic_key, header = {type = node.quic_guise} } or nil - } or nil, + }, settings = { vnext = (node.protocol == "vmess") and { { @@ -132,7 +141,7 @@ function gen_config(user) { id = node.vmess_id, alterId = tonumber(node.alter_id), - level = tonumber(node.vmess_level), + level = tonumber(node.level), security = node.security } } @@ -162,7 +171,7 @@ function gen_config(user) local config = { log = { - -- error = "/var/log/v2ray.log", + -- error = "/var/etc/passwall_server/log/" .. user[".name"] .. ".log", loglevel = "warning" }, -- 传入连接 @@ -171,14 +180,12 @@ function gen_config(user) listen = (user.bind_local == "1") and "127.0.0.1" or nil, port = tonumber(user.port), protocol = user.protocol, - -- 底层传输配置 settings = settings, - streamSettings = (user.protocol == "vmess") and { + streamSettings = { network = user.transport, security = (user.stream_security == 'tls') and "tls" or "none", tlsSettings = (user.stream_security == 'tls') and { disableSessionResumption = user.sessionTicket ~= "1" and true or false, - -- serverName = (user.tls_serverName), allowInsecure = false, disableSystemRoot = false, certificates = { @@ -209,22 +216,22 @@ function gen_config(user) writeBufferSize = tonumber(user.mkcp_writeBufferSize), header = {type = user.mkcp_guise} } or nil, - wsSettings = (user.transport == "ws") and - { - headers = (user.ws_host) and {Host = user.ws_host} or - nil, - path = user.ws_path - } or nil, - httpSettings = (user.transport == "h2") and - {path = user.h2_path, host = user.h2_host} or nil, - dsSettings = (user.transport == "ds") and - {path = user.ds_path} or nil, + wsSettings = (user.transport == "ws") and { + headers = (user.ws_host) and {Host = user.ws_host} or nil, + path = user.ws_path + } or nil, + httpSettings = (user.transport == "h2") and { + path = user.h2_path, host = user.h2_host + } or nil, + dsSettings = (user.transport == "ds") and { + path = user.ds_path + } or nil, quicSettings = (user.transport == "quic") and { security = user.quic_security, key = user.quic_key, header = {type = user.quic_guise} } or nil - } or nil + } } }, -- 传出连接 diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/user.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/user.lua index 1d28cefbad..b44d4e2490 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/user.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/user.lua @@ -82,17 +82,17 @@ if is_installed("trojan-go") or is_finded("trojan-go") then end protocol = s:option(ListValue, "protocol", translate("Protocol")) -protocol:value("vmess", translate("Vmess")) -protocol:value("http", translate("HTTP")) -protocol:value("socks", translate("Socks")) -protocol:value("shadowsocks", translate("Shadowsocks")) +protocol:value("vmess", "Vmess") +protocol:value("http", "HTTP") +protocol:value("socks", "Socks") +protocol:value("shadowsocks", "Shadowsocks") +protocol:value("mtproto", "MTProto") protocol:depends("type", "V2ray") -- Brook协议 -brook_protocol = s:option(ListValue, "brook_protocol", - translate("Brook Protocol")) -brook_protocol:value("server", translate("Brook")) -brook_protocol:value("wsserver", translate("WebSocket")) +brook_protocol = s:option(ListValue, "brook_protocol", translate("Brook Protocol")) +brook_protocol:value("server", "Brook") +brook_protocol:value("wsserver", "WebSocket") brook_protocol:depends("type", "Brook") brook_tls = s:option(Flag, "brook_tls", translate("Use TLS")) @@ -101,14 +101,6 @@ brook_tls:depends("brook_protocol", "wsserver") port = s:option(Value, "port", translate("Port")) port.datatype = "port" port.rmempty = false -port:depends("type", "SSR") -port:depends({ type = "V2ray", protocol = "vmess" }) -port:depends({ type = "V2ray", protocol = "http" }) -port:depends({ type = "V2ray", protocol = "socks" }) -port:depends({ type = "V2ray", protocol = "shadowsocks" }) -port:depends("type", "Brook") -port:depends("type", "Trojan") -port:depends("type", "Trojan-Go") username = s:option(Value, "username", translate("Username")) username:depends("protocol", "http") @@ -123,6 +115,7 @@ password:depends("type", "Trojan-Go") password:depends({ type = "V2ray", protocol = "http" }) password:depends({ type = "V2ray", protocol = "socks" }) password:depends({ type = "V2ray", protocol = "shadowsocks" }) +password:depends({ type = "V2ray", protocol = "mtproto" }) ssr_encrypt_method = s:option(ListValue, "ssr_encrypt_method", translate("Encrypt Method")) for a, t in ipairs(ssr_encrypt_method_list) do ssr_encrypt_method:value(t) end @@ -185,21 +178,20 @@ alter_id = s:option(Value, "alter_id", translate("Alter ID")) alter_id.default = 16 alter_id:depends({ type = "V2ray", protocol = "vmess" }) -vmess_level = s:option(Value, "vmess_level", translate("User Level")) -vmess_level.default = 1 -vmess_level:depends({ type = "V2ray", protocol = "vmess" }) -vmess_level:depends({ type = "V2ray", protocol = "shadowsocks" }) +level = s:option(Value, "level", translate("User Level")) +level.default = 1 +level:depends({ type = "V2ray", protocol = "vmess" }) +level:depends({ type = "V2ray", protocol = "shadowsocks" }) +level:depends({ type = "V2ray", protocol = "mtproto" }) -stream_security = s:option(ListValue, "stream_security", - translate("Transport Layer Encryption"), - translate( - 'Whether or not transport layer encryption is enabled, the supported options are "none" for unencrypted (default) and "TLS" for using TLS.')) +stream_security = s:option(ListValue, "stream_security", translate("Transport Layer Encryption"), translate('Whether or not transport layer encryption is enabled, the supported options are "none" for unencrypted (default) and "TLS" for using TLS.')) stream_security:value("none", "none") stream_security:value("tls", "tls") stream_security.default = "tls" stream_security:depends({ type = "V2ray", protocol = "vmess", transport = "ws" }) stream_security:depends({ type = "V2ray", protocol = "vmess", transport = "h2" }) -stream_security:depends("protocol", "shadowsocks") +stream_security:depends({ type = "V2ray", protocol = "socks" }) +stream_security:depends({ type = "V2ray", protocol = "shadowsocks" }) stream_security:depends("type", "Trojan-Go") -- [[ TLS部分 ]] -- @@ -221,7 +213,9 @@ transport:value("ws", "WebSocket") transport:value("h2", "HTTP/2") transport:value("ds", "DomainSocket") transport:value("quic", "QUIC") -transport:depends("protocol", "vmess") +stream_security:depends({ type = "V2ray", protocol = "vmess" }) +stream_security:depends({ type = "V2ray", protocol = "socks" }) +stream_security:depends({ type = "V2ray", protocol = "shadowsocks" }) trojan_transport = s:option(ListValue, "trojan_transport", translate("Transport")) trojan_transport:value("original", "Original") @@ -343,7 +337,7 @@ quic_guise = s:option(ListValue, "quic_guise", translate("Camouflage Type")) for a, t in ipairs(header_type_list) do quic_guise:value(t) end quic_guise:depends("transport", "quic") -remote_enable = s:option(Flag, "remote_enable", translate("Enable Remote"),translate("You can forward to Nginx/Caddy/V2ray WebSocket and more.")) +remote_enable = s:option(Flag, "remote_enable", translate("Enable Remote"), translate("You can forward to Nginx/Caddy/V2ray WebSocket and more.")) remote_enable.default = "1" remote_enable.rmempty = false remote_enable:depends("type", "Trojan") @@ -372,14 +366,6 @@ ss_aead_pwd.password = true ss_aead_pwd.rmempty = false ss_aead_pwd:depends("ss_aead", "1") --- [[ Mux ]]-- -mux = s:option(Flag, "mux", translate("Mux")) - -mux_concurrency = s:option(Value, "mux_concurrency", - translate("Mux Concurrency")) -mux_concurrency.default = 8 -mux_concurrency:depends("mux", "1") - local nodes_table = {} uci:foreach("passwall", "nodes", function(e) if e.type and e.type == "V2ray" and e.remarks and e.address and e.port then diff --git a/package/lienol/luci-app-passwall/luasrc/view/passwall/node_list/link_add_node.htm b/package/lienol/luci-app-passwall/luasrc/view/passwall/node_list/link_add_node.htm index 098e7a5a11..a54e0888c9 100644 --- a/package/lienol/luci-app-passwall/luasrc/view/passwall/node_list/link_add_node.htm +++ b/package/lienol/luci-app-passwall/luasrc/view/passwall/node_list/link_add_node.htm @@ -23,6 +23,41 @@ local dsp = require "luci.dispatcher" + + + + +<%+cbi/valuefooter%> diff --git a/package/lienol/luci-app-passwall/po/zh_Hans/passwall.po b/package/lienol/luci-app-passwall/po/zh_Hans/passwall.po index b55d1692f9..7a05c246e5 100644 --- a/package/lienol/luci-app-passwall/po/zh_Hans/passwall.po +++ b/package/lienol/luci-app-passwall/po/zh_Hans/passwall.po @@ -370,6 +370,42 @@ msgstr "负载均衡节点列表" msgid "Load balancing node list, document" msgstr "负载均衡节点列表,文档原理" +msgid "Share Current" +msgstr "所见即所得" + +msgid "From Share URL" +msgstr "导入配置信息" + +msgid "Build Share URL" +msgstr "导出配置信息" + +msgid "Import Finished" +msgstr "导入完成:" + +msgid "Not a supported scheme:" +msgstr "不支持这种样式的:" + +msgid "Invalid Share URL Format" +msgstr "无效的分享信息" + +msgid "User cancelled" +msgstr "用户已取消" + +msgid "Paste Share URL Here" +msgstr "在此处粘贴分享信息" + +msgid "Unable share to clipboard, copy to batch mode still:" +msgstr "无法分享网址到剪贴板,复制到批量导入临时输入:" + +msgid "Share to clipboard successfully, copy to batch mode still:" +msgstr "成功复制分享网址到剪贴板和批量导入临时输入:" + +msgid "Faltal on get option, please help in debug:" +msgstr "代码错误,请协助捉虫:" + +msgid "Faltal on set option, please help in debug:" +msgstr "代码错误,请协助捉虫:" + msgid "Address" msgstr "地址" @@ -386,7 +422,7 @@ msgid "Finger Print" msgstr "指纹伪造" msgid "Shadowsocks2" -msgstr "双重加密" +msgstr "二次加密" msgid "Encrypt Method" msgstr "加密"