feat(脚本): 增加sing-box客户端订阅

pull/1006/head
mack-a 2024-03-12 23:56:04 +08:00
parent 2b4833c779
commit 498166b1e8
2 changed files with 75 additions and 69 deletions

View File

@ -164,7 +164,6 @@
"type": "remote", "type": "remote",
"format": "binary", "format": "binary",
"url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/category-ads-all.srs", "url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/category-ads-all.srs",
"download_detour": "全局代理",
"update_interval": "1d" "update_interval": "1d"
}, },
{ {
@ -172,7 +171,6 @@
"type": "remote", "type": "remote",
"format": "binary", "format": "binary",
"url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/telegram.srs", "url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/telegram.srs",
"download_detour": "全局代理",
"update_interval": "1d" "update_interval": "1d"
}, },
{ {
@ -180,7 +178,6 @@
"type": "remote", "type": "remote",
"format": "binary", "format": "binary",
"url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geoip/telegram.srs", "url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geoip/telegram.srs",
"download_detour": "全局代理",
"update_interval": "1d" "update_interval": "1d"
}, },
{ {
@ -188,7 +185,6 @@
"type": "remote", "type": "remote",
"format": "binary", "format": "binary",
"url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/youtube.srs", "url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/youtube.srs",
"download_detour": "全局代理",
"update_interval": "1d" "update_interval": "1d"
}, },
{ {
@ -196,7 +192,6 @@
"type": "remote", "type": "remote",
"format": "binary", "format": "binary",
"url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/netflix.srs", "url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/netflix.srs",
"download_detour": "全局代理",
"update_interval": "1d" "update_interval": "1d"
}, },
{ {
@ -204,7 +199,6 @@
"type": "remote", "type": "remote",
"format": "binary", "format": "binary",
"url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geoip/netflix.srs", "url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geoip/netflix.srs",
"download_detour": "全局代理",
"update_interval": "1d" "update_interval": "1d"
}, },
{ {
@ -212,7 +206,6 @@
"type": "remote", "type": "remote",
"format": "binary", "format": "binary",
"url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/openai@ads.srs", "url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/openai@ads.srs",
"download_detour": "全局代理",
"update_interval": "1d" "update_interval": "1d"
}, },
{ {
@ -220,7 +213,6 @@
"type": "remote", "type": "remote",
"format": "binary", "format": "binary",
"url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/openai.srs", "url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/openai.srs",
"download_detour": "全局代理",
"update_interval": "1d" "update_interval": "1d"
}, },
{ {
@ -228,7 +220,6 @@
"type": "remote", "type": "remote",
"format": "binary", "format": "binary",
"url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/apple.srs", "url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/apple.srs",
"download_detour": "全局代理",
"update_interval": "1d" "update_interval": "1d"
}, },
{ {
@ -236,7 +227,6 @@
"type": "remote", "type": "remote",
"format": "binary", "format": "binary",
"url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/google.srs", "url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/google.srs",
"download_detour": "全局代理",
"update_interval": "1d" "update_interval": "1d"
}, },
{ {
@ -244,7 +234,6 @@
"type": "remote", "type": "remote",
"format": "binary", "format": "binary",
"url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geoip/google.srs", "url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geoip/google.srs",
"download_detour": "全局代理",
"update_interval": "1d" "update_interval": "1d"
}, },
{ {
@ -252,7 +241,6 @@
"type": "remote", "type": "remote",
"format": "binary", "format": "binary",
"url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/microsoft.srs", "url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/microsoft.srs",
"download_detour": "全局代理",
"update_interval": "1d" "update_interval": "1d"
}, },
{ {
@ -260,7 +248,6 @@
"type": "remote", "type": "remote",
"format": "binary", "format": "binary",
"url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/geolocation-!cn.srs", "url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/geolocation-!cn.srs",
"download_detour": "全局代理",
"update_interval": "1d" "update_interval": "1d"
}, },
{ {
@ -268,7 +255,6 @@
"type": "remote", "type": "remote",
"format": "binary", "format": "binary",
"url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/private.srs", "url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/private.srs",
"download_detour": "全局代理",
"update_interval": "1d" "update_interval": "1d"
}, },
{ {
@ -276,7 +262,6 @@
"type": "remote", "type": "remote",
"format": "binary", "format": "binary",
"url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/cn.srs", "url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/cn.srs",
"download_detour": "全局代理",
"update_interval": "1d" "update_interval": "1d"
}, },
{ {
@ -284,7 +269,6 @@
"type": "remote", "type": "remote",
"format": "binary", "format": "binary",
"url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geoip/private.srs", "url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geoip/private.srs",
"download_detour": "全局代理",
"update_interval": "1d" "update_interval": "1d"
}, },
{ {
@ -292,7 +276,6 @@
"type": "remote", "type": "remote",
"format": "binary", "format": "binary",
"url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geoip/cn.srs", "url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geoip/cn.srs",
"download_detour": "全局代理",
"update_interval": "1d" "update_interval": "1d"
} }
], ],
@ -386,7 +369,7 @@
"outbound": "本地直连" "outbound": "本地直连"
} }
], ],
"final": "全局代理", "final": "本地直连",
"auto_detect_interface": true "auto_detect_interface": true
} }
} }

View File

@ -887,6 +887,9 @@ mkdirTools() {
mkdir -p /etc/v2ray-agent/subscribe/clashMetaProfiles mkdir -p /etc/v2ray-agent/subscribe/clashMetaProfiles
mkdir -p /etc/v2ray-agent/subscribe/clashMeta mkdir -p /etc/v2ray-agent/subscribe/clashMeta
mkdir -p /etc/v2ray-agent/subscribe/sing-box
mkdir -p /etc/v2ray-agent/subscribe_local/sing-box
mkdir -p /etc/v2ray-agent/v2ray/conf mkdir -p /etc/v2ray-agent/v2ray/conf
mkdir -p /etc/v2ray-agent/v2ray/tmp mkdir -p /etc/v2ray-agent/v2ray/tmp
mkdir -p /etc/v2ray-agent/xray/conf mkdir -p /etc/v2ray-agent/xray/conf
@ -1325,7 +1328,7 @@ server {
client_header_timeout 1071906480m; client_header_timeout 1071906480m;
keepalive_timeout 1071906480m; keepalive_timeout 1071906480m;
location ~ ^/s/(clashMeta|default|clashMetaProfiles)/(.*) { location ~ ^/s/(clashMeta|default|clashMetaProfiles|sing-box)/(.*) {
proxy_set_header X-Real-IP \$proxy_protocol_addr; proxy_set_header X-Real-IP \$proxy_protocol_addr;
default_type 'text/plain; charset=utf-8'; default_type 'text/plain; charset=utf-8';
alias /etc/v2ray-agent/subscribe/\$1/\$2; alias /etc/v2ray-agent/subscribe/\$1/\$2;
@ -1366,7 +1369,7 @@ server {
server_name ${domain}; server_name ${domain};
root ${nginxStaticPath}; root ${nginxStaticPath};
location ~ ^/s/(clashMeta|default|clashMetaProfiles)/(.*) { location ~ ^/s/(clashMeta|default|clashMetaProfiles|sing-box)/(.*) {
proxy_set_header X-Real-IP \$proxy_protocol_addr; proxy_set_header X-Real-IP \$proxy_protocol_addr;
default_type 'text/plain; charset=utf-8'; default_type 'text/plain; charset=utf-8';
alias /etc/v2ray-agent/subscribe/\$1/\$2; alias /etc/v2ray-agent/subscribe/\$1/\$2;
@ -1394,7 +1397,7 @@ server {
server_name ${domain}; server_name ${domain};
root ${nginxStaticPath}; root ${nginxStaticPath};
location ~ ^/s/(clashMeta|default|clashMetaProfiles)/(.*) { location ~ ^/s/(clashMeta|default|clashMetaProfiles|sing-box)/(.*) {
proxy_set_header X-Real-IP \$proxy_protocol_addr; proxy_set_header X-Real-IP \$proxy_protocol_addr;
default_type 'text/plain; charset=utf-8'; default_type 'text/plain; charset=utf-8';
alias /etc/v2ray-agent/subscribe/\$1/\$2; alias /etc/v2ray-agent/subscribe/\$1/\$2;
@ -1424,7 +1427,7 @@ server {
server_name ${domain}; server_name ${domain};
root ${nginxStaticPath}; root ${nginxStaticPath};
location ~ ^/s/(clashMeta|default|clashMetaProfiles)/(.*) { location ~ ^/s/(clashMeta|default|clashMetaProfiles|sing-box)/(.*) {
proxy_set_header X-Real-IP \$proxy_protocol_addr; proxy_set_header X-Real-IP \$proxy_protocol_addr;
default_type 'text/plain; charset=utf-8'; default_type 'text/plain; charset=utf-8';
alias /etc/v2ray-agent/subscribe/\$1/\$2; alias /etc/v2ray-agent/subscribe/\$1/\$2;
@ -1444,7 +1447,7 @@ server {
real_ip_header proxy_protocol; real_ip_header proxy_protocol;
root ${nginxStaticPath}; root ${nginxStaticPath};
location ~ ^/s/(clashMeta|default|clashMetaProfiles)/(.*) { location ~ ^/s/(clashMeta|default|clashMetaProfiles|sing-box)/(.*) {
proxy_set_header X-Real-IP \$proxy_protocol_addr; proxy_set_header X-Real-IP \$proxy_protocol_addr;
default_type 'text/plain; charset=utf-8'; default_type 'text/plain; charset=utf-8';
alias /etc/v2ray-agent/subscribe/\$1/\$2; alias /etc/v2ray-agent/subscribe/\$1/\$2;
@ -1804,7 +1807,7 @@ nginxBlog() {
if [[ "${nginxBlogInstallStatus}" == "y" ]]; then if [[ "${nginxBlogInstallStatus}" == "y" ]]; then
rm -rf "${nginxStaticPath}" rm -rf "${nginxStaticPath}"
randomNum=$((RANDOM % 6 + 1)) randomNum=$((RANDOM % 6 + 1))
wget -q -P "${nginxStaticPath}" https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/blog/unable/html${randomNum}.zip >/dev/null wget -q "${wgetShowProgressStatus}" -P "${nginxStaticPath}" https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/blog/unable/html${randomNum}.zip >/dev/null
unzip -o "${nginxStaticPath}html${randomNum}.zip" -d "${nginxStaticPath}" >/dev/null unzip -o "${nginxStaticPath}html${randomNum}.zip" -d "${nginxStaticPath}" >/dev/null
rm -f "${nginxStaticPath}html${randomNum}.zip*" rm -f "${nginxStaticPath}html${randomNum}.zip*"
echoContent green " ---> 添加伪装站点成功" echoContent green " ---> 添加伪装站点成功"
@ -1812,7 +1815,7 @@ nginxBlog() {
else else
randomNum=$((RANDOM % 6 + 1)) randomNum=$((RANDOM % 6 + 1))
rm -rf "${nginxStaticPath}" rm -rf "${nginxStaticPath}"
wget -q -P "${nginxStaticPath}" https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/blog/unable/html${randomNum}.zip wget -q "${wgetShowProgressStatus}" -P "${nginxStaticPath}" https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/blog/unable/html${randomNum}.zip
unzip -o "${nginxStaticPath}html${randomNum}.zip" -d "${nginxStaticPath}" >/dev/null unzip -o "${nginxStaticPath}html${randomNum}.zip" -d "${nginxStaticPath}" >/dev/null
rm -f "${nginxStaticPath}html${randomNum}.zip*" rm -f "${nginxStaticPath}html${randomNum}.zip*"
echoContent green " ---> 添加伪装站点成功" echoContent green " ---> 添加伪装站点成功"
@ -3158,7 +3161,7 @@ EOF
# 下载sing-box geosite db # 下载sing-box geosite db
downloadSingBoxGeositeDB() { downloadSingBoxGeositeDB() {
if [[ ! -f "${singBoxConfigPath}geosite.db" ]]; then if [[ ! -f "${singBoxConfigPath}geosite.db" ]]; then
wget -q -P "${singBoxConfigPath}" https://github.com/Johnshall/sing-geosite/releases/latest/download/geosite.db wget -q "${wgetShowProgressStatus}" -P "${singBoxConfigPath}" https://github.com/Johnshall/sing-geosite/releases/latest/download/geosite.db
fi fi
} }
@ -4430,7 +4433,10 @@ EOF
removeSingBoxConfig 01_direct_outbound removeSingBoxConfig 01_direct_outbound
removeSingBoxConfig block_domain_outbound removeSingBoxConfig block_domain_outbound
} }
# 初始化 sing-box订阅配置
initSubscribeLocalConfig() {
rm -rf /etc/v2ray-agent/subscribe_local/sing-box/*
}
# 通用 # 通用
defaultBase64Code() { defaultBase64Code() {
local type=$1 local type=$1
@ -4441,7 +4447,10 @@ defaultBase64Code() {
local path=$6 local path=$6
local user= local user=
user=$(echo "${email}" | awk -F "[-]" '{print $1}') user=$(echo "${email}" | awk -F "[-]" '{print $1}')
if [[ ! -f "/etc/v2ray-agent/subscribe_local/sing-box/${user}" ]]; then
echo [] >"/etc/v2ray-agent/subscribe_local/sing-box/${user}"
fi
local singBoxSubscribeLocalConfig=
if [[ "${type}" == "vlesstcp" ]]; then if [[ "${type}" == "vlesstcp" ]]; then
echoContent yellow " ---> 通用格式(VLESS+TCP+TLS_Vision)" echoContent yellow " ---> 通用格式(VLESS+TCP+TLS_Vision)"
@ -4464,6 +4473,9 @@ EOF
flow: xtls-rprx-vision flow: xtls-rprx-vision
client-fingerprint: chrome client-fingerprint: chrome
EOF EOF
singBoxSubscribeLocalConfig=$(jq -r ". += [{\"tag\":\"${email}\",\"type\":\"vless\",\"server\":\"${currentHost}\",\"server_port\":${port},\"uuid\":\"${id}\",\"flow\":\"xtls-rprx-vision\",\"tls\":{\"enabled\":true,\"server_name\":\"${currentHost}\",\"utls\":{\"enabled\":true,\"fingerprint\":\"chrome\"}},\"packet_encoding\":\"xudp\"}]" "/etc/v2ray-agent/subscribe_local/sing-box/${user}")
echo "${singBoxSubscribeLocalConfig}" | jq . >"/etc/v2ray-agent/subscribe_local/sing-box/${user}"
echoContent yellow " ---> 二维码 VLESS(VLESS+TCP+TLS_Vision)" echoContent yellow " ---> 二维码 VLESS(VLESS+TCP+TLS_Vision)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${currentHost}%3A${port}%3Fencryption%3Dnone%26fp%3Dchrome%26security%3Dtls%26type%3Dtcp%26${currentHost}%3D${currentHost}%26headerType%3Dnone%26sni%3D${currentHost}%26flow%3Dxtls-rprx-vision%23${email}\n" echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${currentHost}%3A${port}%3Fencryption%3Dnone%26fp%3Dchrome%26security%3Dtls%26type%3Dtcp%26${currentHost}%3D${currentHost}%26headerType%3Dnone%26sni%3D${currentHost}%26flow%3Dxtls-rprx-vision%23${email}\n"
@ -4498,6 +4510,10 @@ EOF
headers: headers:
Host: ${currentHost} Host: ${currentHost}
EOF EOF
singBoxSubscribeLocalConfig=$(jq -r ". += [{\"tag\":\"${email}\",\"type\":\"vmess\",\"server\":\"${add}\",\"server_port\":${port},\"uuid\":\"${id}\",\"alter_id\":0,\"tls\":{\"enabled\":true,\"server_name\":\"${currentHost}\",\"utls\":{\"enabled\":true,\"fingerprint\":\"chrome\"}},\"packet_encoding\":\"packetaddr\",\"transport\":{\"type\":\"ws\",\"path\":\"${path}\",\"max_early_data\":2048,\"early_data_header_name\":\"Sec-WebSocket-Protocol\"}}]" "/etc/v2ray-agent/subscribe_local/sing-box/${user}")
echo "${singBoxSubscribeLocalConfig}" | jq . >"/etc/v2ray-agent/subscribe_local/sing-box/${user}"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vmess://${qrCodeBase64Default}\n" echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vmess://${qrCodeBase64Default}\n"
elif [[ "${type}" == "vlessws" ]]; then elif [[ "${type}" == "vlessws" ]]; then
@ -4528,6 +4544,9 @@ EOF
Host: ${currentHost} Host: ${currentHost}
EOF EOF
singBoxSubscribeLocalConfig=$(jq -r ". += [{\"tag\":\"${email}\",\"type\":\"vless\",\"server\":\"${add}\",\"server_port\":${port},\"uuid\":\"${id}\",\"flow\":\"\",\"tls\":{\"enabled\":true,\"server_name\":\"${currentHost}\",\"utls\":{\"enabled\":true,\"fingerprint\":\"chrome\"}},\"multiplex\":{\"enabled\":false,\"protocol\":\"smux\",\"max_streams\":32},\"packet_encoding\":\"xudp\",\"transport\":{\"type\":\"ws\",\"path\":\"/${currentPath}ws\",\"headers\":{\"Host\":\"${port}\"}}}]" "/etc/v2ray-agent/subscribe_local/sing-box/${user}")
echo "${singBoxSubscribeLocalConfig}" | jq . >"/etc/v2ray-agent/subscribe_local/sing-box/${user}"
echoContent yellow " ---> 二维码 VLESS(VLESS+WS+TLS)" echoContent yellow " ---> 二维码 VLESS(VLESS+WS+TLS)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${add}%3A${port}%3Fencryption%3Dnone%26security%3Dtls%26type%3Dws%26host%3D${currentHost}%26fp%3Dchrome%26sni%3D${currentHost}%26path%3D%252f${currentPath}ws%23${email}" echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${add}%3A${port}%3Fencryption%3Dnone%26security%3Dtls%26type%3Dws%26host%3D${currentHost}%26fp%3Dchrome%26sni%3D${currentHost}%26path%3D%252f${currentPath}ws%23${email}"
@ -4556,6 +4575,10 @@ EOF
grpc-opts: grpc-opts:
grpc-service-name: ${currentPath}grpc grpc-service-name: ${currentPath}grpc
EOF EOF
singBoxSubscribeLocalConfig=$(jq -r ". += [{\"tag\":\"${email}\",\"type\": \"vless\",\"server\": \"${add}\",\"server_port\": ${port},\"uuid\": \"${id}\",\"tls\": { \"enabled\": true, \"server_name\": \"${currentHost}\", \"utls\": { \"enabled\": true, \"fingerprint\": \"chrome\" }},\"packet_encoding\": \"xudp\",\"transport\": { \"type\": \"grpc\", \"service_name\": \"${currentPath}grpc\"}}]" "/etc/v2ray-agent/subscribe_local/sing-box/${user}")
echo "${singBoxSubscribeLocalConfig}" | jq . >"/etc/v2ray-agent/subscribe_local/sing-box/${user}"
echoContent yellow " ---> 二维码 VLESS(VLESS+gRPC+TLS)" echoContent yellow " ---> 二维码 VLESS(VLESS+gRPC+TLS)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${add}%3A${port}%3Fencryption%3Dnone%26security%3Dtls%26type%3Dgrpc%26host%3D${currentHost}%26serviceName%3D${currentPath}grpc%26fp%3Dchrome%26path%3D${currentPath}grpc%26sni%3D${currentHost}%26alpn%3Dh2%23${email}" echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${add}%3A${port}%3Fencryption%3Dnone%26security%3Dtls%26type%3Dgrpc%26host%3D${currentHost}%26serviceName%3D${currentPath}grpc%26fp%3Dchrome%26path%3D${currentPath}grpc%26sni%3D${currentHost}%26alpn%3Dh2%23${email}"
@ -4578,6 +4601,9 @@ EOF
udp: true udp: true
sni: ${currentHost} sni: ${currentHost}
EOF EOF
singBoxSubscribeLocalConfig=$(jq -r ". += [{\"tag\":\"${email}\",\"type\":\"trojan\",\"server\":\"${currentHost}\",\"server_port\":${port},\"password\":\"${id}\",\"tls\":{\"alpn\":[\"http/1.1\"],\"enabled\":true,\"server_name\":\"${currentHost}\",\"utls\":{\"enabled\":true,\"fingerprint\":\"chrome\"}}}]" "/etc/v2ray-agent/subscribe_local/sing-box/${user}")
echo "${singBoxSubscribeLocalConfig}" | jq . >"/etc/v2ray-agent/subscribe_local/sing-box/${user}"
echoContent yellow " ---> 二维码 Trojan(TLS)" echoContent yellow " ---> 二维码 Trojan(TLS)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=trojan%3a%2f%2f${id}%40${currentHost}%3a${port}%3fpeer%3d${currentHost}%26fp%3Dchrome%26sni%3d${currentHost}%26alpn%3Dhttp/1.1%23${email}\n" echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=trojan%3a%2f%2f${id}%40${currentHost}%3a${port}%3fpeer%3d${currentHost}%26fp%3Dchrome%26sni%3d${currentHost}%26alpn%3Dhttp/1.1%23${email}\n"
@ -4601,6 +4627,10 @@ EOF
grpc-opts: grpc-opts:
grpc-service-name: ${currentPath}trojangrpc grpc-service-name: ${currentPath}trojangrpc
EOF EOF
singBoxSubscribeLocalConfig=$(jq -r ". += [{\"tag\":\"${email}\",\"type\":\"trojan\",\"server\":\"${add}\",\"server_port\":${port},\"password\":\"${id}\",\"tls\":{\"enabled\":true,\"server_name\":\"${currentHost}\",\"insecure\":true,\"utls\":{\"enabled\":true,\"fingerprint\":\"chrome\"}},\"transport\":{\"type\":\"grpc\",\"service_name\":\"${currentPath}trojangrpc\",\"idle_timeout\":\"15s\",\"ping_timeout\":\"15s\",\"permit_without_stream\":false},\"multiplex\":{\"enabled\":false,\"protocol\":\"smux\",\"max_streams\":32}}]" "/etc/v2ray-agent/subscribe_local/sing-box/${user}")
echo "${singBoxSubscribeLocalConfig}" | jq . >"/etc/v2ray-agent/subscribe_local/sing-box/${user}"
echoContent yellow " ---> 二维码 Trojan gRPC(TLS)" echoContent yellow " ---> 二维码 Trojan gRPC(TLS)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=trojan%3a%2f%2f${id}%40${add}%3a${port}%3Fencryption%3Dnone%26fp%3Dchrome%26security%3Dtls%26peer%3d${currentHost}%26type%3Dgrpc%26sni%3d${currentHost}%26path%3D${currentPath}trojangrpc%26alpn%3Dh2%26serviceName%3D${currentPath}trojangrpc%23${email}\n" echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=trojan%3a%2f%2f${id}%40${add}%3a${port}%3Fencryption%3Dnone%26fp%3Dchrome%26security%3Dtls%26peer%3d${currentHost}%26type%3Dgrpc%26sni%3d${currentHost}%26path%3D${currentPath}trojangrpc%26alpn%3Dh2%26serviceName%3D${currentPath}trojangrpc%23${email}\n"
@ -4626,6 +4656,10 @@ EOF
up: "${hysteria2ClientUploadSpeed} Mbps" up: "${hysteria2ClientUploadSpeed} Mbps"
down: "${hysteria2ClientDownloadSpeed} Mbps" down: "${hysteria2ClientDownloadSpeed} Mbps"
EOF EOF
singBoxSubscribeLocalConfig=$(jq -r ". += [{\"tag\":\"${email}\",\"type\":\"hysteria2\",\"server\":\"${currentHost}\",\"server_port\":${port},\"up_mbps\":\"${hysteria2ClientUploadSpeed}\",\"down_mbps\":\"${hysteria2ClientDownloadSpeed}Mbps\",\"password\":\"${id}\",\"tls\":{\"enabled\":true,\"server_name\":\"${currentHost}\",\"alpn\":[\"h3\"]}}]" "/etc/v2ray-agent/subscribe_local/sing-box/${user}")
echo "${singBoxSubscribeLocalConfig}" | jq . >"/etc/v2ray-agent/subscribe_local/sing-box/${user}"
echoContent yellow " ---> 二维码 Hysteria2(TLS)" echoContent yellow " ---> 二维码 Hysteria2(TLS)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=hysteria2%3A%2F%2F${id}%40${currentHost}%3A${port}%3Fpeer%3D${currentHost}%26insecure%3D0%26sni%3D${currentHost}%26alpn%3Dh3%23${email}\n" echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=hysteria2%3A%2F%2F${id}%40${currentHost}%3A${port}%3Fpeer%3D${currentHost}%26insecure%3D0%26sni%3D${currentHost}%26alpn%3Dh3%23${email}\n"
@ -4660,6 +4694,10 @@ EOF
short-id: 6ba85179e30d4fc2 short-id: 6ba85179e30d4fc2
client-fingerprint: chrome client-fingerprint: chrome
EOF EOF
singBoxSubscribeLocalConfig=$(jq -r ". += [{\"tag\":\"${email}\",\"type\":\"vless\",\"server\":\"$(getPublicIP)\",\"server_port\":${port},\"uuid\":\"${id}\",\"flow\":\"xtls-rprx-vision\",\"tls\":{\"enabled\":true,\"server_name\":\"${realityServerName}\",\"utls\":{\"enabled\":true,\"fingerprint\":\"chrome\"},\"reality\":{\"enabled\":true,\"public_key\":\"${publicKey}\",\"short_id\":\"6ba85179e30d4fc2\"}},\"packet_encoding\":\"xudp\"}]" "/etc/v2ray-agent/subscribe_local/sing-box/${user}")
echo "${singBoxSubscribeLocalConfig}" | jq . >"/etc/v2ray-agent/subscribe_local/sing-box/${user}"
echoContent yellow " ---> 二维码 VLESS(VLESS+reality+uTLS+Vision)" echoContent yellow " ---> 二维码 VLESS(VLESS+reality+uTLS+Vision)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40$(getPublicIP)%3A${port}%3Fencryption%3Dnone%26security%3Dreality%26type%3Dtcp%26sni%3D${realityServerName}%26fp%3Dchrome%26pbk%3D${publicKey}%26sid%3D6ba85179e30d4fc2%26flow%3Dxtls-rprx-vision%23${email}\n" echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40$(getPublicIP)%3A${port}%3Fencryption%3Dnone%26security%3Dreality%26type%3Dtcp%26sni%3D${realityServerName}%26fp%3Dchrome%26pbk%3D${publicKey}%26sid%3D6ba85179e30d4fc2%26flow%3Dxtls-rprx-vision%23${email}\n"
@ -4696,6 +4734,10 @@ EOF
grpc-service-name: "grpc" grpc-service-name: "grpc"
client-fingerprint: chrome client-fingerprint: chrome
EOF EOF
singBoxSubscribeLocalConfig=$(jq -r ". += [{\"tag\":\"${email}\",\"type\":\"vless\",\"server\":\"$(getPublicIP)\",\"server_port\":${port},\"uuid\":\"${id}\",\"tls\":{\"enabled\":true,\"server_name\":\"${realityServerName}\",\"utls\":{\"enabled\":true,\"fingerprint\":\"chrome\"},\"reality\":{\"enabled\":true,\"public_key\":\"${publicKey}\",\"short_id\":\"6ba85179e30d4fc2\"}},\"packet_encoding\":\"xudp\",\"transport\":{\"type\":\"grpc\",\"service_name\":\"grpc\"}}]" "/etc/v2ray-agent/subscribe_local/sing-box/${user}")
echo "${singBoxSubscribeLocalConfig}" | jq . >"/etc/v2ray-agent/subscribe_local/sing-box/${user}"
echoContent yellow " ---> 二维码 VLESS(VLESS+reality+uTLS+gRPC)" echoContent yellow " ---> 二维码 VLESS(VLESS+reality+uTLS+gRPC)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40$(getPublicIP)%3A${port}%3Fencryption%3Dnone%26security%3Dreality%26type%3Dgrpc%26sni%3D${realityServerName}%26fp%3Dchrome%26pbk%3D${publicKey}%26sid%3D6ba85179e30d4fc2%26path%3Dgrpc%26serviceName%3Dgrpc%23${email}\n" echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40$(getPublicIP)%3A${port}%3Fencryption%3Dnone%26security%3Dreality%26type%3Dgrpc%26sni%3D${realityServerName}%26fp%3Dchrome%26pbk%3D${publicKey}%26sid%3D6ba85179e30d4fc2%26path%3Dgrpc%26serviceName%3Dgrpc%23${email}\n"
elif [[ "${type}" == "tuic" ]]; then elif [[ "${type}" == "tuic" ]]; then
@ -4733,6 +4775,10 @@ EOF
reduce-rtt: true reduce-rtt: true
sni: ${email} sni: ${email}
EOF EOF
singBoxSubscribeLocalConfig=$(jq -r ". += [{\"tag\":\"${email}\",\"type\": \"tuic\",\"server\": \"${currentHost}\",\"server_port\": ${port},\"uuid\": \"${id}\",\"password\": \"${id}\",\"congestion_control\": \"${tuicAlgorithm}\",\"tls\": {\"enabled\": true,\"server_name\": \"${currentHost}\",\"alpn\": [\"h3\"]}}]" "/etc/v2ray-agent/subscribe_local/sing-box/${user}")
echo "${singBoxSubscribeLocalConfig}" | jq . >"/etc/v2ray-agent/subscribe_local/sing-box/${user}"
echoContent yellow "\n ---> 二维码 Tuic" echoContent yellow "\n ---> 二维码 Tuic"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=tuic%3A%2F%2F${tuicUUID}%3A${tuicPassword}%40${currentHost}%3A${tuicPort}%3Fcongestion_control%3D${tuicAlgorithm}%26alpn%3Dh3%26sni%3D${currentHost}%26udp_relay_mode%3Dquic%26allow_insecure%3D0%23${email}\n" echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=tuic%3A%2F%2F${tuicUUID}%3A${tuicPassword}%40${currentHost}%3A${tuicPort}%3Fcongestion_control%3D${tuicAlgorithm}%26alpn%3Dh3%26sni%3D${currentHost}%26udp_relay_mode%3Dquic%26allow_insecure%3D0%23${email}\n"
elif [[ "${type}" == "naive" ]]; then elif [[ "${type}" == "naive" ]]; then
@ -4758,6 +4804,7 @@ showAccounts() {
echo echo
echoContent skyBlue "\n进度 $1/${totalProgress} : 账号" echoContent skyBlue "\n进度 $1/${totalProgress} : 账号"
initSubscribeLocalConfig
# VLESS TCP # VLESS TCP
if echo ${currentInstallProtocolType} | grep -q ",0,"; then if echo ${currentInstallProtocolType} | grep -q ",0,"; then
@ -5069,7 +5116,7 @@ updateNginxBlog() {
if [[ "${selectInstallNginxBlogType}" =~ ^[1-9]$ ]]; then if [[ "${selectInstallNginxBlogType}" =~ ^[1-9]$ ]]; then
rm -rf "${nginxStaticPath}" rm -rf "${nginxStaticPath}"
wget -q -P "${nginxStaticPath}" "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/blog/unable/html${selectInstallNginxBlogType}.zip" >/dev/null wget -q "${wgetShowProgressStatus}" -P "${nginxStaticPath}" "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/blog/unable/html${selectInstallNginxBlogType}.zip" >/dev/null
unzip -o "${nginxStaticPath}html${selectInstallNginxBlogType}.zip" -d "${nginxStaticPath}" >/dev/null unzip -o "${nginxStaticPath}html${selectInstallNginxBlogType}.zip" -d "${nginxStaticPath}" >/dev/null
rm -f "${nginxStaticPath}html${selectInstallNginxBlogType}.zip*" rm -f "${nginxStaticPath}html${selectInstallNginxBlogType}.zip*"
@ -7615,7 +7662,7 @@ server {
${nginxSubscribeSSL} ${nginxSubscribeSSL}
client_max_body_size 100m; client_max_body_size 100m;
root ${nginxStaticPath}; root ${nginxStaticPath};
location ~ ^/s/(clashMeta|default|clashMetaProfiles)/(.*) { location ~ ^/s/(clashMeta|default|clashMetaProfiles|sing-box)/(.*) {
default_type 'text/plain; charset=utf-8'; default_type 'text/plain; charset=utf-8';
alias /etc/v2ray-agent/subscribe/\$1/\$2; alias /etc/v2ray-agent/subscribe/\$1/\$2;
} }
@ -7681,44 +7728,6 @@ addOtherSubscribe() {
echo "${remoteSubscribeUrl}" >>/etc/v2ray-agent/subscribe_remote/remoteSubscribeUrl echo "${remoteSubscribeUrl}" >>/etc/v2ray-agent/subscribe_remote/remoteSubscribeUrl
subscribe subscribe
# local remoteUrl=
# remoteUrl=$(echo "${remoteSubscribeUrl}" | awk -F "[:]" '{print $1":"$2}')
#
# local serverAlias=
# serverAlias=$(echo "${remoteSubscribeUrl}" | awk -F "[:]" '{print $3}')
#
# if [[ -n $(ls /etc/v2ray-agent/subscribe/clashMeta/) || -n $(ls /etc/v2ray-agent/subscribe/default/) ]]; then
# find /etc/v2ray-agent/subscribe_local/default/* | while read -r email; do
# email=$(echo "${email}" | awk -F "[d][e][f][a][u][l][t][/]" '{print $2}')
#
# local emailMd5=
# emailMd5=$(echo -n "${email}$(cat "/etc/v2ray-agent/subscribe_local/subscribeSalt")"$'\n' | md5sum | awk '{print $1}')
#
# local default=
# default=$(curl -s -4 "https://${remoteUrl}/s/default/${emailMd5}")
#
# if ! echo "${default}" | grep -q "nginx" && [[ -n "${default}" ]]; then
# default=$(echo "${default}" | base64 -d | sed "s/${email}/${email}_${serverAlias}/g" 2>&1)
#
# echo "${default}" >>"/etc/v2ray-agent/subscribe_remote/default/${email}_${remoteUrl}"
# echoContent green " ---> 通用订阅 ${email} 添加成功"
# else
# echoContent red " ---> 通用订阅 ${email} 不存在"
# fi
#
# local clashMetaProxies=
# clashMetaProxies=$(curl -s -4 "https://${remoteUrl}/s/clashMeta/${emailMd5}" | sed '/proxies:/d' | sed "s/${email}/${email}_${serverAlias}/g")
# if ! echo "${default}" | grep -q "nginx" && [[ -n "${clashMetaProxies}" ]]; then
# echo "${clashMetaProxies}" >>"/etc/v2ray-agent/subscribe_remote/clashMeta/${email}_${remoteUrl}"
#
# echoContent green " ---> clashMeta订阅 ${email} 添加成功"
# else
# echoContent red " ---> clashMeta订阅 ${email}不存在"
# fi
# done
# else
# echoContent red " ---> 请先查看订阅,再进行添加订阅"
# fi
fi fi
} }
# clashMeta配置文件 # clashMeta配置文件
@ -8132,6 +8141,7 @@ subscribe() {
rm -rf /etc/v2ray-agent/subscribe/clashMeta/* rm -rf /etc/v2ray-agent/subscribe/clashMeta/*
rm -rf /etc/v2ray-agent/subscribe_local/default/* rm -rf /etc/v2ray-agent/subscribe_local/default/*
rm -rf /etc/v2ray-agent/subscribe_local/clashMeta/* rm -rf /etc/v2ray-agent/subscribe_local/clashMeta/*
rm -rf /etc/v2ray-agent/subscribe_local/sing-box/*
showAccounts >/dev/null showAccounts >/dev/null
@ -8189,6 +8199,19 @@ subscribe() {
echoContent yellow "在线二维码:https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=https://${currentDomain}/s/clashMetaProfiles/${emailMd5}\n" echoContent yellow "在线二维码:https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=https://${currentDomain}/s/clashMetaProfiles/${emailMd5}\n"
echo "${subscribeType}://${currentDomain}/s/clashMetaProfiles/${emailMd5}" | qrencode -s 10 -m 1 -t UTF8 echo "${subscribeType}://${currentDomain}/s/clashMetaProfiles/${emailMd5}" | qrencode -s 10 -m 1 -t UTF8
fi fi
# sing-box
if [[ -f "/etc/v2ray-agent/subscribe_local/sing-box/${email}" ]]; then
echoContent skyBlue " ---> 下载 sing-box 通用配置文件"
wget -O "/etc/v2ray-agent/subscribe/sing-box/${emailMd5}" -q "${wgetShowProgressStatus}" "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/documents/sing-box.json"
jq ".outbounds=$(jq ".outbounds|map(if has(\"outbounds\") then .outbounds += $(jq ".|map(.tag)" "/etc/v2ray-agent/subscribe_local/sing-box/${email}") else . end)" "/etc/v2ray-agent/subscribe/sing-box/${emailMd5}")" "/etc/v2ray-agent/subscribe/sing-box/${emailMd5}" >"/etc/v2ray-agent/subscribe/sing-box/${emailMd5}_tmp" && mv "/etc/v2ray-agent/subscribe/sing-box/${emailMd5}_tmp" "/etc/v2ray-agent/subscribe/sing-box/${emailMd5}"
jq ".outbounds += $(jq '.' "/etc/v2ray-agent/subscribe_local/sing-box/${email}")" "/etc/v2ray-agent/subscribe/sing-box/${emailMd5}" >"/etc/v2ray-agent/subscribe/sing-box/${emailMd5}_tmp" && mv "/etc/v2ray-agent/subscribe/sing-box/${emailMd5}_tmp" "/etc/v2ray-agent/subscribe/sing-box/${emailMd5}"
echoContent skyBlue "\n----------sing-box订阅----------\n"
echoContent yellow "url:${subscribeType}://${currentDomain}/s/sing-box/${emailMd5}\n"
echoContent yellow "在线二维码:https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=https://${currentDomain}/s/sing-box/${emailMd5}\n"
echo "${subscribeType}://${currentDomain}/s/sing-box/${emailMd5}" | qrencode -s 10 -m 1 -t UTF8
fi
echoContent skyBlue "--------------------------------------------------------------" echoContent skyBlue "--------------------------------------------------------------"
done done
@ -8680,7 +8703,7 @@ menu() {
cd "$HOME" || exit cd "$HOME" || exit
echoContent red "\n==============================================================" echoContent red "\n=============================================================="
echoContent green "作者mack-a" echoContent green "作者mack-a"
echoContent green "当前版本v3.2.18" echoContent green "当前版本v3.2.19"
echoContent green "Githubhttps://github.com/mack-a/v2ray-agent" echoContent green "Githubhttps://github.com/mack-a/v2ray-agent"
echoContent green "描述:八合一共存脚本\c" echoContent green "描述:八合一共存脚本\c"
showInstallStatus showInstallStatus