From 560c4b8661ab35520b237beb3bffeffdff2e68e5 Mon Sep 17 00:00:00 2001 From: Dokril Date: Sat, 27 Dec 2025 21:00:13 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=B2=D0=B5=D0=B1-=D1=81=D0=B5=D1=80=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=20=D0=BD=D0=B0=20Python=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D1=83=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?VPN-=D0=BF=D1=80=D0=BE=D0=BA=D1=81=D0=B8,=20Dockerfile=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20sing-box=20=D0=B8=20=D0=BE=D0=B1=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=20README.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- docker/Dockerfile.singbox | 2 +- web/server.py | 75 ++++++++++++++++++++++++++------------- 3 files changed, 52 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index b4d1285..12a33f2 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ docker compose up -d | Порт | Для чего | URL | | ------ | ------------------------------------------------- | ----------------------- | | `3456` | **Веб-интерфейс** — управление через браузер | http://localhost:3456 | -| `8082` | **Прокси** — сюда подключаются браузер/приложения | `http://127.0.0.1:8082` | +| `2412` | **Прокси** — сюда подключаются браузер/приложения | `http://127.0.0.1:8082` | | `9090` | Внутренний порт управления (обычно не нужен) | — | --- diff --git a/docker/Dockerfile.singbox b/docker/Dockerfile.singbox index 1c80fc0..bd736aa 100644 --- a/docker/Dockerfile.singbox +++ b/docker/Dockerfile.singbox @@ -1,5 +1,5 @@ FROM alpine:3.20 -ARG SINGBOX_VER=1.8.10 +ARG SINGBOX_VER=1.12.13 # Устанавливаем зависимости, включая dos2unix для исправления скриптов RUN apk add --no-cache curl ca-certificates tar jq bash coreutils netcat-openbsd python3 dos2unix && update-ca-certificates diff --git a/web/server.py b/web/server.py index 10a702e..0143eba 100644 --- a/web/server.py +++ b/web/server.py @@ -139,18 +139,27 @@ def parse_vless_url(url: str) -> dict: def generate_vless_config(vless_params: dict) -> dict: """Generate sing-box configuration from VLESS parameters""" config = { + "dns": { + "independent_cache": True + }, "log": { - "level": "info", + "level": "debug", + "disabled": True, "timestamp": True }, + "route": { + "final": vless_params['tag'], + "auto_detect_interface": True + }, "inbounds": [ { - "type": "mixed", "tag": "mixed-in", + "type": "mixed", + "sniff": True, + "users": [], "listen": "0.0.0.0", "listen_port": 8082, - "sniff": True, - "sniff_override_destination": True + "set_system_proxy": False } ], "outbounds": [ @@ -159,36 +168,27 @@ def generate_vless_config(vless_params: dict) -> dict: "tag": vless_params['tag'], "server": vless_params['server'], "server_port": vless_params['server_port'], - "uuid": vless_params['uuid'], "flow": vless_params['flow'], "tls": { "enabled": True, "server_name": vless_params['server_name'], - "utls": { - "enabled": True, - "fingerprint": vless_params['fingerprint'] - }, "reality": { "enabled": True, "public_key": vless_params['public_key'], "short_id": vless_params['short_id'] + }, + "utls": { + "enabled": True, + "fingerprint": vless_params['fingerprint'] } }, - "packet_encoding": "xudp" + "uuid": vless_params['uuid'] }, { - "type": "direct", - "tag": "direct" - }, - { - "type": "block", - "tag": "block" + "tag": "direct", + "type": "direct" } - ], - "route": { - "final": vless_params['tag'], - "auto_detect_interface": True - } + ] } return config @@ -447,10 +447,35 @@ class ProxyControlHandler(http.server.BaseHTTPRequestHandler): # Add selected server as main outbound new_outbounds.insert(0, selected_outbound) - # Update route rules to use selected server - routes = config.get("route", {}) - final_outbound = selected_tag - routes["final"] = final_outbound + # Update route - remove incompatible fields and set only final + # Some subscription configs have route.rules with "action" field which is not supported + routes = { + "final": selected_tag, + "auto_detect_interface": True + } + + # Simplify DNS configuration to match client.json format + config["dns"] = { + "independent_cache": True + } + + # Remove platform-specific and experimental fields from root config + config.pop("platform", None) + config.pop("experimental", None) + + # Replace TUN inbounds with mixed proxy (TUN requires privileges in Docker) + # Use mixed proxy on 127.0.0.1:2412 instead + config["inbounds"] = [ + { + "tag": "mixed-in", + "type": "mixed", + "sniff": True, + "users": [], + "listen": "0.0.0.0", + "listen_port": 8082, + "set_system_proxy": False + } + ] config["outbounds"] = new_outbounds config["route"] = routes