zapret-kvn/xray_fluent/constants.py
loop-uh 3a84b4bdb7
Some checks failed
Windows project source guards / test (push) Failing after 1m7s
release: prepare v0.8.0
2026-09-27 14:35:16 +03:00

98 lines
4.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from __future__ import annotations
from pathlib import Path
import sys
APP_NAME = "zapret kvn"
APP_VERSION = "0.8.0"
STATE_SCHEMA_VERSION = 4
SUBSCRIPTION_PARSER_REVISION = 2
PROXY_HOST = "127.0.0.1"
DEFAULT_SOCKS_PORT = 1390
DEFAULT_HTTP_PORT = 1391
DEFAULT_XRAY_STATS_API_PORT = 19085
XRAY_RELEASES_API = "https://api.github.com/repos/XTLS/Xray-core/releases"
# Default UI accent color (single source of truth; re-exported by ui/theme.py
# as DEFAULT_ACCENT). Hex literals of the accent palette live only here and
# in xray_fluent/ui/theme.py (C3).
DEFAULT_ACCENT_COLOR = "#0078D4"
ROUTING_GLOBAL = "global"
ROUTING_RULE = "rule"
ROUTING_DIRECT = "direct"
ROUTING_MODES = (ROUTING_GLOBAL, ROUTING_RULE, ROUTING_DIRECT)
def get_base_dir() -> Path:
if getattr(sys, "frozen", False):
return Path(sys.executable).resolve().parent
return Path(__file__).resolve().parents[1]
BASE_DIR = get_base_dir()
ASSETS_DIR = BASE_DIR / "assets"
FLAGS_DIR = ASSETS_DIR / "flags"
APP_ICON_PATH = ASSETS_DIR / "app_icon.png"
TEMPLATE_UPDATE_BUNDLE_DIR = ASSETS_DIR / "template-update"
DATA_DIR = BASE_DIR / "data"
TEMPLATES_DIR = DATA_DIR / "templates"
CONFIGS_DIR = DATA_DIR / "configs"
SINGBOX_TEMPLATES_DIR = TEMPLATES_DIR / "sing-box"
XRAY_TEMPLATES_DIR = TEMPLATES_DIR / "xray"
SINGBOX_CONFIGS_DIR = CONFIGS_DIR / "sing-box"
XRAY_CONFIGS_DIR = CONFIGS_DIR / "xray"
RUNTIME_DIR = DATA_DIR / "runtime"
LOG_DIR = DATA_DIR / "logs"
STATE_FILE = DATA_DIR / "state.enc"
XRAY_CONFIG_FILE = RUNTIME_DIR / "xray_config.json"
XRAY_DEFAULT_CONFIG_NAME = "default.json"
XRAY_PATH_DEFAULT = BASE_DIR / "core" / "xray.exe"
XRAY_TUN_DEFAULT_INTERFACE_NAME = "xray0"
SINGBOX_CONFIG_FILE = RUNTIME_DIR / "singbox_config.json"
SINGBOX_PROVIDER_FILE = RUNTIME_DIR / "singbox_nodes.json"
SINGBOX_DEFAULT_CONFIG_NAME = "default.json"
SINGBOX_PATH_DEFAULT = BASE_DIR / "core" / "sing-box.exe"
SINGBOX_CLASH_API_PORT = 19090
SINGBOX_XRAY_RELAY_PORT = 11808
HYSTERIA_SIDECAR_RELAY_PORT = 11809
HYSTERIA_PATH_DEFAULT = BASE_DIR / "core" / "hysteria.exe"
AMNEZIA_PATH_DEFAULT = BASE_DIR / "core" / "zapret-amnezia.exe"
HYSTERIA_CONFIG_FILE = RUNTIME_DIR / "hysteria_config.json"
SPEED_TEST_URLS_BY_COUNTRY: dict[str, str] = {
"nl": "https://ams.download.datapacket.com/100mb.bin",
"de": "https://fra.download.datapacket.com/100mb.bin",
"gb": "https://lon.download.datapacket.com/100mb.bin",
"uk": "https://lon.download.datapacket.com/100mb.bin",
"fr": "https://par.download.datapacket.com/100mb.bin",
"se": "https://sto.download.datapacket.com/100mb.bin",
"no": "https://osl.download.datapacket.com/100mb.bin",
"dk": "https://sto.download.datapacket.com/100mb.bin",
"fi": "https://sto.download.datapacket.com/100mb.bin",
"at": "https://fra.download.datapacket.com/100mb.bin",
"ch": "https://fra.download.datapacket.com/100mb.bin",
"be": "https://ams.download.datapacket.com/100mb.bin",
"lu": "https://fra.download.datapacket.com/100mb.bin",
"pl": "https://ber.download.datapacket.com/100mb.bin",
"cz": "https://ber.download.datapacket.com/100mb.bin",
"ie": "https://lon.download.datapacket.com/100mb.bin",
"ru": "https://speedtest.selectel.ru/100MB",
"us": "https://ams.download.datapacket.com/100mb.bin",
}
SPEED_TEST_DEFAULT_URL = "https://fra.download.datapacket.com/100mb.bin"
SPEED_TEST_TIMEOUT = 20 # seconds per single measurement
SPEED_TEST_ROUNDS = 3 # number of measurements per node (best avg of N-1)
SPEED_TEST_TEMP_SOCKS_PORT = 19100
SPEED_TEST_TEMP_HTTP_PORT = 19101
# Временное ядро теста скорости запускается из отдельной ссылки/копии xray.exe
# с собственным именем: план sing-box TUN уводит ровно этот путь в direct
# (process_path), чтобы замер кандидата не шёл через текущий сервер. Путь
# отличается от xray.exe гибридного сайдкара, поэтому правило его не задевает.
SPEED_TEST_XRAY_PATH = RUNTIME_DIR / "speedtest" / "xray-speedtest.exe"
SS_PROTECT_PORT_START = 19200
SS_PROTECT_PORT_END = 19300