feat: Добавлена веб-панель управления VPN-прокси и Docker-конфигурация.

This commit is contained in:
2025-12-27 20:01:38 +03:00
parent 6a9d454d2a
commit b65b48d82b
8 changed files with 785 additions and 374 deletions

View File

@@ -1,6 +1,5 @@
FROM alpine:3.20
ARG SINGBOX_VER=1.8.10
ARG VLESS_URL
# Устанавливаем зависимости, включая dos2unix для исправления скриптов
RUN apk add --no-cache curl ca-certificates tar jq bash coreutils netcat-openbsd python3 dos2unix && update-ca-certificates
@@ -16,14 +15,11 @@ RUN ARCH=$(uname -m) && \
&& chmod +x /usr/local/bin/sing-box \
&& adduser -D -u 1000 suser
COPY --chown=suser:suser config/client.template.json /app/
COPY --chown=suser:suser scripts/gen-client-from-url.sh scripts/menu.sh /app/
COPY --chown=suser:suser docker/entrypoint.sh /app/
COPY --chown=suser:suser web/ /app/web/
# Исправляем окончания строк (важно для Windows пользователей) и даем права на запуск
RUN dos2unix /app/*.sh && chmod +x /app/gen-client-from-url.sh /app/entrypoint.sh /app/menu.sh
RUN dos2unix /app/*.sh && chmod +x /app/entrypoint.sh
ENV VLESS_URL=$VLESS_URL
EXPOSE 8082 9090 3456
ENTRYPOINT ["/app/entrypoint.sh"]

View File

@@ -1,26 +1,12 @@
#!/usr/bin/env bash
set -e
# Default update interval: 60 minutes
UPDATE_INTERVAL=${UPDATE_INTERVAL:-60}
CONFIG_FILE="/app/data/client.json"
SINGBOX_PID=""
# Ensure data directory exists
mkdir -p /app/data
# Function to generate config
generate_config() {
echo "$(date): Generating config..."
if ./gen-client-from-url.sh "$VLESS_URL" "$CONFIG_FILE"; then
echo "$(date): Config generated successfully."
return 0
else
echo "$(date): Error generating config."
return 1
fi
}
start_singbox() {
if [[ -f "$CONFIG_FILE" ]]; then
echo "$(date): Starting sing-box..."
@@ -47,11 +33,6 @@ restart_singbox() {
start_singbox
}
# Initial generation (if URL provided)
if [[ -n "$VLESS_URL" ]]; then
generate_config
fi
start_singbox
# Start Web UI Server
@@ -61,22 +42,15 @@ WEBUI_PID=$!
# HTTP Control Server (Simple Netcat loop)
# Listens on 9090.
# Endpoints:
# /update -> Regenerate from ENV (VLESS_URL) & Restart
# /reload -> Just Restart (used by web_server.py after config change)
# Endpoint: /reload -> Restart sing-box (used by web_server.py after config change)
(
while true; do
# Read the request using nc.
REQ=$(echo -e "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n" | nc -l -p 9090 -q 1)
echo "$(date): Received request on 9090"
if echo "$REQ" | grep -q "GET /update"; then
echo "$(date): Action: UPDATE (Regen from ENV + Restart)"
if generate_config; then
restart_singbox
fi
elif echo "$REQ" | grep -q "GET /reload"; then
echo "$(date): Action: RELOAD (Restart only)"
if echo "$REQ" | grep -q "GET /reload"; then
echo "$(date): Action: RELOAD (Restart sing-box)"
restart_singbox
else
echo "$(date): Unknown request or ping."
@@ -85,20 +59,6 @@ WEBUI_PID=$!
) &
CONTROL_PID=$!
# Periodic Update Loop (only if VLESS_URL is set)
if [[ -n "$VLESS_URL" ]]; then
(
while true; do
sleep "$((UPDATE_INTERVAL * 60))"
echo "$(date): Checking for periodic update..."
if generate_config; then
restart_singbox
fi
done
) &
UPDATE_PID=$!
fi
# Keep container alive - wait for any background process
echo "$(date): Entrypoint ready. Waiting for processes..."