2 Commits

Author SHA1 Message Date
mack-a 170bf2ec88 feat(脚本): 修改系统判断 2025-05-08 11:30:33 +08:00
mack-a 7c9186c32d feat(脚本): 增加anytls 2025-04-29 16:01:44 +08:00
2 changed files with 190 additions and 101 deletions
+23 -19
View File
@@ -20,38 +20,36 @@
"servers": [
{
"tag": "dns_proxy",
"address": "https://1.1.1.1/dns-query",
"address_resolver": "dns_resolver",
"strategy": "ipv4_only",
"detour": "手动切换"
"type": "https",
"server": "1.1.1.1",
"server_port": 443,
"path": "/dns-query",
"domain_resolver": "dns_resolver",
"strategy": "prefer_ipv4"
},
{
"tag": "dns_direct",
"address": "h3://dns.alidns.com/dns-query",
"address_resolver": "dns_resolver",
"strategy": "ipv4_only",
"detour": "direct"
"type": "h3",
"server": "dns.alidns.com",
"server_port": 443,
"path": "/dns-query",
"domain_resolver": "dns_resolver",
"strategy": "prefer_ipv4"
},
{
"tag": "google",
"address": "tls://8.8.4.4"
},
{
"tag": "dns_block",
"address": "rcode://success"
"type": "tls",
"server": "8.8.4.4",
"domain_resolver": "dns_resolver",
"strategy": "prefer_ipv4"
},
{
"tag": "dns_resolver",
"address": "114.114.114.114",
"strategy": "ipv4_only",
"detour": "direct"
"strategy": "prefer_ipv4"
}
],
"rules": [
{
"outbound": "any",
"server": "dns_direct"
},
{
"clash_mode": "direct",
"server": "dns_direct"
@@ -112,6 +110,12 @@
}
],
"outbounds": [
{
"domain_resolver": {
"server": "dns_direct",
"strategy": "prefer_ipv4"
}
},
{
"type": "urltest",
"tag": "自动选择",
+167 -82
View File
@@ -434,6 +434,7 @@ readInstallProtocolType() {
singBoxVLESSRealityVisionServerName=
singBoxVLESSRealityGRPCPort=
singBoxVLESSRealityGRPCServerName=
singBoxAnyTLSPort=
singBoxTuicPort=
singBoxNaivePort=
singBoxVMessWSPort=
@@ -461,12 +462,6 @@ readInstallProtocolType() {
xrayVLESSRealityXHTTPServerName=$(jq -r .inbounds[0].streamSettings.realitySettings.serverNames[0] "${row}.json")
currentRealityXHTTPPublicKey=$(jq -r .inbounds[0].streamSettings.realitySettings.publicKey "${row}.json")
# currentRealityXHTTPPrivateKey=$(jq -r .inbounds[0].streamSettings.realitySettings.privateKey "${row}.json")
# if [[ "${coreInstallType}" == "2" ]]; then
# frontingType=03_VLESS_WS_inbounds
# singBoxVLESSWSPort=$(jq .inbounds[0].listen_port "${row}.json")
# fi
fi
if echo "${row}" | grep -q trojan_gRPC_inbounds; then
@@ -549,6 +544,13 @@ readInstallProtocolType() {
singBoxNaivePort=$(jq .inbounds[0].listen_port "${row}.json")
fi
fi
if echo "${row}" | grep -q anytls_inbounds; then
currentInstallProtocolType="${currentInstallProtocolType}13,"
if [[ "${coreInstallType}" == "2" ]]; then
frontingType=13_anytls_inbounds
singBoxAnyTLSPort=$(jq .inbounds[0].server_port "${row}.json")
fi
fi
if echo "${row}" | grep -q VMess_HTTPUpgrade_inbounds; then
currentInstallProtocolType="${currentInstallProtocolType}11,"
if [[ "${coreInstallType}" == "2" ]]; then
@@ -861,12 +863,13 @@ readConfigHostPathUUID() {
elif [[ "${coreInstallType}" == "2" ]]; then
if [[ -n "${frontingType}" ]]; then
currentHost=$(jq -r .inbounds[0].tls.server_name ${configPath}${frontingType}.json)
currentUUID=$(jq -r .inbounds[0].users[0].uuid ${configPath}${frontingType}.json)
currentClients=$(jq -r .inbounds[0].users ${configPath}${frontingType}.json)
if echo ${currentInstallProtocolType} | grep -q ",11," && [[ "${currentHost}" == "null" ]]; then
currentHost=$(grep 'server_name' <${nginxConfigPath}sing_box_VMess_HTTPUpgrade.conf | awk '{print $2}')
currentHost=${currentHost//;/}
fi
currentUUID=$(jq -r .inbounds[0].users[0].uuid ${configPath}${frontingType}.json)
currentClients=$(jq -r .inbounds[0].users ${configPath}${frontingType}.json)
else
currentUUID=$(jq -r .inbounds[0].users[0].uuid ${configPath}${frontingTypeReality}.json)
currentClients=$(jq -r .inbounds[0].users ${configPath}${frontingTypeReality}.json)
@@ -984,6 +987,18 @@ showInstallStatus() {
if echo ${currentInstallProtocolType} | grep -q ",9,"; then
echoContent yellow "Tuic \c"
fi
if echo ${currentInstallProtocolType} | grep -q ",10,"; then
echoContent yellow "Naive \c"
fi
if echo ${currentInstallProtocolType} | grep -q ",11,"; then
echoContent yellow "VMess+TLS+HTTPUpgrade \c"
fi
if echo ${currentInstallProtocolType} | grep -q ",12,"; then
echoContent yellow "VLESS+XHTTP \c"
fi
if echo ${currentInstallProtocolType} | grep -q ",13,"; then
echoContent yellow "AnyTLS \c"
fi
fi
}
@@ -1743,8 +1758,12 @@ initDNSAPIConfig() {
exit 0
fi
read -r -p "是否使用*.${dnsTLSDomain}进行API申请通配符证书?[y/n]:" dnsAPIStatus
# if [[ "${dnsAPIStatus}" != "y" ]]; then
# exit 0
# fi
fi
elif [[ "$1" == "aliyun" ]]; then
# echoContent yellow "\n CF_Token参考配置教程:https://www.v2ray-agent.com/archives/1701160377972\n"
read -r -p "请输入Ali Key:" aliKey
read -r -p "请输入Ali Secret:" aliSecret
if [[ -z "${aliKey}" || -z "${aliSecret}" ]]; then
@@ -1757,6 +1776,9 @@ initDNSAPIConfig() {
exit 0
fi
read -r -p "是否使用*.${dnsTLSDomain}进行API申请通配符证书?[y/n]:" dnsAPIStatus
if [[ "${dnsAPIStatus}" != "y" ]]; then
exit 0
fi
fi
fi
}
@@ -1821,10 +1843,10 @@ acmeInstallSSL() {
if [[ "${dnsAPIType}" == "cloudflare" ]]; then
echoContent green " ---> DNS API 生成证书中"
sudo CF_Token="${cfAPIToken}" "$HOME/.acme.sh/acme.sh" --issue -d "${dnsAPIDomain}" -d "${dnsTLSDomain}" --dns dns_cf -k ec-256 --server "${sslType}" ${sslIPv6} 2>&1 | tee -a /etc/v2ray-agent/tls/acme.log >/dev/null
sudo CF_Token="${cfAPIToken}" "$HOME/.acme.sh/acme.sh" --issue -d "${dnsAPIDomain}" --dns dns_cf -k ec-256 --server "${sslType}" ${sslIPv6} 2>&1 | tee -a /etc/v2ray-agent/tls/acme.log >/dev/null
elif [[ "${dnsAPIType}" == "aliyun" ]]; then
echoContent green " ---> DNS API 生成证书中"
sudo Ali_Key="${aliKey}" Ali_Secret="${aliSecret}" "$HOME/.acme.sh/acme.sh" --issue -d "${dnsAPIDomain}" -d "${dnsTLSDomain}" --dns dns_ali -k ec-256 --server "${sslType}" ${sslIPv6} 2>&1 | tee -a /etc/v2ray-agent/tls/acme.log >/dev/null
sudo Ali_Key="${aliKey}" Ali_Secret="${aliSecret}" "$HOME/.acme.sh/acme.sh" --issue -d "${dnsAPIDomain}" --dns dns_ali -k ec-256 --server "${sslType}" ${sslIPv6} 2>&1 | tee -a /etc/v2ray-agent/tls/acme.log >/dev/null
else
echoContent green " ---> 生成证书中"
sudo "$HOME/.acme.sh/acme.sh" --issue -d "${tlsDomain}" --standalone -k ec-256 --server "${sslType}" ${sslIPv6} 2>&1 | tee -a /etc/v2ray-agent/tls/acme.log >/dev/null
@@ -2305,7 +2327,7 @@ installSingBox() {
if [[ ! -f "/etc/v2ray-agent/sing-box/sing-box" ]]; then
version=$(curl -s "https://api.github.com/repos/SagerNet/sing-box/releases?per_page=20" | jq -r ".[]|select (.prerelease==${prereleaseStatus})|.tag_name" | head -1)
version="v1.12.0-beta.7"
echoContent green " ---> sing-box版本:${version}"
if [[ "${release}" == "alpine" ]]; then
@@ -3121,10 +3143,9 @@ initSingBoxClients() {
currentUser="{\"uuid\":\"${uuid}\",\"name\":\"${name}-VMess_HTTPUpgrade\",\"alterId\": 0}"
users=$(echo "${users}" | jq -r ". +=[${currentUser}]")
fi
if echo "${type}" | grep -q ",20,"; then
currentUser="{\"username\":\"${uuid}\",\"password\":\"${uuid}\"}"
# anytls
if echo "${type}" | grep -q ",13,"; then
currentUser="{\"password\":\"${uuid}\",\"name\":\"${name}-anytls\"}"
users=$(echo "${users}" | jq -r ". +=[${currentUser}]")
fi
@@ -3972,65 +3993,67 @@ singBoxMergeConfig() {
}
# 初始化Xray Trojan XTLS 配置文件
#initXrayFrontingConfig() {
# echoContent red " ---> Trojan暂不支持 xtls-rprx-vision"
# if [[ -z "${configPath}" ]]; then
# echoContent red " ---> 未安装,请使用脚本安装"
# menu
# exit 0
# fi
# if [[ "${coreInstallType}" != "1" ]]; then
# echoContent red " ---> 未安装可用类型"
# fi
# local xtlsType=
# if echo ${currentInstallProtocolType} | grep -q trojan; then
# xtlsType=VLESS
# else
# xtlsType=Trojan
# fi
#
# echoContent skyBlue "\n功能 1/${totalProgress} : 前置切换为${xtlsType}"
# echoContent red "\n=============================================================="
# echoContent yellow "# 注意事项\n"
# echoContent yellow "会将前置替换为${xtlsType}"
# echoContent yellow "如果前置是Trojan,查看账号时则会出现两个Trojan协议的节点,有一个不可用xtls"
# echoContent yellow "再次执行可切换至上一次的前置\n"
#
# echoContent yellow "1.切换至${xtlsType}"
# echoContent red "=============================================================="
# read -r -p "请选择:" selectType
# if [[ "${selectType}" == "1" ]]; then
#
# if [[ "${xtlsType}" == "Trojan" ]]; then
#
# local VLESSConfig
# VLESSConfig=$(cat ${configPath}${frontingType}.json)
# VLESSConfig=${VLESSConfig//"id"/"password"}
# VLESSConfig=${VLESSConfig//VLESSTCP/TrojanTCPXTLS}
# VLESSConfig=${VLESSConfig//VLESS/Trojan}
# VLESSConfig=${VLESSConfig//"vless"/"trojan"}
# VLESSConfig=${VLESSConfig//"id"/"password"}
#
# echo "${VLESSConfig}" | jq . >${configPath}02_trojan_TCP_inbounds.json
# rm ${configPath}${frontingType}.json
# elif [[ "${xtlsType}" == "VLESS" ]]; then
#
# local VLESSConfig
# VLESSConfig=$(cat ${configPath}02_trojan_TCP_inbounds.json)
# VLESSConfig=${VLESSConfig//"password"/"id"}
# VLESSConfig=${VLESSConfig//TrojanTCPXTLS/VLESSTCP}
# VLESSConfig=${VLESSConfig//Trojan/VLESS}
# VLESSConfig=${VLESSConfig//"trojan"/"vless"}
# VLESSConfig=${VLESSConfig//"password"/"id"}
#
# echo "${VLESSConfig}" | jq . >${configPath}02_VLESS_TCP_inbounds.json
# rm ${configPath}02_trojan_TCP_inbounds.json
# fi
# reloadCore
# fi
#
# exit 0
#}
initXrayFrontingConfig() {
echoContent red " ---> Trojan暂不支持 xtls-rprx-vision"
exit 0
if [[ -z "${configPath}" ]]; then
echoContent red " ---> 未安装,请使用脚本安装"
menu
exit 0
fi
if [[ "${coreInstallType}" != "1" ]]; then
echoContent red " ---> 未安装可用类型"
fi
local xtlsType=
if echo ${currentInstallProtocolType} | grep -q trojan; then
xtlsType=VLESS
else
xtlsType=Trojan
fi
echoContent skyBlue "\n功能 1/${totalProgress} : 前置切换为${xtlsType}"
echoContent red "\n=============================================================="
echoContent yellow "# 注意事项\n"
echoContent yellow "会将前置替换为${xtlsType}"
echoContent yellow "如果前置是Trojan,查看账号时则会出现两个Trojan协议的节点,有一个不可用xtls"
echoContent yellow "再次执行可切换至上一次的前置\n"
echoContent yellow "1.切换至${xtlsType}"
echoContent red "=============================================================="
read -r -p "请选择:" selectType
if [[ "${selectType}" == "1" ]]; then
if [[ "${xtlsType}" == "Trojan" ]]; then
local VLESSConfig
VLESSConfig=$(cat ${configPath}${frontingType}.json)
VLESSConfig=${VLESSConfig//"id"/"password"}
VLESSConfig=${VLESSConfig//VLESSTCP/TrojanTCPXTLS}
VLESSConfig=${VLESSConfig//VLESS/Trojan}
VLESSConfig=${VLESSConfig//"vless"/"trojan"}
VLESSConfig=${VLESSConfig//"id"/"password"}
echo "${VLESSConfig}" | jq . >${configPath}02_trojan_TCP_inbounds.json
rm ${configPath}${frontingType}.json
elif [[ "${xtlsType}" == "VLESS" ]]; then
local VLESSConfig
VLESSConfig=$(cat ${configPath}02_trojan_TCP_inbounds.json)
VLESSConfig=${VLESSConfig//"password"/"id"}
VLESSConfig=${VLESSConfig//TrojanTCPXTLS/VLESSTCP}
VLESSConfig=${VLESSConfig//Trojan/VLESS}
VLESSConfig=${VLESSConfig//"trojan"/"vless"}
VLESSConfig=${VLESSConfig//"password"/"id"}
echo "${VLESSConfig}" | jq . >${configPath}02_VLESS_TCP_inbounds.json
rm ${configPath}02_trojan_TCP_inbounds.json
fi
reloadCore
fi
exit 0
}
# 初始化sing-box端口
initSingBoxPort() {
@@ -4942,6 +4965,36 @@ EOF
elif [[ -z "$3" ]]; then
rm /etc/v2ray-agent/sing-box/conf/config/11_VMess_HTTPUpgrade_inbounds.json >/dev/null 2>&1
fi
if echo "${selectCustomInstallType}" | grep -q ",13," || [[ "$1" == "all" ]]; then
echoContent yellow "\n================== 配置 AnyTLS ==================\n"
echoContent skyBlue "\n开始配置AnyTLS协议端口"
echo
mapfile -t result < <(initSingBoxPort "${singBoxAnyTLSPort}")
echoContent green "\n ---> AnyTLS端口:${result[-1]}"
cat <<EOF >/etc/v2ray-agent/sing-box/conf/config/13_anytls_inbounds.json
{
"inbounds": [
{
"type": "anytls",
"listen": "::",
"tag":"anytls",
"listen_port": ${result[-1]},
"users": $(initSingBoxClients 13),
"tls": {
"enabled": true,
"server_name":"${sslDomain}",
"certificate_path": "/etc/v2ray-agent/tls/${sslDomain}.crt",
"key_path": "/etc/v2ray-agent/tls/${sslDomain}.key"
}
}
]
}
EOF
elif [[ -z "$3" ]]; then
rm /etc/v2ray-agent/sing-box/conf/config/13_anytls_inbounds.json >/dev/null 2>&1
fi
if [[ -z "$3" ]]; then
removeSingBoxConfig wireguard_endpoints_IPv4_route
removeSingBoxConfig wireguard_endpoints_IPv6_route
@@ -5377,8 +5430,29 @@ EOF
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vmess://${qrCodeBase64Default}\n"
fi
elif [[ "${type}" == "anytls" ]]; then
echoContent yellow " ---> AnyTLS"
echoContent green " anytls://${id}@${currentHost}:${singBoxAnyTLSPort}?peer=${currentHost}&insecure=0&sni=${currentHost}#${email}\n"
cat <<EOF >>"/etc/v2ray-agent/subscribe_local/default/${user}"
anytls://${id}@${currentHost}:${singBoxAnyTLSPort}?peer=${currentHost}&insecure=0&sni=${currentHost}#${email}
EOF
cat <<EOF >>"/etc/v2ray-agent/subscribe_local/clashMeta/${user}"
- name: "${email}"
type: anytls
port: ${singBoxAnyTLSPort}
server: ${currentHost}
password: ${id}
udp: true
sni: ${currentHost}
EOF
singBoxSubscribeLocalConfig=$(jq -r ". += [{\"tag\":\"${email}\",\"type\":\"anytls\",\"server\":\"${currentHost}\",\"server_port\":${singBoxAnyTLSPort},\"password\":\"${id}\",\"tls\":{\"enabled\":true,\"server_name\":\"${currentHost}\"}}]" "/etc/v2ray-agent/subscribe_local/sing-box/${user}")
echo "${singBoxSubscribeLocalConfig}" | jq . >"/etc/v2ray-agent/subscribe_local/sing-box/${user}"
echoContent yellow " ---> 二维码 AnyTLS"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=anytls%3A%2F%2F${id}%40${currentHost}%3A${singBoxAnyTLSPort}%3Fpeer%3D${currentHost}%26insecure%3D0%26sni%3D${currentHost}%23${email}\n"
fi
}
# 账号
@@ -5486,7 +5560,6 @@ showAccounts() {
done < <(echo "${currentCDNAddress}" | tr ',' '\n')
done
fi
# trojan tcp
if echo ${currentInstallProtocolType} | grep -q ",4,"; then
echoContent skyBlue "\n================================== Trojan TLS [不推荐] ==================================\n"
@@ -5639,6 +5712,17 @@ showAccounts() {
done < <(echo "${currentCDNAddress}" | tr ',' '\n')
done
fi
# AnyTLS
if echo ${currentInstallProtocolType} | grep -q ",13," || [[ -n "${hysteriaPort}" ]]; then
echoContent skyBlue "\n================================ AnyTLS ================================\n"
jq -r -c '.inbounds[]|.users[]' "${configPath}13_anytls_inbounds.json" | while read -r user; do
echoContent skyBlue "\n ---> 账号:$(echo "${user}" | jq -r .name)"
echo
defaultBase64Code anytls "${singBoxAnyTLSPort}" "$(echo "${user}" | jq -r .name)" "$(echo "${user}" | jq -r .password)"
done
fi
}
# 移除nginx302配置
removeNginx302() {
@@ -8083,6 +8167,7 @@ customSingBoxInstall() {
echoContent yellow "9.Tuic"
echoContent yellow "10.Naive"
echoContent yellow "11.VMess+TLS+HTTPUpgrade"
echoContent yellow "13.anytls"
read -r -p "请选择[多选][例如:1,2,3]:" selectCustomInstallType
echoContent skyBlue "--------------------------------------------------------------"
@@ -8090,7 +8175,7 @@ customSingBoxInstall() {
echoContent red " ---> 请使用英文逗号分隔"
exit 0
fi
if [[ "${selectCustomInstallType}" != "10" ]] && [[ "${selectCustomInstallType}" != "11" ]] && ((${#selectCustomInstallType} >= 2)) && ! echo "${selectCustomInstallType}" | grep -q ","; then
if [[ "${selectCustomInstallType}" != "10" ]] && [[ "${selectCustomInstallType}" != "11" ]] && [[ "${selectCustomInstallType}" != "13" ]] && ((${#selectCustomInstallType} >= 2)) && ! echo "${selectCustomInstallType}" | grep -q ","; then
echoContent red " ---> 多选请使用英文逗号分隔"
exit 0
fi
@@ -8107,7 +8192,7 @@ customSingBoxInstall() {
totalProgress=9
installTools 1
# 申请tls
if echo "${selectCustomInstallType}" | grep -q -E ",0,|,1,|,3,|,4,|,6,|,9,|,10,|,11,"; then
if echo "${selectCustomInstallType}" | grep -q -E ",0,|,1,|,3,|,4,|,6,|,9,|,10,|,11,|,13,"; then
initTLSNginxConfig 2
installTLS 3
handleNginx stop
@@ -9724,7 +9809,7 @@ menu() {
cd "$HOME" || exit
echoContent red "\n=============================================================="
echoContent green "作者:mack-a"
echoContent green "当前版本:v3.4.12"
echoContent green "当前版本:v3.4.8"
echoContent green "Githubhttps://github.com/mack-a/v2ray-agent"
echoContent green "描述:八合一共存脚本\c"
showInstallStatus
@@ -9771,9 +9856,9 @@ menu() {
2)
selectCoreInstall
;;
# 3)
# initXrayFrontingConfig 1
# ;;
3)
initXrayFrontingConfig 1
;;
4)
manageHysteria
;;