xrayvpn 0.4.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. xrayvpn-0.4.1/.gitignore +41 -0
  2. xrayvpn-0.4.1/BUILD.en.md +67 -0
  3. xrayvpn-0.4.1/BUILD.md +67 -0
  4. xrayvpn-0.4.1/PKG-INFO +174 -0
  5. xrayvpn-0.4.1/README.en.md +153 -0
  6. xrayvpn-0.4.1/README.md +157 -0
  7. xrayvpn-0.4.1/build_support.py +95 -0
  8. xrayvpn-0.4.1/hatch_build.py +29 -0
  9. xrayvpn-0.4.1/pyproject.toml +54 -0
  10. xrayvpn-0.4.1/src/xrayvpn/__init__.py +3 -0
  11. xrayvpn-0.4.1/src/xrayvpn/__main__.py +6 -0
  12. xrayvpn-0.4.1/src/xrayvpn/cli/__init__.py +0 -0
  13. xrayvpn-0.4.1/src/xrayvpn/cli/entry.py +15 -0
  14. xrayvpn-0.4.1/src/xrayvpn/cli/l10n_typer.py +281 -0
  15. xrayvpn-0.4.1/src/xrayvpn/cli/main.py +1036 -0
  16. xrayvpn-0.4.1/src/xrayvpn/cli/prompts.py +53 -0
  17. xrayvpn-0.4.1/src/xrayvpn/cli/repl.py +408 -0
  18. xrayvpn-0.4.1/src/xrayvpn/cli/service.py +444 -0
  19. xrayvpn-0.4.1/src/xrayvpn/cli/terminal_host.py +282 -0
  20. xrayvpn-0.4.1/src/xrayvpn/cli/theme.py +297 -0
  21. xrayvpn-0.4.1/src/xrayvpn/core/__init__.py +0 -0
  22. xrayvpn-0.4.1/src/xrayvpn/core/config.py +60 -0
  23. xrayvpn-0.4.1/src/xrayvpn/core/conn.py +186 -0
  24. xrayvpn-0.4.1/src/xrayvpn/core/deploy_lock.py +80 -0
  25. xrayvpn-0.4.1/src/xrayvpn/core/execution/__init__.py +0 -0
  26. xrayvpn-0.4.1/src/xrayvpn/core/execution/base.py +46 -0
  27. xrayvpn-0.4.1/src/xrayvpn/core/execution/local.py +273 -0
  28. xrayvpn-0.4.1/src/xrayvpn/core/execution/remote.py +329 -0
  29. xrayvpn-0.4.1/src/xrayvpn/core/inventory.py +145 -0
  30. xrayvpn-0.4.1/src/xrayvpn/core/manifest.py +57 -0
  31. xrayvpn-0.4.1/src/xrayvpn/core/runtime_paths.py +257 -0
  32. xrayvpn-0.4.1/src/xrayvpn/core/service_actions.py +209 -0
  33. xrayvpn-0.4.1/src/xrayvpn/core/transport/__init__.py +0 -0
  34. xrayvpn-0.4.1/src/xrayvpn/core/transport/remote.py +145 -0
  35. xrayvpn-0.4.1/src/xrayvpn/core/update_check.py +147 -0
  36. xrayvpn-0.4.1/src/xrayvpn/core/wsl.py +92 -0
  37. xrayvpn-0.4.1/src/xrayvpn/i18n.py +55 -0
  38. xrayvpn-0.4.1/src/xrayvpn/text/__init__.py +623 -0
  39. xrayvpn-0.4.1/uv.lock +749 -0
  40. xrayvpn-0.4.1/xrayvpn/payload/config/README.en.md +56 -0
  41. xrayvpn-0.4.1/xrayvpn/payload/config/README.md +56 -0
  42. xrayvpn-0.4.1/xrayvpn/payload/config/settings.yml +79 -0
  43. xrayvpn-0.4.1/xrayvpn/payload/deploy.yml +15 -0
  44. xrayvpn-0.4.1/xrayvpn/payload/inventory.yml.example +8 -0
  45. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/handlers/main.yml +23 -0
  46. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/meta/main.yml +19 -0
  47. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/tasks/keys.yml +421 -0
  48. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/tasks/logs.yml +19 -0
  49. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/tasks/main.yml +169 -0
  50. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/tasks/obs.yml +60 -0
  51. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/tasks/runtime_docker.yml +33 -0
  52. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/tasks/runtime_native.yml +69 -0
  53. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/tasks/runtime_setup.yml +31 -0
  54. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/tasks/smoke.yml +98 -0
  55. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/tasks/warp.yml +107 -0
  56. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/tasks/watchdog.yml +66 -0
  57. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/templates/clash_meta.yaml.j2 +119 -0
  58. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/templates/client_config.json.j2 +46 -0
  59. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/templates/journald-60-xray-ansible.conf.j2 +6 -0
  60. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/templates/xray-obs-snapshot.service.j2 +6 -0
  61. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/templates/xray-obs-snapshot.sh.j2 +28 -0
  62. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/templates/xray-obs-snapshot.timer.j2 +10 -0
  63. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/templates/xray-watchdog.service.j2 +6 -0
  64. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/templates/xray-watchdog.sh.j2 +111 -0
  65. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/templates/xray-watchdog.timer.j2 +10 -0
  66. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/templates/xray.service.docker.j2 +26 -0
  67. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/templates/xray.service.native.j2 +26 -0
  68. xrayvpn-0.4.1/xrayvpn/payload/roles/xray_vpn/templates/xray_config.json.j2 +98 -0
  69. xrayvpn-0.4.1/xrayvpn.spec +41 -0
@@ -0,0 +1,41 @@
1
+ # Python environments
2
+ .venv/
3
+ venv/
4
+ __pycache__/
5
+
6
+ # Ansible
7
+ .ansible/
8
+ *.retry
9
+ downloaded-configs/
10
+ downloaded-clients/
11
+ inventory.yml
12
+ .xrayvpn-inventory.yml
13
+ .xrayvpn-fetch-playbook.yml
14
+
15
+ # VS Code
16
+ .vscode/
17
+
18
+ # OS cruft
19
+ .DS_Store
20
+ Thumbs.db
21
+
22
+ .llm_context/
23
+
24
+ .kilo/
25
+
26
+ # --- Python extras ---
27
+ .ruff_cache/
28
+ .pytest_cache/
29
+
30
+ # --- Binary builds ---
31
+ python-client/build/
32
+ python-client/dist/
33
+ python-client/dist-binary/
34
+
35
+ # --- Env files (any project) ---
36
+ .env
37
+ .env.local
38
+ .env.development.local
39
+ .env.test.local
40
+ .env.production.local
41
+ *.env
@@ -0,0 +1,67 @@
1
+ # Building standalone xrayvpn binaries
2
+
3
+ Summary: `xrayvpn` is packaged by Nuitka (`--mode=onefile`) into a single
4
+ executable `xrayvpn-<os>-<arch>[.exe]` carrying the bundled payload (`roles/`,
5
+ `config/`, `deploy.yml`, `inventory.yml.example` → `xrayvpn/payload/…`; the same
6
+ allowlist used for server uploads). The PyInstaller spec `xrayvpn.spec` is a
7
+ fallback with the identical payload contract (shared staging in `build_support.py`).
8
+
9
+ ## Requirements
10
+
11
+ - `uv` (same pin as CI) — the wrapper syncs the `build` dependency group itself.
12
+ - C compiler: Windows — Visual Studio 2022 (or Nuitka auto-downloads MinGW),
13
+ Linux — gcc, macOS — clang (Xcode CLT).
14
+ - Python 3.12+ (`requires-python` in `pyproject.toml`).
15
+
16
+ ## Commands
17
+
18
+ ```
19
+ # Windows
20
+ .\build-binary.ps1 # onefile, canonical
21
+ .\build-binary.ps1 -Mode standalone # debug mode (onedir folder)
22
+ .\build-binary.ps1 -Engine pyinstaller # fallback spec
23
+ .\build-binary.ps1 -Version 0.4.1 # release version fed to metadata/--version (default: __version__)
24
+
25
+ # Linux/macOS
26
+ ./build-binary.sh
27
+ ./build-binary.sh --mode standalone
28
+ ./build-binary.sh --engine pyinstaller --version 0.4.1
29
+ ```
30
+
31
+ Artifacts land in `dist-binary/`. Contract: identical payload paths for both
32
+ engines, `--version` = the version passed, file name = `xrayvpn-<os>-<arch>[.exe]`.
33
+
34
+ ## Debug loop
35
+
36
+ 1. `--mode standalone` → inspect `dist-binary/xrayvpn-*.dist/` by hand.
37
+ 2. No complaints → `--mode onefile` (default) → smoke below.
38
+ 3. Nuitka surprises (bcrypt/cffi/plugin deps) — fix with flags/`--include-package`,
39
+ not client code; as a last resort use the PyInstaller spec (payload contract unchanged).
40
+
41
+ ## Onefile cache
42
+
43
+ Extraction goes to `{CACHE_DIR}/xrayvpn/{VERSION}` (a stable path so Windows
44
+ Firewall does not treat every run as a new program; repeat launches skip
45
+ re-extraction). A version change creates a fresh cache directory.
46
+
47
+ ## Smoke set (MUST run from a NEUTRAL cwd)
48
+
49
+ Outside the repo checkout — `--dry-run` would otherwise find the bundle via the
50
+ composite clone marker `roles/xray_vpn` inside the repo and the check would not count:
51
+
52
+ ```
53
+ cd $TMPDIR/some-empty-dir
54
+ XRAYVPN_UPDATE_CHECK=0 ./xrayvpn-… --version # first line: xrayvpn <version>
55
+ XRAYVPN_UPDATE_CHECK=0 ./xrayvpn-… deploy --dry-run --no-interactive --host 127.0.0.1
56
+ XRAYVPN_LANG=ru XRAYVPN_UPDATE_CHECK=0 ./xrayvpn-… --ru --help # RU output (l10n-patch sentinel in freeze)
57
+ XRAYVPN_REPL_SELFTEST=1 ./xrayvpn-… repl # stdin feeding: help\nexit\n → rc 0
58
+ # Windows: double-click on the .exe = same entry with a console (--windows-console-mode=force);
59
+ # on a fatal error the window stays open with the message until you press Enter.
60
+ ```
61
+
62
+ ## Known environment notes
63
+
64
+ - Unsigned Windows exe → SmartScreen “More info”; macOS → `chmod +x`,
65
+ Gatekeeper → right-click Open / `xattr -d com.apple.quarantine`.
66
+ - Reset the onefile cache: delete `{CACHE_DIR}/xrayvpn/<version>`.
67
+ - On low-memory hosts add `--low-memory` / `--jobs=1` inside `build_binary.py`.
xrayvpn-0.4.1/BUILD.md ADDED
@@ -0,0 +1,67 @@
1
+ # Сборка standalone-приложения xrayvpn
2
+
3
+ Суть: `xrayvpn` упаковывается Nuitka (`--mode=onefile`) в один исполняемый
4
+ файл `xrayvpn-<os>-<arch>[.exe]` с bundled payload (`roles/`, `config/`, `deploy.yml`,
5
+ `inventory.yml.example` → `xrayvpn/payload/…`; тот же allowlist, что у загрузки на сервер).
6
+ PyInstaller-спека `xrayvpn.spec` — фолбэк с тем же контрактом payload
7
+ (общий staging из `build_support.py`).
8
+
9
+ ## Требования
10
+
11
+ - `uv` (тот же пин, что в CI) — окружение и группу `build` ставит сам через wrapper.
12
+ - C-компилятор: Windows — Visual Studio 2022 (или авто-догруз MinGW Nuitka),
13
+ Linux — gcc, macOS — clang (Xcode CLT).
14
+ - Python 3.12+ (_requires-python_ из `pyproject.toml`).
15
+
16
+ ## Команды
17
+
18
+ ```
19
+ # Windows
20
+ .\build-binary.ps1 # onefile, канон
21
+ .\build-binary.ps1 -Mode standalone # отладочный режим (папка onedir)
22
+ .\build-binary.ps1 -Engine pyinstaller # фолбэк-спека
23
+ .\build-binary.ps1 -Version 0.4.1 # версия в метаданные/--version (дефолт: __version__)
24
+
25
+ # Linux/macOS
26
+ ./build-binary.sh
27
+ ./build-binary.sh --mode standalone
28
+ ./build-binary.sh --engine pyinstaller --version 0.4.1
29
+ ```
30
+
31
+ Артефакты — `dist-binary/`. Контракт: одинаковые payload-пути у обоих движков,
32
+ `--version` = переданная версия, имя файла = `xrayvpn-<os>-<arch>[.exe]`.
33
+
34
+ ## Цикл отладки
35
+
36
+ 1. `--mode standalone` → проверить `dist-binary/xrayvpn-*.dist/` вручную.
37
+ 2. Претензий нет → `--mode onefile` (дефолт) → смоук ниже.
38
+ 3. Nuitka-сюрпризы (bcrypt/cffi/плагин-зависимости) — чинить флагами/`--include-package`,
39
+ не кодом клиента; в крайнем случае — PyInstaller-спека (контракт payload не меняется).
40
+
41
+ ## Onefile-кэш
42
+
43
+ Распаковка идёт в `{CACHE_DIR}/xrayvpn/{VERSION}` (стабильный путь — Windows Firewall
44
+ не считает каждый запуск новой программой; повторные запуски без переупаковки).
45
+ Смена версии = новая папка кэша.
46
+
47
+ ## Smoke-набор (ОБЯЗАТЕЛЬНО из НЕЙТРАЛЬНОГО cwd)
48
+
49
+ Каталог вне checkout репо (`--dry-run` сам нашёл бы бандл по композит-маркеру
50
+ `roles/xray_vpn`, если запускать внутри репо — проверка бандла не считается):
51
+
52
+ ```
53
+ cd $TMPDIR/some-empty-dir
54
+ XRAYVPN_UPDATE_CHECK=0 ./xrayvpn-… --version # первая строка: xrayvpn <версия>
55
+ XRAYVPN_UPDATE_CHECK=0 ./xrayvpn-… deploy --dry-run --no-interactive --host 127.0.0.1
56
+ XRAYVPN_LANG=ru XRAYVPN_UPDATE_CHECK=0 ./xrayvpn-… --ru --help # RU-вывод (страж l10n-патчей в freeze)
57
+ XRAYVPN_REPL_SELFTEST=1 ./xrayvpn-… repl # feeding stdin: help\nexit\n → rc 0
58
+ # Windows: двойной клик по .exe = тот же entry с консолью (--windows-console-mode=force);
59
+ # при фатальной ошибке окно остаётся с текстом до нажатия Enter.
60
+ ```
61
+
62
+ ## Known environment notes
63
+
64
+ - Не-подписанный Windows-exe → SmartScreen «показать подробности», macOS → `chmod +x`,
65
+ Gatekeeper → ПКМ→Открыть/`xattr -d com.apple.quarantine`.
66
+ - Сброс кэша onefile: удалить папку `{CACHE_DIR}/xrayvpn/<версия>`.
67
+ - `--low-memory` / `--jobs=1` добавить в `build_binary.py` на малоразмерных хостах.
xrayvpn-0.4.1/PKG-INFO ADDED
@@ -0,0 +1,174 @@
1
+ Metadata-Version: 2.5
2
+ Name: xrayvpn
3
+ Version: 0.4.1
4
+ Summary: Python client for provisioning Xray VLESS + REALITY VPN servers (local and remote execution)
5
+ License-Expression: AGPL-3.0-or-later
6
+ Classifier: Environment :: Console
7
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
8
+ Classifier: Programming Language :: Python :: 3 :: Only
9
+ Classifier: Topic :: System :: Systems Administration
10
+ Requires-Python: >=3.12
11
+ Requires-Dist: fabric>=3.2.3
12
+ Requires-Dist: inquirerpy>=0.3.4
13
+ Requires-Dist: pyyaml>=6.0.3
14
+ Requires-Dist: rich>=15.0.0
15
+ Requires-Dist: typer<0.28,>=0.27.2
16
+ Description-Content-Type: text/markdown
17
+
18
+ # `python-client/`
19
+
20
+ > English version: [README.en.md](README.en.md).
21
+
22
+ Основной клиент `xrayvpn` (Python) — развертывание, обновление и ротация Xray-сервера.
23
+ Одинаково на Windows, Linux и macOS; удалённый и локальный режимы в одном CLI.
24
+
25
+ ## Установка и запуск
26
+
27
+ Самый простой вариант — готовая standalone-сборка без Python: скачайте файл своей платформы
28
+ из [Releases](https://github.com/lifestreamy/xrayvpn/releases/latest).
29
+ Первый запуск — в [../docs/user/SETUP.md](../docs/user/SETUP.md), раздел «Первый запуск».
30
+ Как собрать самому (Nuitka onefile, режим отладки, smoke) — [BUILD.md](BUILD.md).
31
+
32
+ Для работы с исходниками в репозитории нужен [uv](https://docs.astral.sh/uv/) (или Python 3.12+):
33
+
34
+ ```powershell
35
+ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" # Windows
36
+ ```
37
+
38
+ ```bash
39
+ curl -LsSf https://astral.sh/uv/install.sh | sh # Linux/macOS
40
+ ```
41
+
42
+ Из корня репозитория:
43
+
44
+ ```bash
45
+ uv run --project python-client xrayvpn --help
46
+ ```
47
+
48
+ Внутри `python-client/` (после `uv sync`) работают и `uv run xrayvpn ...`, и `python -m xrayvpn`.
49
+
50
+ На Windows можно вообще без флагов. Двойной клик по `xrayvpn-deploy.pyw` (английский интерфейс)
51
+ или `xrayvpn-deploy-ru.pyw` (русский) открывает консоль и запускает интерактивный мастер деплоя.
52
+ CLI спросит узел исполнения, хост VPS и SSH-аутентификацию, покажет план и запросит
53
+ подтверждение: без него ничего не выполняется. Окно остаётся открытым — ошибки и код возврата
54
+ видны до нажатия Enter.
55
+
56
+ Дефис в имени лаунчера обязателен: `xrayvpn.pyw` рядом с пакетом перехватывал бы
57
+ `import xrayvpn` на Windows.
58
+
59
+ ### Команда `xrayvpn` в PATH
60
+
61
+ Чтобы вводить `xrayvpn` в любом терминале без префикса `uv run`, из корня репозитория:
62
+
63
+ ```bash
64
+ uv tool install --editable python-client
65
+ ```
66
+
67
+ Установка editable — изменения кода в репозитории применяются сразу. Запускать из папки
68
+ репозитория: клиент ищет `deploy.yml` и `config/settings.yml` вверх от текущей директории.
69
+ Удаление — `uv tool uninstall xrayvpn`.
70
+
71
+ ## Интерактивный режим
72
+
73
+ `xrayvpn` без аргументов (или `xrayvpn repl`) открывает интерактивный режим: команды внутри —
74
+ с тем же синтаксисом, что CLI, без префикса. `deploy` спросит недостающее и покажет план как
75
+ обычно; `help` перечисляет встроенное (`version`, `lang ru|en`, `exit`); `deploy --help` —
76
+ полный список флагов развёртывания. Приветственная плашка перерисовывается при смене языка
77
+ (`lang ru|en` или просто `ru`/`en`) и сразу показывает `service` — аварийные команды по SSH.
78
+ Под ссылками — строка «прервалось — повтори деплой» со ссылкой на docs; во время прогона видно
79
+ прогресс этапов `[1/7]…[7/7]`, в долгих фазах — счётчик секунд.
80
+ Двойной клик по standalone-приложению и `.pyw`-обёртки —
81
+ это тот же режим. На Windows с Windows Terminal как терминалом по умолчанию двойной клик по `.exe`
82
+ открывает классическое окно conhost с иконкой приложения (перезапуск через `conhost.exe`); остаться
83
+ во вкладке Windows Terminal — флаг `--wt` или `XRAYVPN_IN_WT=1`.
84
+
85
+ ## Куда ставится и где выполняется ansible
86
+
87
+ Цель деплоя — **всегда удалённый VPS**. `--execution` выбирает лишь узел, где
88
+ выполняется сам ansible:
89
+
90
+ - **remote** (по умолчанию) — окружение поднимается на VPS по SSH: bootstrap,
91
+ загрузка репозитория tarball'ом (GitHub серверу не нужен), playbook на сервере,
92
+ забор готовых клиентских конфигов. На слабом VPS bootstrap и apt могут упираться
93
+ в память (для этого встроен swap-guard).
94
+ - **local** — ansible-контроллер на вашей машине: на Linux/macOS напрямую
95
+ (venv/PATH, по умолчанию `~/xray-venv`), на Windows — через WSL. Цель та же —
96
+ VPS по SSH (creds: флаги `--host/--user/--port/--pkey/--pass` или личный
97
+ `inventory.yml` через `--use-inventory`), конфиги после прогона подтягиваются тем
98
+ же ansible-fetch по SSH. Полезно на очень слабых VPS, где Ansible на самом
99
+ сервере работать не может. Парольная аутентификация требует `sshpass`.
100
+ - Без `--execution` — вопрос в терминале (по умолчанию remote).
101
+
102
+ Перед любым реальным прогоном клиент показывает **план деплоя** (узел, цель,
103
+ аутентификация — пароль только `******`, изменения, предупреждение при `--rotate`,
104
+ куда лягут конфиги) и спрашивает согласие; `--no-interactive` отключает вопросы
105
+ для скриптов/CI (недостающие обязательные значения тогда — ошибка). `--dry-run`
106
+ план не подтверждает (он ничего не меняет).
107
+
108
+ ## Примеры
109
+
110
+ ```bash
111
+ # VPS по IP: пароль спросит скрыто (или заранее --pkey ~/.ssh/id_ed25519)
112
+ uv run --project python-client xrayvpn deploy --host 1.2.3.4
113
+
114
+ # параметры подключения из личного inventory.yml
115
+ uv run --project python-client xrayvpn deploy --use-inventory
116
+
117
+ # ansible с вашей машины против того же VPS, без WARP и без ротации
118
+ uv run --project python-client xrayvpn deploy --execution local --host 1.2.3.4 --no-warp --no-rotate
119
+
120
+ # план remote-развертывания без какого-либо подключения
121
+ uv run --project python-client xrayvpn deploy --host 1.2.3.4 --dry-run
122
+ ```
123
+
124
+ ## Флаги `deploy`
125
+
126
+ - Узел выполнения: `--execution remote|local` (цель всегда VPS; без флага — вопрос, дефолт remote).
127
+ - Неинтерактивно: `--no-interactive` — без вопросов и подтверждения плана (для CI/скриптов).
128
+ - Язык: `--ru` — полностью русский интерфейс (промпты, сообщения, ошибки, `--help`);
129
+ работает в любой позиции аргументов, альтернатива — переменная окружения `XRAYVPN_LANG=ru`.
130
+ - Переопределения сервера (иначе берётся из `config/settings.yml`): `--runtime native|docker`,
131
+ `--xray-port`, `--num-clients`, `--camouflage-domain`, `--warp/--no-warp`,
132
+ `--rotate/--no-rotate` (перегенерация ключа REALITY и UUID / оставить как есть),
133
+ `--manage-ufw/--no-ufw`.
134
+ - Инвентарь: `--inventory PATH` — только local, ssh-inventory для прогона (по умолчанию
135
+ генерируется `.xrayvpn-inventory.yml` с параметрами VPS из флагов/inventory, 0600,
136
+ после прогона удаляется);
137
+ `--use-inventory` — читает подключение и переменные из личного `inventory.yml`
138
+ (перекрывает host/key-флаги с предупреждением).
139
+ - Подключение (цель-VPS, оба узла): `--host`/`-H`, `--user`/`-u` (default `root`), `--port`/`-p` (default 22),
140
+ `--pkey FILE` (предпочтительно), `--pass TEXT` (пароль в открытом виде, хуже ключа; без него —
141
+ скрытый запрос). `--user`/`--port` без явного значения не пинуются: для хоста из
142
+ `~/.ssh/config` работают user/port из конфига, для голого IP — `root:22`.
143
+ - Результат: `--clients-dir PATH` — куда сохранить конфиги клиентов
144
+ (default `<repo>/downloaded-clients/`, забираются с сервера из `/root/vpn-configs`);
145
+ `--no-config-download` — вообще не скачивать, оставить их на сервере.
146
+ - Уборка на сервере (remote): по умолчанию staging-каталог удаляется, venv остаётся;
147
+ `--full-cleanup` — снести и venv, `--no-cleanup` — оставить всё.
148
+ - Windows и `--execution local`: `--wsl-distro` (дистрибутив WSL) и `--wsl-venv` (venv с
149
+ `ansible-playbook`, по умолчанию `~/xray-venv`).
150
+ - Диагностика: `--dry-run` (узел local: ansible `--check`; узел remote: напечатанный план без подключения),
151
+ `--debug` / `--verbose` (Ansible -vvv/-vvvv; вместе нельзя, как и `--pkey` с `--pass`).
152
+
153
+ Полная афиша: `xrayvpn deploy --help`.
154
+
155
+ ## Сервисные действия (`xrayvpn service`)
156
+
157
+ Когда VPN уже развёрнут и что-то деградировало — точечные действия по SSH теми же флагами
158
+ подключения (`-H/--pkey/--pass/--use-inventory`): `service status` (состояние, журнал, слушатели),
159
+ `service restart` (перезапуск xray — WARP живёт внутри него),
160
+ `service logs [--since 30m] [--lines N] [--out DIR]` (дамп журнала на свою машину: конечный снимок
161
+ окна, по умолчанию 30 минут; Ctrl+C прерывает загрузку и сохраняет частичный файл),
162
+ `service reboot --yes` (крайний случай, только с явным `--yes`).
163
+ Порядок действий при сбое — [`docs/user/RUNBOOK.md`](../docs/user/RUNBOOK.md).
164
+
165
+ ## Где что лежит
166
+
167
+ - `src/xrayvpn/` — пакет (`cli/`, `core/`, `core/execution/`, `core/transport/`);
168
+ - `tests/` — pytest-набор (в CI нога `python-client` гоняет его и ruff; контракт лаунчеров
169
+ `.pyw` ↔ CLI проверяется статически и реальным запуском);
170
+ - смежные зоны репо: `shell-clients/` (Bash/PowerShell, поддержка без развития), `scripts/`
171
+ (инструменты разработки).
172
+
173
+ Настройка сервера — [../docs/user/SETUP.md](../docs/user/SETUP.md), ротация ключей —
174
+ [../docs/user/ROTATION.md](../docs/user/ROTATION.md).
@@ -0,0 +1,153 @@
1
+ # `python-client/`
2
+
3
+ > This is the English copy of [README.md](README.md); the Russian file is the base.
4
+
5
+ The primary `xrayvpn` client (Python) — deploy, update and rotate an Xray server.
6
+ Works the same on Windows, Linux and macOS; remote and local modes in one CLI.
7
+
8
+ ## Install and run
9
+
10
+ The simplest option is the standalone binary with no Python: download the build for your
11
+ platform from [Releases](https://github.com/lifestreamy/xrayvpn/releases/latest). First run —
12
+ [../docs/user/SETUP.en.md](../docs/user/SETUP.en.md), "First run" section. To build the binary
13
+ yourself (Nuitka onefile, debug mode, smoke) — [BUILD.en.md](BUILD.en.md).
14
+
15
+ Working with the sources in the repository requires [uv](https://docs.astral.sh/uv/) (or Python 3.12+):
16
+
17
+ ```powershell
18
+ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" # Windows
19
+ ```
20
+
21
+ ```bash
22
+ curl -LsSf https://astral.sh/uv/install.sh | sh # Linux/macOS
23
+ ```
24
+
25
+ From the repository root:
26
+
27
+ ```bash
28
+ uv run --project python-client xrayvpn --help
29
+ ```
30
+
31
+ Inside `python-client/` (after `uv sync`) both `uv run xrayvpn ...` and `python -m xrayvpn` work.
32
+
33
+ On Windows you can skip flags entirely. Double-click `xrayvpn-deploy.pyw` (English UI) or
34
+ `xrayvpn-deploy-ru.pyw` (Russian UI): a console opens and the interactive deploy wizard starts.
35
+ The CLI asks for the execution node, the VPS host and SSH auth, prints a deploy plan and asks
36
+ for confirmation: nothing runs without it. The window stays open — failures and the exit code
37
+ are visible until you press Enter.
38
+
39
+ The hyphen in the launcher name is mandatory: `xrayvpn-deploy.pyw` cannot shadow
40
+ `import xrayvpn`, while a plain `xrayvpn.pyw` next to the package would.
41
+
42
+ ### The `xrayvpn` command on PATH
43
+
44
+ To type `xrayvpn` in any terminal without the `uv run` prefix, from the repository root:
45
+
46
+ ```bash
47
+ uv tool install --editable python-client
48
+ ```
49
+
50
+ The install is editable — repository code changes apply immediately. Run it from the repository
51
+ folder: the client locates `deploy.yml` and `config/settings.yml` by walking up from the current
52
+ directory. Remove with `uv tool uninstall xrayvpn`.
53
+
54
+ ## Interactive mode
55
+
56
+ `xrayvpn` with no arguments (or `xrayvpn repl`) opens the interactive mode: commands use the exact
57
+ CLI syntax without the prefix. `deploy` still asks for the missing pieces and confirms the plan;
58
+ `help` lists the built-ins (`version`, `lang ru|en`, `exit`); `deploy --help` shows every flag of
59
+ the deploy command. The welcome banner is reprinted whenever the language switches
60
+ (`lang ru|en` or just `ru`/`en`) and already shows `service` — the SSH recovery commands. The banner carries a "interrupted — rerun deploy" line with a docs link; a run shows stage progress `[1/7]…[7/7]`, counting seconds on the long stages.
61
+ Double-clicking the binary and the `.pyw` launchers are this very mode. On Windows with
62
+ Windows Terminal as the default terminal, double-clicking the `.exe` opens a classic conhost window
63
+ with the app icon (a `conhost.exe` relaunch); to stay in a Windows Terminal tab, use the `--wt`
64
+ flag or `XRAYVPN_IN_WT=1`.
65
+
66
+ ## Where the deploy goes and where ansible runs
67
+
68
+ The target is **always a remote VPS**. `--execution` only picks the node where
69
+ ansible itself runs:
70
+
71
+ - **remote** (default) — the client bootstraps the VPS over SSH itself: environment
72
+ setup, repo uploaded as a tarball (the server never needs GitHub), the playbook on the
73
+ server, then it fetches the generated client configs. On a very small VPS the bootstrap
74
+ and apt may hit the RAM limit (a built-in swap-guard covers this).
75
+ - **local** — the ansible control node is your own machine: directly on Linux/macOS
76
+ (venv/PATH, default `~/xray-venv`), through WSL on Windows. The target stays the same
77
+ VPS over SSH (creds: `--host/--user/--port/--pkey/--pass` flags or the personal
78
+ `inventory.yml` via `--use-inventory`); generated configs are pulled back with the same
79
+ ansible-fetch over SSH. Useful on weak VPSes where Ansible cannot run on the server
80
+ itself. Password auth additionally requires `sshpass`.
81
+ - Without `--execution` the CLI asks in the terminal (default: remote).
82
+
83
+ Before any real run the client prints a **deploy plan** (node, target, auth — a password
84
+ is shown only as `******`, overrides, a warning when `--rotate` is set, where the configs
85
+ land) and asks for consent; `--no-interactive` skips all prompts for scripts/CI (missing
86
+ required values then fail). `--dry-run` needs no confirmation (it changes nothing).
87
+
88
+ ## Examples
89
+
90
+ ```bash
91
+ # VPS by IP: the password is prompted with hidden input (or pass --pkey ~/.ssh/id_ed25519)
92
+ uv run --project python-client xrayvpn deploy --host 1.2.3.4
93
+
94
+ # connection parameters from the personal inventory.yml
95
+ uv run --project python-client xrayvpn deploy --use-inventory
96
+
97
+ # ansible on your own machine against the same VPS, no WARP, no forced rotation
98
+ uv run --project python-client xrayvpn deploy --execution local --host 1.2.3.4 --no-warp --no-rotate
99
+
100
+ # the remote deploy plan without connecting anywhere
101
+ uv run --project python-client xrayvpn deploy --host 1.2.3.4 --dry-run
102
+ ```
103
+
104
+ ## `deploy` flags
105
+
106
+ - Execution node: `--execution remote|local` (the target is always the VPS; no flag asks, default remote).
107
+ - Non-interactive: `--no-interactive` — no prompts and no plan confirmation (for CI/scripts).
108
+ - Language: `--ru` — fully Russian interface (prompts, messages, errors, `--help`);
109
+ works in any argument position, alternative — the `XRAYVPN_LANG=ru` environment variable.
110
+ - Server overrides (otherwise taken from `config/settings.yml`): `--runtime native|docker`,
111
+ `--xray-port`, `--num-clients`, `--camouflage-domain`, `--warp/--no-warp`,
112
+ `--rotate/--no-rotate` (regenerate the REALITY key and UUIDs / keep them),
113
+ `--manage-ufw/--no-ufw`.
114
+ - Inventory: `--inventory PATH` — `--execution local` only: the ssh-inventory to run with
115
+ (by default `.xrayvpn-inventory.yml` is generated from flags/inventory.yml, 0600, removed after the run);
116
+ `--use-inventory` — reads connection vars from the personal `inventory.yml` in both nodes
117
+ (overrides the host/key flags with a warning).
118
+ - Connection (the VPS target, both nodes): `--host`/`-H`, `--user`/`-u`, `--port`/`-p`,
119
+ `--pkey FILE` (preferred), `--pass TEXT` (plain password, worse than a key; omit both and
120
+ it prompts, hidden). Left alone, `--user`/`--port` are not pinned: a `~/.ssh/config` host
121
+ keeps its user and port, a bare IP falls back to `root:22`.
122
+ - Output: `--clients-dir PATH` — where client configs are saved
123
+ (default `<repo>/downloaded-clients/`, fetched from the server's `/root/vpn-configs`);
124
+ `--no-config-download` skips fetching and leaves them on the server.
125
+ - Server-side cleanup (remote): by default the staging dir is removed, the venv stays;
126
+ `--full-cleanup` removes the venv too, `--no-cleanup` leaves everything.
127
+ - Windows and `--execution local`: `--wsl-distro` (the WSL distro) and `--wsl-venv` (a venv holding
128
+ `ansible-playbook`, default `~/xray-venv`).
129
+ - Diagnostics: `--dry-run` (local node: ansible `--check`; remote node: printed plan without connecting),
130
+ `--debug` / `--verbose` (Ansible -vvv/-vvvv; mutually exclusive, as are `--pkey` with `--pass`).
131
+
132
+ Full list: `xrayvpn deploy --help`.
133
+
134
+ ## Service actions (`xrayvpn service`)
135
+
136
+ Once the VPN is deployed and something degrades — point actions over SSH with the same
137
+ connection flags (`-H/--pkey/--pass/--use-inventory`): `service status` (state, journal,
138
+ listeners), `service restart` (restarts xray — WARP lives inside it), `service logs
139
+ [--since 30m] [--lines N] [--out DIR]` (dumps the journal to your machine: a finite snapshot
140
+ of the window, 30 minutes by default; Ctrl+C aborts the download and keeps the partial file),
141
+ `service reboot --yes` (last resort, requires the explicit `--yes`). The recovery sequence —
142
+ [`docs/user/RUNBOOK.en.md`](../docs/user/RUNBOOK.en.md).
143
+
144
+ ## Layout
145
+
146
+ - `src/xrayvpn/` — the package (`cli/`, `core/`, `core/execution/`, `core/transport/`);
147
+ - `tests/` — pytest suite (the `python-client` CI leg runs it plus ruff; the `.pyw` launcher ↔ CLI
148
+ contract is checked statically and by a real end-to-end launch);
149
+ - sibling repo zones: `shell-clients/` (Bash/PowerShell, maintained, not developed) and
150
+ `scripts/` (contributor tooling).
151
+
152
+ Server configuration — [../docs/user/SETUP.en.md](../docs/user/SETUP.en.md), key rotation —
153
+ [../docs/user/ROTATION.en.md](../docs/user/ROTATION.en.md).