feat: реальный VLESS-тест + spiderX в конфиге
- Замена TCP-теста на реальный VLESS-тест (запуск xray + curl) Теперь ✓ работает только если VLESS-туннель действительно пропускает трафик - Добавлен spiderX в realitySettings (нужен для AmneziaVPN/tcp-vision) - Парсер: автоопределение spiderX (пустая строка для tcp, / для xhttp) - Убран вводящий в заблуждение TCP-check Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
103
ai-setup.sh
103
ai-setup.sh
@@ -63,6 +63,7 @@ flow = get('flow')
|
||||
vtype = get('type')
|
||||
if not vtype:
|
||||
vtype = 'xhttp' if not flow else 'tcp'
|
||||
spx_default = '' if vtype == 'tcp' else '/'
|
||||
|
||||
print(f'VL_UUID={uuid}')
|
||||
print(f'VL_ADDRESS={host}')
|
||||
@@ -77,10 +78,87 @@ print(f'VL_SID={get(\"sid\")}')
|
||||
print(f'VL_TYPE={vtype}')
|
||||
print(f'VL_PATH={urllib.parse.unquote(get(\"path\", \"/\"))}')
|
||||
print(f'VL_MODE={get(\"mode\", \"auto\")}')
|
||||
print(f'VL_SPX={get(\"spx\", spx_default)}')
|
||||
print(f'VL_NAME={name}')
|
||||
" "$url")"
|
||||
}
|
||||
|
||||
# ── VLESS connectivity test ────────────────────────────────────
|
||||
# Запускает xray с тестовым конфигом и проверяет curl'ом
|
||||
# Возвращает: "ok" или "fail"
|
||||
test_vless_server() {
|
||||
local url="$1" test_port="$2"
|
||||
|
||||
parse_vless_url "$url"
|
||||
|
||||
# Генерируем временный конфиг
|
||||
_TMP_CONF="/tmp/xray_test_${test_port}.json"
|
||||
_VL_XHTTP=""
|
||||
if [ "$VL_TYPE" = "xhttp" ]; then
|
||||
_VL_XHTTP=$(printf ',\n "xhttpSettings": {\n "path": "%s",\n "mode": "%s"\n }' "$VL_PATH" "$VL_MODE")
|
||||
fi
|
||||
|
||||
cat > "$_TMP_CONF" << XRAYEOF
|
||||
{
|
||||
"log": { "loglevel": "none" },
|
||||
"inbounds": [
|
||||
{
|
||||
"port": $test_port,
|
||||
"listen": "127.0.0.1",
|
||||
"protocol": "socks",
|
||||
"settings": { "udp": true }
|
||||
}
|
||||
],
|
||||
"outbounds": [
|
||||
{
|
||||
"protocol": "vless",
|
||||
"settings": {
|
||||
"vnext": [
|
||||
{
|
||||
"address": "$VL_ADDRESS",
|
||||
"port": $VL_PORT,
|
||||
"users": [
|
||||
{
|
||||
"id": "$VL_UUID",
|
||||
"encryption": "$VL_ENCRYPTION",
|
||||
"flow": "$VL_FLOW"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"streamSettings": {
|
||||
"network": "$VL_TYPE",
|
||||
"security": "$VL_SECURITY",
|
||||
"realitySettings": {
|
||||
"serverName": "$VL_SNI",
|
||||
"fingerprint": "$VL_FP",
|
||||
"publicKey": "$VL_PBK",
|
||||
"shortId": "$VL_SID",
|
||||
"spiderX": "$VL_SPX"
|
||||
}$_VL_XHTTP
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
XRAYEOF
|
||||
|
||||
# Запускаем xray
|
||||
/usr/local/bin/xray run -c "$_TMP_CONF" >/dev/null 2>&1 &
|
||||
local xpid=$!
|
||||
sleep 2
|
||||
|
||||
# Тест через SOCKS5
|
||||
local result="fail"
|
||||
if curl --socks5 "127.0.0.1:${test_port}" --max-time 5 -s https://ifconfig.co/ >/dev/null 2>&1; then
|
||||
result="ok"
|
||||
fi
|
||||
|
||||
kill $xpid 2>/dev/null; wait $xpid 2>/dev/null
|
||||
rm -f "$_TMP_CONF"
|
||||
echo "$result"
|
||||
}
|
||||
|
||||
# ── 0. Выбор режима работы (vless / direct) ─────────────────
|
||||
read -r -p "Установить встроенный vless? [Y/n] " _vless_ans
|
||||
_vless_ans="${_vless_ans:-Y}"
|
||||
@@ -90,8 +168,6 @@ if [[ "$_vless_ans" =~ ^[Yy]$ ]]; then
|
||||
# Читаем список серверов
|
||||
_VL_URLS=()
|
||||
_VL_LABELS=()
|
||||
_VL_IPS=()
|
||||
_VL_PORTS=()
|
||||
_SERVERS_FILE="$SCRIPT_DIR/home-configs/vless/servers.conf"
|
||||
|
||||
if [ ! -f "$_SERVERS_FILE" ]; then
|
||||
@@ -104,34 +180,30 @@ if [[ "$_vless_ans" =~ ^[Yy]$ ]]; then
|
||||
_vl_rest="${line#vless://}"
|
||||
_vl_rest="${_vl_rest#*@}"
|
||||
_vl_ip="${_vl_rest%%:*}"
|
||||
_vl_tmp="${_vl_rest#*:}"
|
||||
_vl_port="${_vl_tmp%%\?*}"
|
||||
_vl_name="${line##*#}"
|
||||
[[ "$_vl_name" == "$line" ]] && _vl_name=""
|
||||
_VL_URLS+=("$line")
|
||||
_VL_LABELS+=("$_vl_ip ($_vl_name)")
|
||||
_VL_IPS+=("$_vl_ip")
|
||||
_VL_PORTS+=("$_vl_port")
|
||||
done < "$_SERVERS_FILE"
|
||||
|
||||
if [ "${#_VL_URLS[@]}" -eq 0 ]; then
|
||||
err "Нет VLESS серверов в $_SERVERS_FILE"
|
||||
fi
|
||||
|
||||
# Проверка доступности
|
||||
# Реальная проверка VLESS (запускаем xray для каждого сервера)
|
||||
echo ""
|
||||
info "Проверяю доступность серверов..."
|
||||
info "Проверяю VLESS-доступность серверов..."
|
||||
_VL_STATUS=()
|
||||
for i in "${!_VL_IPS[@]}"; do
|
||||
_ip="${_VL_IPS[$i]}"
|
||||
_port="${_VL_PORTS[$i]}"
|
||||
for i in "${!_VL_URLS[@]}"; do
|
||||
_label="${_VL_LABELS[$i]}"
|
||||
_test_port=$((10980 + i))
|
||||
printf " %-45s" "$((i+1))) $_label"
|
||||
if timeout 3 bash -c "echo >/dev/tcp/$_ip/$_port" 2>/dev/null; then
|
||||
echo -e "${GREEN}✓ доступен${NC}"
|
||||
_status=$(test_vless_server "${_VL_URLS[$i]}" "$_test_port")
|
||||
if [ "$_status" = "ok" ]; then
|
||||
echo -e "${GREEN}✓ работает${NC}"
|
||||
_VL_STATUS+=("ok")
|
||||
else
|
||||
echo -e "${RED}✗ недоступен${NC}"
|
||||
echo -e "${RED}✗ не работает${NC}"
|
||||
_VL_STATUS+=("fail")
|
||||
fi
|
||||
done
|
||||
@@ -296,7 +368,8 @@ if [ "$USE_VLESS" -eq 1 ]; then
|
||||
"serverName": "$VL_SNI",
|
||||
"fingerprint": "$VL_FP",
|
||||
"publicKey": "$VL_PBK",
|
||||
"shortId": "$VL_SID"
|
||||
"shortId": "$VL_SID",
|
||||
"spiderX": "$VL_SPX"
|
||||
}$_VL_XHTTP
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user