mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-12 03:27:52 +08:00
update 2026-10-21 10:58:41
This commit is contained in:
1 parent
f144cc6010
commit
4570f1512e
495 files changed
+129503
-31
No files matched your search
@@ -993,7 +993,7 @@ use_mihomo_for_ss_rust_server() {
|
||||
|
||||
start_v2ray_with_mihomo() {
|
||||
# These nodes use Xray-specific settings.
|
||||
case "$(uci_get_by_name "$1" v2ray_protocol)" in naive|shadowsocksr) return 1 ;; esac
|
||||
case "$(uci_get_by_name "$1" v2ray_protocol)" in naive|shadowsocksr|tuic) return 1 ;; esac
|
||||
local sid="$1"
|
||||
local local_port="$2"
|
||||
local socks_port="$3"
|
||||
@@ -1798,7 +1798,7 @@ start_udp() {
|
||||
;;
|
||||
v2ray)
|
||||
enable_mihomo=$(uci_get_by_type server_subscribe enable_mihomo "")
|
||||
if [ "$(uci_get_by_name "$UDP_RELAY_SERVER" v2ray_protocol)" != "naive" ] && [ "$(uci_get_by_name "$UDP_RELAY_SERVER" v2ray_protocol)" != "shadowsocksr" ] && [ "$enable_mihomo" = "1" ] && has_mihomo_binary; then
|
||||
if [ "$(uci_get_by_name "$UDP_RELAY_SERVER" v2ray_protocol)" != "naive" ] && [ "$(uci_get_by_name "$UDP_RELAY_SERVER" v2ray_protocol)" != "shadowsocksr" ] && [ "$(uci_get_by_name "$UDP_RELAY_SERVER" v2ray_protocol)" != "tuic" ] && [ "$enable_mihomo" = "1" ] && has_mihomo_binary; then
|
||||
redir_udp=0
|
||||
ARG_UDP=""
|
||||
echolog "UDP TPROXY Relay:V2Ray/Xray 单节点由主 Mihomo 实例处理。"
|
||||
@@ -1811,7 +1811,7 @@ start_udp() {
|
||||
echolog "UDP TPROXY Relay:$($(first_type xray) version | head -1) Started!"
|
||||
else
|
||||
# Xray 不存在但 Mihomo 存在,回退到 Mihomo(当 enable_mihomo=0 时)
|
||||
if [ "$(uci_get_by_name "$UDP_RELAY_SERVER" v2ray_protocol)" != "naive" ] && [ "$(uci_get_by_name "$UDP_RELAY_SERVER" v2ray_protocol)" != "shadowsocksr" ] && has_mihomo_binary; then
|
||||
if [ "$(uci_get_by_name "$UDP_RELAY_SERVER" v2ray_protocol)" != "naive" ] && [ "$(uci_get_by_name "$UDP_RELAY_SERVER" v2ray_protocol)" != "shadowsocksr" ] && [ "$(uci_get_by_name "$UDP_RELAY_SERVER" v2ray_protocol)" != "tuic" ] && has_mihomo_binary; then
|
||||
redir_udp=0
|
||||
ARG_UDP=""
|
||||
echolog "UDP TPROXY Relay:Xray 内核不存在,已回退到 Mihomo 内核启动。"
|
||||
@@ -1962,9 +1962,6 @@ start_local() {
|
||||
[ -n "$probe_instance_key" ] && instance_key="$probe_instance_key"
|
||||
if [ "$enable_mihomo" = "1" ] && start_v2ray_with_mihomo "$LOCAL_SERVER" "$local_port" "$local_port" "$instance_key" "socks" "v2ray-local" "Global_Socks5"; then
|
||||
:
|
||||
elif [ "$(uci_get_by_name "$LOCAL_SERVER" v2ray_protocol)" = "snell" ]; then
|
||||
echolog "Global_Socks5:Snell 需要 Mihomo 内核,且当前 Mihomo 启动失败。"
|
||||
return 1
|
||||
elif [ "$_local" = "2" ]; then
|
||||
# 尝试 Xray
|
||||
xray_bin="$(first_type xray)"
|
||||
@@ -2251,6 +2248,9 @@ get_udp_relay_mode() {
|
||||
v2ray)
|
||||
proto=$(uci_get_by_name "$node" v2ray_protocol)
|
||||
case "$proto" in
|
||||
snell)
|
||||
case "$(uci_get_by_name "$node" snell_version 4)" in 1|2) echo "disabled" ;; *) echo "native" ;; esac
|
||||
;;
|
||||
naive)
|
||||
[ "$(uci_get_by_name "$node" naive_udp_over_tcp 0)" = "1" ] && echo "native" || echo "disabled"
|
||||
;;
|
||||
@@ -2386,11 +2386,8 @@ Start_Run() {
|
||||
enable_mihomo=$(uci_get_by_type server_subscribe enable_mihomo "")
|
||||
if [ "$enable_mihomo" = "1" ] && start_v2ray_with_mihomo "$GLOBAL_SERVER" "$tcp_port" "$socks_port" "$GLOBAL_SERVER" "redir" "ssr-retcp" "Main node"; then
|
||||
:
|
||||
elif [ "$(uci_get_by_name "$GLOBAL_SERVER" v2ray_protocol)" = "snell" ]; then
|
||||
echolog "Main node:Snell 需要 Mihomo 内核,且当前 Mihomo 启动失败。"
|
||||
return 1
|
||||
else
|
||||
# enable_mihomo=0 或 Mihomo 启动失败(非 Snell)→ 优先使用 Xray
|
||||
# enable_mihomo=0 或 Mihomo 启动失败 → 优先使用 Xray
|
||||
xray_bin="$(first_type xray)"
|
||||
if [ -n "$xray_bin" ]; then
|
||||
gen_config_file "$GLOBAL_SERVER" "$type" 1 "$tcp_port" "$socks_port"
|
||||
@@ -2752,6 +2749,36 @@ start_server() {
|
||||
echolog "Server: Xray NaiveProxy Server$server_count Started!"
|
||||
;;
|
||||
|
||||
anytls)
|
||||
xray_bin="$(first_type xray)"
|
||||
[ -x "$xray_bin" ] || return 1
|
||||
config_file="$TMP_PATH/xray-server-$server_count.json"
|
||||
lua /usr/share/shadowsocksr/gen_anytls_server.lua "$1" > "$config_file" || return 1
|
||||
"$xray_bin" run -test -c "$config_file" >> /var/ssrplus.log 2>&1 || return 1
|
||||
ln_start_bin "$xray_bin" xray-server-$server_count run -c "$config_file"
|
||||
echolog "Server: Xray AnyTLS Server$server_count Started!"
|
||||
;;
|
||||
|
||||
snell)
|
||||
xray_bin="$(first_type xray)"
|
||||
[ -x "$xray_bin" ] || return 1
|
||||
config_file="$TMP_PATH/xray-server-$server_count.json"
|
||||
lua /usr/share/shadowsocksr/gen_snell_server.lua "$1" > "$config_file" || return 1
|
||||
"$xray_bin" run -test -c "$config_file" >> /var/ssrplus.log 2>&1 || return 1
|
||||
ln_start_bin "$xray_bin" xray-server-$server_count run -c "$config_file"
|
||||
echolog "Server: Xray Snell Server$server_count Started!"
|
||||
;;
|
||||
|
||||
tuic)
|
||||
xray_bin="$(first_type xray)"
|
||||
[ -x "$xray_bin" ] || return 1
|
||||
config_file="$TMP_PATH/xray-server-$server_count.json"
|
||||
lua /usr/share/shadowsocksr/gen_tuic_server.lua "$1" > "$config_file" || return 1
|
||||
"$xray_bin" run -test -c "$config_file" >> /var/ssrplus.log 2>&1 || return 1
|
||||
ln_start_bin "$xray_bin" xray-server-$server_count run -c "$config_file"
|
||||
echolog "Server: Xray TUIC Server$server_count Started!"
|
||||
;;
|
||||
|
||||
vmess|vless|trojan|shadowsocks)
|
||||
# Xray 服务端支持
|
||||
port=$(uci_get_by_name "$1" server_port)
|
||||
|
||||
@@ -928,7 +928,9 @@ local function build_v2ray_mihomo_proxy(sid)
|
||||
elseif protocol == "snell" then
|
||||
proxy.type = "snell"
|
||||
proxy.psk = get_server_field(sid, "snell_psk", "")
|
||||
proxy.version = number_or_nil(get_server_field(sid, "snell_version", ""))
|
||||
proxy.version = tonumber(get_server_field(sid, "snell_version", "4")) or 4
|
||||
proxy.reuse = get_server_field(sid, "snell_reuse", "0") == "1"
|
||||
proxy.udp = proxy.version >= 3
|
||||
local obfs_mode = string_or_nil(get_server_field(sid, "snell_obfs", ""))
|
||||
local obfs_host = string_or_nil(get_server_field(sid, "snell_obfs_host", ""))
|
||||
if obfs_mode or obfs_host then
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/lua
|
||||
local uci = require("luci.model.uci").cursor()
|
||||
local json = require "luci.jsonc"
|
||||
local s = assert(uci:get_all("shadowsocksr", arg[1]), "missing server section")
|
||||
local padding = {}
|
||||
for line in (s.anytls_padding or ""):gmatch("[^\r\n]+") do padding[#padding + 1] = line end
|
||||
print(json.stringify({
|
||||
log = {loglevel = "warning"},
|
||||
inbounds = {{listen = "::", port = assert(tonumber(s.server_port)), protocol = "anytls",
|
||||
settings = {users = {{email = "user", password = assert(s.anytls_password)}},
|
||||
paddingScheme = #padding > 0 and padding or nil},
|
||||
streamSettings = {network = "raw", security = "tls", tlsSettings = {
|
||||
certificates = {{oneTimeLoading = true, certificateFile = assert(s.tls_certificateFile), keyFile = assert(s.tls_keyFile)}}
|
||||
}}
|
||||
}},
|
||||
outbounds = {{protocol = "freedom", settings = {}}}
|
||||
}, 1))
|
||||
@@ -363,6 +363,34 @@ function outbound:handleIndex(index)
|
||||
trojan = function()
|
||||
trojan_shadowsocks()
|
||||
end,
|
||||
snell = function()
|
||||
outbound_settings = {
|
||||
address = server.server, port = tonumber(server.server_port),
|
||||
psk = server.snell_psk, version = tonumber(server.snell_version) or 4,
|
||||
obfs = server.snell_obfs or "", obfsHost = server.snell_obfs_host,
|
||||
reuse = server.snell_reuse == "1"
|
||||
}
|
||||
end,
|
||||
tuic = function()
|
||||
local version = tonumber(server.xray_tuic_version) or 5
|
||||
local alpn = {}
|
||||
for value in (server.tuic_alpn or ""):gmatch("[^,]+") do alpn[#alpn + 1] = value end
|
||||
if #alpn == 0 then alpn = {"h3"} end
|
||||
outbound_settings = {
|
||||
address = server.server, port = tonumber(server.server_port), version = version,
|
||||
token = version == 4 and server.xray_tuic_token or nil,
|
||||
uuid = version == 5 and server.tuic_uuid or nil,
|
||||
password = version == 5 and server.tuic_passwd or nil,
|
||||
serverName = server.tls_host, certificateFile = server.xray_tuic_ca,
|
||||
allowInsecure = server.insecure == "1",
|
||||
alpn = alpn,
|
||||
congestionControl = server.congestion_control or "cubic",
|
||||
udpRelayMode = server.udp_relay_mode or "native",
|
||||
heartbeatInterval = (tonumber(server.heartbeat) or 10) * 1000,
|
||||
requestTimeout = (tonumber(server.timeout) or 8) * 1000,
|
||||
reduceRtt = server.zero_rtt_handshake == "1"
|
||||
}
|
||||
end,
|
||||
shadowsocksr = function()
|
||||
outbound_settings = {
|
||||
address = server.server, port = tonumber(server.server_port),
|
||||
@@ -899,9 +927,9 @@ Xray.outbounds = {
|
||||
}
|
||||
}
|
||||
|
||||
-- Naive owns TLS/multiplexing; SSR owns obfuscation and uses native UDP.
|
||||
-- Preserve Xray socket marks and dialer chains for both.
|
||||
if server.v2ray_protocol == "naive" or server.v2ray_protocol == "shadowsocksr" then
|
||||
-- These protocols own their framing, obfuscation and multiplexing.
|
||||
-- Preserve Xray socket marks and dialer chains.
|
||||
if server.v2ray_protocol == "naive" or server.v2ray_protocol == "shadowsocksr" or server.v2ray_protocol == "tuic" or server.v2ray_protocol == "snell" then
|
||||
local ob = Xray.outbounds[1]
|
||||
ob.streamSettings = { network = "raw", sockopt = ob.streamSettings.sockopt }
|
||||
ob.mux = nil
|
||||
@@ -1322,6 +1350,14 @@ function config:handleIndex(index)
|
||||
chain_switch[ChainType]()
|
||||
end
|
||||
end,
|
||||
snell = function()
|
||||
outbound_settings = {
|
||||
address = server.server, port = tonumber(server.server_port),
|
||||
psk = server.snell_psk, version = tonumber(server.snell_version) or 4,
|
||||
obfs = server.snell_obfs or "", obfsHost = server.snell_obfs_host,
|
||||
reuse = server.snell_reuse == "1"
|
||||
}
|
||||
end,
|
||||
tuic = function()
|
||||
print(json.stringify(tuic, 1))
|
||||
end
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/lua
|
||||
local uci = require("luci.model.uci").cursor()
|
||||
local json = require "luci.jsonc"
|
||||
local s = assert(uci:get_all("shadowsocksr", arg[1]), "missing server section")
|
||||
local version = tonumber(s.snell_version) or 4
|
||||
print(json.stringify({
|
||||
log = {loglevel = "warning"},
|
||||
inbounds = {{listen = "::", port = assert(tonumber(s.server_port)), protocol = "snell",
|
||||
settings = {psk = assert(s.snell_psk), version = version,
|
||||
obfs = s.snell_obfs or "", udp = version >= 3 and s.snell_udp ~= "0"}
|
||||
}},
|
||||
outbounds = {{protocol = "freedom", settings = {}}}
|
||||
}, 1))
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/lua
|
||||
local uci = require("luci.model.uci").cursor()
|
||||
local json = require "luci.jsonc"
|
||||
local s = assert(uci:get_all("shadowsocksr", arg[1]), "missing server section")
|
||||
local users, tokens = {}, {}
|
||||
if s.tuic_uuid and s.tuic_uuid ~= "" then
|
||||
users[s.tuic_uuid] = assert(s.tuic_password, "TUIC password required")
|
||||
end
|
||||
if s.tuic_token and s.tuic_token ~= "" then tokens[1] = s.tuic_token end
|
||||
assert(next(users) or #tokens > 0, "TUIC credentials required")
|
||||
print(json.stringify({
|
||||
log = {loglevel = "warning"},
|
||||
inbounds = {{listen = "::", port = assert(tonumber(s.server_port)), protocol = "tuic",
|
||||
settings = {users = next(users) and users or nil, tokens = #tokens > 0 and tokens or nil,
|
||||
certificateFile = assert(s.tls_certificateFile), keyFile = assert(s.tls_keyFile)},
|
||||
streamSettings = {network = "tuic"}
|
||||
}},
|
||||
outbounds = {{protocol = "freedom", settings = {}}}
|
||||
}, 1))
|
||||
@@ -824,7 +824,9 @@ local function to_mihomo_proxy(node)
|
||||
elseif node.type == "v2ray" and node.v2ray_protocol == "snell" then
|
||||
proxy.type = "snell"
|
||||
proxy.psk = node.snell_psk
|
||||
proxy.version = tonumber(node.snell_version) or nil
|
||||
proxy.version = tonumber(node.snell_version) or 4
|
||||
proxy.udp = proxy.version >= 3
|
||||
proxy.reuse = node.snell_reuse == "1"
|
||||
local obfs_mode = string_from_value(node.snell_obfs)
|
||||
local obfs_host = string_from_value(node.snell_obfs_host)
|
||||
if obfs_mode or obfs_host then
|
||||
@@ -1021,8 +1023,8 @@ local function processData(szType, content, cfgid)
|
||||
result.fast_open = params.tfo
|
||||
end
|
||||
elseif szType == "snell" then
|
||||
if not has_mihomo then
|
||||
log("跳过 Snell 节点:本地未安装 mihomo。")
|
||||
if not has_xray and not has_mihomo then
|
||||
log("跳过 Snell 节点:本地未安装 Xray 或 Mihomo。")
|
||||
return nil
|
||||
end
|
||||
|
||||
@@ -1041,6 +1043,7 @@ local function processData(szType, content, cfgid)
|
||||
result.snell_version = first_nonempty(params, {"version", "v"}) or "4"
|
||||
result.snell_obfs = first_nonempty(params, {"obfs", "obfs-mode", "obfs_mode"})
|
||||
result.snell_obfs_host = first_nonempty(params, {"obfs-host", "obfs_host", "host"})
|
||||
result.snell_reuse = (params.reuse == "1" or params.reuse == "true") and "1" or "0"
|
||||
if not result.snell_psk or result.snell_psk == "" then
|
||||
result.server = nil
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user