luci-app-ssr-plus: add Packet Encoding option

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen 2022-04-08 04:17:19 +08:00 committed by sbwml
parent 259337aacb
commit a73a32360e
7 changed files with 48 additions and 6 deletions

View File

@ -26,8 +26,8 @@ LUCI_PKGARCH:=all
LUCI_DEPENDS:= \ LUCI_DEPENDS:= \
@(PACKAGE_libustream-mbedtls||PACKAGE_libustream-openssl||PACKAGE_libustream-wolfssl) \ @(PACKAGE_libustream-mbedtls||PACKAGE_libustream-openssl||PACKAGE_libustream-wolfssl) \
+coreutils +coreutils-base64 +dns2socks +dns2tcp +dnsmasq-full +ipset +kmod-ipt-nat \ +coreutils +coreutils-base64 +dns2socks +dns2tcp +dnsmasq-full +ipset +kmod-ipt-nat \
+ip-full +iptables +iptables-mod-tproxy +lua +libuci-lua +microsocks +tcping \ +ip-full +iptables +iptables-mod-tproxy +lua +libuci-lua ++luci-lib-ipkg +microsocks \
+resolveip +shadowsocksr-libev-ssr-check +uclient-fetch \ +tcping +resolveip +shadowsocksr-libev-ssr-check +uclient-fetch \
+PACKAGE_$(PKG_NAME)_INCLUDE_Kcptun:kcptun-client \ +PACKAGE_$(PKG_NAME)_INCLUDE_Kcptun:kcptun-client \
+PACKAGE_$(PKG_NAME)_INCLUDE_IPT2Socks:ipt2socks \ +PACKAGE_$(PKG_NAME)_INCLUDE_IPT2Socks:ipt2socks \
+PACKAGE_$(PKG_NAME)_INCLUDE_NaiveProxy:naiveproxy \ +PACKAGE_$(PKG_NAME)_INCLUDE_NaiveProxy:naiveproxy \

View File

@ -56,6 +56,12 @@ o:value("https://ispip.clang.cn/all_cn.txt", translate("Clang.CN"))
o:value("https://ispip.clang.cn/all_cn_cidr.txt", translate("Clang.CN.CIDR")) o:value("https://ispip.clang.cn/all_cn_cidr.txt", translate("Clang.CN.CIDR"))
o.default = "https://ispip.clang.cn/all_cn.txt" o.default = "https://ispip.clang.cn/all_cn.txt"
o = s:option(ListValue, "default_packet_encoding", translate("Default Packet Encoding"))
o:value("none", translate("none"))
o:value("packet", translate("packet (v2ray-core v5+)"))
o:value("xudp", translate("xudp (Xray-core)"))
o.default = "xudp"
o = s:option(Flag, "netflix_enable", translate("Enable Netflix Mode")) o = s:option(Flag, "netflix_enable", translate("Enable Netflix Mode"))
o.rmempty = false o.rmempty = false

View File

@ -1,16 +1,23 @@
-- Copyright (C) 2017 yushi studio <ywb94@qq.com> github.com/ywb94 -- Copyright (C) 2017 yushi studio <ywb94@qq.com> github.com/ywb94
-- Licensed to the public under the GNU General Public License v3. -- Licensed to the public under the GNU General Public License v3.
require "nixio.fs" require "nixio.fs"
require "luci.sys" require "luci.sys"
require "luci.http" require "luci.http"
require "luci.model.ipkg"
local m, s, o, kcp_enable local m, s, o, kcp_enable
local sid = arg[1] local sid = arg[1]
local uuid = luci.sys.exec("cat /proc/sys/kernel/random/uuid") local uuid = luci.sys.exec("cat /proc/sys/kernel/random/uuid")
function is_finded(e) local function is_finded(e)
return luci.sys.exec('type -t -p "%s"' % e) ~= "" and true or false return luci.sys.exec('type -t -p "%s"' % e) ~= "" and true or false
end end
local function is_installed(e)
return luci.model.ipkg.installed(e)
end
local server_table = {} local server_table = {}
local encrypt_methods = { local encrypt_methods = {
-- ssr -- ssr
@ -622,6 +629,17 @@ o:depends("type", "ssr")
o:depends("type", "ss") o:depends("type", "ss")
o:depends("type", "trojan") o:depends("type", "trojan")
if is_installed("sagernet-core") then
o = s:option(ListValue, "packet_encoding", translate("Packet Encoding"))
o:value("none", translate("none"))
o:value("packet", translate("packet (v2ray-core v5+)"))
o:value("xudp", translate("xudp (Xray-core)"))
o.default = "xudp"
o.rmempty = true
o:depends({type = "v2ray", v2ray_protocol = "vless"})
o:depends({type = "v2ray", v2ray_protocol = "vmess"})
end
o = s:option(Flag, "switch_enable", translate("Enable Auto Switch")) o = s:option(Flag, "switch_enable", translate("Enable Auto Switch"))
o.rmempty = false o.rmempty = false
o.default = "1" o.default = "1"

View File

@ -730,6 +730,9 @@ msgstr "写入缓冲区大小"
msgid "Congestion" msgid "Congestion"
msgstr "拥塞控制" msgstr "拥塞控制"
msgid "Packet Encoding"
msgstr "数据包编码"
msgid "Network interface to use" msgid "Network interface to use"
msgstr "使用的网络接口" msgstr "使用的网络接口"
@ -757,5 +760,8 @@ msgstr "重新应用"
msgid "Apply" msgid "Apply"
msgstr "应用" msgstr "应用"
msgid "Default Packet Encoding"
msgstr "默认数据包编码"
msgid "Enable Netflix Mode" msgid "Enable Netflix Mode"
msgstr "启用 Netflix 分流模式" msgstr "启用 Netflix 分流模式"

View File

@ -908,6 +908,7 @@ reset() {
set shadowsocksr.@global[0].switch_time='667' set shadowsocksr.@global[0].switch_time='667'
set shadowsocksr.@global[0].switch_timeout='5' set shadowsocksr.@global[0].switch_timeout='5'
set shadowsocksr.@global[0].switch_try_count='3' set shadowsocksr.@global[0].switch_try_count='3'
set shadowsocksr.@global[0].default_packet_encoding='xudp'
set shadowsocksr.@global[0].gfwlist_url='https://fastly.jsdelivr.net/gh/YW5vbnltb3Vz/domain-list-community@release/gfwlist.txt' set shadowsocksr.@global[0].gfwlist_url='https://fastly.jsdelivr.net/gh/YW5vbnltb3Vz/domain-list-community@release/gfwlist.txt'
set shadowsocksr.@global[0].chnroute_url='https://ispip.clang.cn/all_cn.txt' set shadowsocksr.@global[0].chnroute_url='https://ispip.clang.cn/all_cn.txt'
set shadowsocksr.@global[0].nfip_url='https://fastly.jsdelivr.net/gh/QiuSimons/Netflix_IP/NF_only.txt' set shadowsocksr.@global[0].nfip_url='https://fastly.jsdelivr.net/gh/QiuSimons/Netflix_IP/NF_only.txt'

View File

@ -1,11 +1,16 @@
#!/usr/bin/lua
local ucursor = require "luci.model.uci".cursor() local ucursor = require "luci.model.uci".cursor()
local json = require "luci.jsonc" local json = require "luci.jsonc"
local server_section = arg[1] local server_section = arg[1]
local proto = arg[2] local proto = arg[2]
local local_port = arg[3] or "0" local local_port = arg[3] or "0"
local socks_port = arg[4] or "0" local socks_port = arg[4] or "0"
local server = ucursor:get_all("shadowsocksr", server_section) local server = ucursor:get_all("shadowsocksr", server_section)
local outbound_settings = nil local outbound_settings = nil
function vmess_vless() function vmess_vless()
outbound_settings = { outbound_settings = {
vnext = { vnext = {
@ -21,7 +26,8 @@ function vmess_vless()
} }
} }
} }
} },
packetEncoding = server.packet_encoding or nil
} }
end end
function trojan_shadowsocks() function trojan_shadowsocks()
@ -185,7 +191,8 @@ local Xray = {
mux = (server.mux == "1" and server.xtls ~= "1" and server.transport ~= "grpc") and { mux = (server.mux == "1" and server.xtls ~= "1" and server.transport ~= "grpc") and {
-- mux -- mux
enabled = true, enabled = true,
concurrency = tonumber(server.concurrency) concurrency = tonumber(server.concurrency),
packetEncoding = (server.v2ray_protocol == "vmess" or server.v2ray_protocol == "vless") and server.packet_encoding or nil
} or nil } or nil
} or nil } or nil
} }

View File

@ -9,6 +9,7 @@ require "nixio"
require "luci.util" require "luci.util"
require "luci.sys" require "luci.sys"
require "luci.jsonc" require "luci.jsonc"
require "luci.model.ipkg"
-- these global functions are accessed all the time by the event handler -- these global functions are accessed all the time by the event handler
-- so caching them is worth the effort -- so caching them is worth the effort
local tinsert = table.insert local tinsert = table.insert
@ -25,6 +26,7 @@ local switch = ucic:get_first(name, 'server_subscribe', 'switch', '1')
local subscribe_url = ucic:get_first(name, 'server_subscribe', 'subscribe_url', {}) local subscribe_url = ucic:get_first(name, 'server_subscribe', 'subscribe_url', {})
local filter_words = ucic:get_first(name, 'server_subscribe', 'filter_words', '过期时间/剩余流量') local filter_words = ucic:get_first(name, 'server_subscribe', 'filter_words', '过期时间/剩余流量')
local save_words = ucic:get_first(name, 'server_subscribe', 'save_words', '') local save_words = ucic:get_first(name, 'server_subscribe', 'save_words', '')
local packet_encoding = luci.model.ipkg.installed("sagernet-core") and ucic:get_first(name, 'global', 'default_packet_encoding', 'xudp') or nil
local v2_ss = luci.sys.exec('type -t -p ss-redir sslocal') ~= "" and "ss" or "v2ray" local v2_ss = luci.sys.exec('type -t -p ss-redir sslocal') ~= "" and "ss" or "v2ray"
local v2_tj = luci.sys.exec('type -t -p trojan') ~= "" and "trojan" or "v2ray" local v2_tj = luci.sys.exec('type -t -p trojan') ~= "" and "trojan" or "v2ray"
local log = function(...) local log = function(...)
@ -168,6 +170,7 @@ local function processData(szType, content)
result.transport = info.net result.transport = info.net
result.vmess_id = info.id result.vmess_id = info.id
result.alias = info.ps result.alias = info.ps
result.packet_encoding = packet_encoding
-- result.mux = 1 -- result.mux = 1
-- result.concurrency = 8 -- result.concurrency = 8
if info.net == 'ws' then if info.net == 'ws' then
@ -373,6 +376,7 @@ local function processData(szType, content)
result.vmess_id = uuid result.vmess_id = uuid
result.vless_encryption = params.encryption or "none" result.vless_encryption = params.encryption or "none"
result.transport = params.type and (params.type == 'http' and 'h2' or params.type) or "tcp" result.transport = params.type and (params.type == 'http' and 'h2' or params.type) or "tcp"
result.packet_encoding = packet_encoding
if not params.type or params.type == "tcp" then if not params.type or params.type == "tcp" then
if params.security == "xtls" then if params.security == "xtls" then
result.xtls = "1" result.xtls = "1"