feat: Добавлены веб-интерфейс управления и скрипт для генерации клиентских конфигураций VLESS из URL.

This commit is contained in:
2025-12-24 11:42:23 +03:00
parent dbeb1b9cc0
commit 6a9d454d2a
4 changed files with 42 additions and 94 deletions

View File

@@ -19,58 +19,10 @@ if [[ ! -f "$TEMPLATE_FILE" ]]; then
exit 1
fi
# Detect if input is a subscription link (HTTP/HTTPS)
if [[ "$URL_INPUT" =~ ^http ]]; then
echo "Detecting subscription link..."
# Build URL with client parameter for APIs that require it
SUB_URL="$URL_INPUT"
# Try fetching as-is first
SUB_CONTENT=$(curl -sSL "$SUB_URL")
# If empty, try adding client parameter (some APIs require this)
if [[ -z "$SUB_CONTENT" ]]; then
echo "Empty response, trying with client=v2rayng parameter..."
if [[ "$SUB_URL" == *"?"* ]]; then
SUB_URL="${URL_INPUT}&client=v2rayng"
else
SUB_URL="${URL_INPUT}?client=v2rayng"
fi
SUB_CONTENT=$(curl -sSL "$SUB_URL")
fi
if [[ -z "$SUB_CONTENT" ]]; then
echo "Error: Failed to download subscription from $SUB_URL" >&2
exit 1
fi
# Check if base64 encoded (simple check: no spaces, looks like b64)
# Trying to decode. If fails, assume it's plain text lists
if DECODED=$(echo "$SUB_CONTENT" | base64 -d 2>/dev/null); then
echo "Decoded base64 subscription."
RAW_CONFIGS="$DECODED"
else
echo "Using plain text subscription."
RAW_CONFIGS="$SUB_CONTENT"
fi
# Find first vless reality link (vless://... + security=reality or just vless://)
# We try to find one that explicitly has reality, if not, pick ANY vless
TARGET_URL=$(echo "$RAW_CONFIGS" | grep -o 'vless://[^[:space:]]*' | grep 'security=reality' | head -n 1)
if [[ -z "$TARGET_URL" ]]; then
echo "No VLESS Reality link found, trying any VLESS..."
TARGET_URL=$(echo "$RAW_CONFIGS" | grep -o 'vless://[^[:space:]]*' | head -n 1)
fi
if [[ -z "$TARGET_URL" ]]; then
echo "Error: No VLESS URL found in subscription." >&2
exit 1
fi
echo "Selected URL from subscription: ${TARGET_URL:0:30}..."
URL_INPUT="$TARGET_URL"
# Check if input starts with vless://
if [[ "$URL_INPUT" != vless://* ]]; then
echo "Error: Only vless:// URLs are supported." >&2
exit 1
fi
# Strip scheme