mirror of
https://gitverse.ru/kpa39l/infrastructure.git
synced 2026-11-27 14:33:13 +00:00
openspec: terminal-telegram-client — tuigram v1.8.1 в /opt/tuigram, SOCKS5 127.0.0.1:1080 до логина (validate -> archive)
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
schema: spec-driven
|
||||
created: 2026-11-05
|
||||
@@ -0,0 +1,80 @@
|
||||
# Design — add-tuigram-tui-client
|
||||
|
||||
## Контекст
|
||||
|
||||
- bigbox: Ubuntu 24.04.5, x86_64, sudo без пароля у пользователя агента.
|
||||
- Telegram MTProto напрямую недоступен (проверено: TCP 149.154.167.51:443
|
||||
с хоста не открывается), через SOCKS5 `127.0.0.1:1080`
|
||||
(`telegram-tunnel.service` → vps01) открывается.
|
||||
- Релиз tuigram v1.8.1: `tuigram-x86_64-unknown-linux-gnu.tar.gz`,
|
||||
23 MB, внутри один бинарник `tuigram` (81 MB, not stripped) и README.
|
||||
- Бинарник динамически зависит от `libc++.so.1`, `libc++abi.so.1`,
|
||||
`libunwind.so.1` — в Ubuntu 24.04 это пакеты `libc++1`, `libc++abi1`,
|
||||
`libunwind8` (последний уже стоял в системе).
|
||||
|
||||
## Раскладка
|
||||
|
||||
```
|
||||
/opt/tuigram/
|
||||
bin/tuigram # бинарник релиза, rwxr-xr-x
|
||||
VERSION # 1.8.1
|
||||
SHA256SUMS # контрольные суммы релиза (для сверки/апдейта)
|
||||
install.sh # воспроизводимая установка/обновление
|
||||
README.md # запуск, прокси, обновление, откат
|
||||
/usr/local/bin/tuigram -> /opt/tuigram/bin/tuigram
|
||||
```
|
||||
|
||||
Пользовательские данные (сессия TDLib, настройки, темы) — не в `/opt`:
|
||||
TDLib пишет в `~/.local/share/tuigram` (переопределяется `TG_DATA_DIR`).
|
||||
Каталог `/opt/tuigram` — только код и версия, как требует конвенция
|
||||
`/opt/<service>/`.
|
||||
|
||||
## Прокси
|
||||
|
||||
Настройка до первого логина — критично: без неё клиент снова упрётся в
|
||||
блокировку. Три равнозначных способа (по README):
|
||||
|
||||
1. `TG_PROXY=socks5://127.0.0.1:1080 tuigram`
|
||||
2. `proxy = "socks5://127.0.0.1:1080"` в `~/.local/share/tuigram/settings.toml`
|
||||
3. интерактивно `:proxy` → `socks5://127.0.0.1:1080` → Enter → `y`
|
||||
|
||||
Выбираем (2) как постоянную настройку + (1) как способ разово
|
||||
переопределить. Пароля у туннеля нет (SSH `-D` без аутентификации на
|
||||
SOCKS-уровне, слушает только локально и в WG-сети).
|
||||
|
||||
## Установка / обновление
|
||||
|
||||
`install.sh [version]` (по умолчанию — latest):
|
||||
|
||||
1. `curl -fsSL` тарбол релиза + `SHA256SUMS` во временный каталог.
|
||||
2. `sha256sum -c` для нужного файла; при расхождении — выход с ошибкой.
|
||||
3. `tar xzf … tuigram`, `install -m 0755` в `/opt/tuigram/bin/tuigram.new`,
|
||||
затем атомарный `mv` поверх старого (запущенный процесс не ломается).
|
||||
4. Запись `VERSION`, симлинк `/usr/local/bin/tuigram`.
|
||||
|
||||
## Проверка
|
||||
|
||||
- `tuigram --version` → `tuigram 1.8.1` (без ошибок загрузки libc++).
|
||||
- `nc -X 5 -x 127.0.0.1:1080 149.154.167.51 443` → succeeded (прокси живой).
|
||||
- `tuigram --demo` в TTY — интерфейс рисуется без сети (не проверяется
|
||||
агентом: требует терминала).
|
||||
- Логин (телефон/QR) — действие владельца; агент проверяет только, что
|
||||
процесс доходит до экрана авторизации, а не падает на «Connecting…».
|
||||
|
||||
## Риски
|
||||
|
||||
- Бинарник not stripped, 81 MB — норм для /opt, но бэкапится вместе с
|
||||
системой; при желании исключается из бэкапа.
|
||||
- Прокси видит IP и факт использования Telegram (не содержимое) — обычное
|
||||
свойство SOCKS5.
|
||||
- Обновление без сверки SHA256 запрещено: `install.sh` падает, если строки
|
||||
для нужного файла нет в `SHA256SUMS`.
|
||||
|
||||
## Откат
|
||||
|
||||
```
|
||||
rm -f /usr/local/bin/tuigram
|
||||
rm -rf /opt/tuigram
|
||||
# по желанию: rm -rf ~/.local/share/tuigram (удаляет сессию и секретные чаты)
|
||||
```
|
||||
`tele` не затрагивается — откат к нему не требует действий.
|
||||
@@ -0,0 +1,43 @@
|
||||
# tuigram — TUI-клиент Telegram для bigbox
|
||||
|
||||
## Why
|
||||
|
||||
Российский провайдер режет MTProto: прямой TCP до DC4 Telegram
|
||||
(`149.154.167.51:443`) с bigbox не открывается, поэтому TUI-клиент `tele`
|
||||
(apt-пакет 2.1.1, github.com/sorokin-vladimir/tele) висит на «Connecting…»
|
||||
и в чаты не пускает — при этом прокси он не поддерживает.
|
||||
|
||||
`tuigram` (erictran308/tuigram, Rust + TDLib, MIT, v1.8.1) умеет прокси
|
||||
через SOCKS5/HTTP/MTProto: `:proxy` в TUI, `TG_PROXY` в окружении или
|
||||
`proxy = "…"` в `settings.toml`. Уже работающий туннель
|
||||
`telegram-tunnel.service` (SOCKS5 `127.0.0.1:1080` → vps01) проверен:
|
||||
через него TCP до DC4:443 открывается, напрямую — нет. То есть tuigram
|
||||
закрывает ровно ту дырку, из-за которой `tele` нерабочий.
|
||||
|
||||
## What Changes
|
||||
|
||||
- Новый сервисный каталог `/opt/tuigram/` (бинарник + установочный
|
||||
скрипт + README), симлинк `/usr/local/bin/tuigram`.
|
||||
- Готовые релизные сборки кладутся в `/opt/tuigram/bin`, ставятся с
|
||||
проверкой SHA256 по `SHA256SUMS` релиза.
|
||||
- Системные runtime-зависимости libc++ (Debian/Ubuntu: `libc++1`,
|
||||
`libc++abi1`, `libunwind8`) — без них бинарник не запускается.
|
||||
- Преднастроенный прокси в `~/.local/share/tuigram/settings.toml`
|
||||
(`proxy = "socks5://127.0.0.1:1080"`), чтобы логин шёл через туннель
|
||||
без ручного `:proxy` при первом запуске.
|
||||
- `tele` не удаляется: остаётся как есть до отдельного решения владельца.
|
||||
|
||||
## Non-goals
|
||||
|
||||
- Не трогаем `telegram-tunnel.service` (туннель уже существует и покрыт
|
||||
спекой `tunnel-proxy`).
|
||||
- Не разворачиваем MTProto-прокси и XRay-цепочку для этого клиента —
|
||||
используется существующий SOCKS5.
|
||||
- Не настраиваем systemd-юнит: tuigram — интерактивный TUI, а не демон.
|
||||
|
||||
## Impact
|
||||
|
||||
- Affected: bigbox, ФС `/opt/tuigram`, `/usr/local/bin`, пакеты libc++.
|
||||
- Ports: новых нет; исходящее — через существующий `127.0.0.1:1080`.
|
||||
- Rollback: `rm -f /usr/local/bin/tuigram && rm -rf /opt/tuigram`;
|
||||
данные сессии — `~/.local/share/tuigram` (удаляет логин).
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
# terminal-telegram-client Specification
|
||||
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Service Directory Layout
|
||||
|
||||
The terminal Telegram client MUST be installed under `/opt/tuigram` with the
|
||||
binary at `/opt/tuigram/bin/tuigram` and MUST be reachable as `tuigram` from
|
||||
`PATH` via the symlink `/usr/local/bin/tuigram`.
|
||||
|
||||
#### Scenario: Binary and symlink present
|
||||
- GIVEN the change is applied
|
||||
- WHEN running `ls -l /opt/tuigram/bin/tuigram /usr/local/bin/tuigram`
|
||||
- THEN `/opt/tuigram/bin/tuigram` is an executable regular file
|
||||
- AND `/usr/local/bin/tuigram` is a symlink pointing to it
|
||||
|
||||
#### Scenario: Version reported
|
||||
- GIVEN the client is installed
|
||||
- WHEN running `tuigram --version`
|
||||
- THEN it prints the installed version (e.g. `tuigram 1.8.1`)
|
||||
- AND exits with status 0
|
||||
|
||||
### Requirement: Runtime Libraries
|
||||
|
||||
The system MUST provide the C++ runtime the release binary links against, so
|
||||
that the client starts without `error while loading shared libraries`.
|
||||
|
||||
#### Scenario: No missing shared objects
|
||||
- GIVEN the client binary is installed
|
||||
- WHEN running `ldd /opt/tuigram/bin/tuigram`
|
||||
- THEN no line contains `not found`
|
||||
- AND `libc++.so.1`, `libc++abi.so.1`, `libunwind.so.1` resolve to system paths
|
||||
|
||||
### Requirement: Verified Release Artifacts
|
||||
|
||||
Installation and update MUST use the upstream GitHub release asset for
|
||||
`x86_64-unknown-linux-gnu` and MUST verify its SHA256 against the release's
|
||||
`SHA256SUMS` before the binary is replaced.
|
||||
|
||||
#### Scenario: Checksum matches
|
||||
- GIVEN the release tarball and `SHA256SUMS` were downloaded
|
||||
- WHEN the installer compares the digest
|
||||
- THEN a match installs the new binary atomically (`mv` over the old one)
|
||||
- AND `VERSION` records the release tag
|
||||
|
||||
#### Scenario: Checksum mismatch or missing entry
|
||||
- GIVEN the downloaded tarball has a different digest, or its name is absent
|
||||
from `SHA256SUMS`
|
||||
- WHEN the installer runs
|
||||
- THEN it exits non-zero and leaves the existing binary untouched
|
||||
|
||||
### Requirement: Proxy Preset Before First Login
|
||||
|
||||
The client MUST default to the existing SOCKS5 tunnel at `127.0.0.1:1080`
|
||||
before the first login, because direct MTProto to Telegram datacenters is
|
||||
blocked from this host.
|
||||
|
||||
#### Scenario: Settings file carries the proxy
|
||||
- GIVEN `~/.local/share/tuigram/settings.toml` does not exist yet
|
||||
- WHEN the proxy preset is applied
|
||||
- THEN the file contains `proxy = "socks5://127.0.0.1:1080"`
|
||||
- AND an existing file is not overwritten without an explicit decision
|
||||
|
||||
#### Scenario: Proxy path is reachable
|
||||
- GIVEN `telegram-tunnel.service` is active
|
||||
- WHEN opening a TCP connection to `149.154.167.51:443` through
|
||||
`127.0.0.1:1080`
|
||||
- THEN the connection succeeds
|
||||
- AND the same connection attempted directly fails, confirming the proxy is
|
||||
required rather than optional
|
||||
|
||||
#### Scenario: One-off override
|
||||
- GIVEN the preset points at `127.0.0.1:1080`
|
||||
- WHEN the client is started as `TG_PROXY=socks5://host:port tuigram`
|
||||
- THEN the environment value takes precedence over the saved setting
|
||||
|
||||
### Requirement: Operators' Documentation
|
||||
|
||||
`/opt/tuigram/README.md` MUST document the installed version, how to update
|
||||
and roll back, the proxy setting, and where user data lives.
|
||||
|
||||
#### Scenario: Documented facts match reality
|
||||
- GIVEN the README exists
|
||||
- WHEN comparing it to the installed artifacts
|
||||
- THEN the documented version equals `/opt/tuigram/VERSION`
|
||||
- AND the documented data directory equals the path printed by `tuigram --help`
|
||||
@@ -0,0 +1,47 @@
|
||||
# Tasks — add-tuigram-tui-client
|
||||
|
||||
## 1. Предпосылки
|
||||
|
||||
- [x] 1.1 Проверить блокировку MTProto и доступность прокси:
|
||||
`nc -zv 149.154.167.51 443` (fail) и
|
||||
`nc -zv -X 5 -x 127.0.0.1:1080 149.154.167.51 443` (succeeded).
|
||||
Верификация: оба вывода зафиксированы.
|
||||
|
||||
## 2. Каталог и бинарник
|
||||
|
||||
- [x] 2.1 Создать `/opt/tuigram/{bin}`.
|
||||
- [x] 2.2 Скачать `tuigram-x86_64-unknown-linux-gnu.tar.gz` (v1.8.1) и
|
||||
`SHA256SUMS`, сверить `sha256sum -c`.
|
||||
Верификация: `a99b2d94…d8a` совпадает со строкой в `SHA256SUMS`.
|
||||
- [x] 2.3 Установить бинарник в `/opt/tuigram/bin/tuigram` (0755), записать
|
||||
`/opt/tuigram/VERSION`, положить `/opt/tuigram/SHA256SUMS`.
|
||||
Верификация: `tuigram --version` → `tuigram 1.8.1`.
|
||||
- [x] 2.4 Поставить runtime-зависимости: `libc++1 libc++abi1 libunwind8`.
|
||||
Верификация: `ldd /opt/tuigram/bin/tuigram | grep 'not found'` — пусто.
|
||||
- [x] 2.5 Симлинк `/usr/local/bin/tuigram` → `/opt/tuigram/bin/tuigram`.
|
||||
Верификация: `command -v tuigram`, `ls -l /usr/local/bin/tuigram`.
|
||||
|
||||
## 3. Прокси
|
||||
|
||||
- [x] 3.1 Создать `~/.local/share/tuigram/settings.toml` с
|
||||
`proxy = "socks5://127.0.0.1:1080"` (не перезаписывать существующий).
|
||||
Верификация: `grep proxy ~/.local/share/tuigram/settings.toml`.
|
||||
- [x] 3.2 Проверить, что туннель активен: `systemctl is-active telegram-tunnel`.
|
||||
Верификация: `active`.
|
||||
|
||||
## 4. Скрипты и документация
|
||||
|
||||
- [x] 4.1 `/opt/tuigram/install.sh` — установка/обновление с обязательной
|
||||
сверкой SHA256 и атомарной заменой бинарника.
|
||||
Верификация: `bash -n install.sh`; повторный запуск идемпотентен.
|
||||
- [x] 4.2 `/opt/tuigram/README.md` — версия, запуск, прокси, обновление,
|
||||
откат, каталог данных (`~/.local/share/tuigram`).
|
||||
Верификация: версия в README совпадает с `/opt/tuigram/VERSION`.
|
||||
|
||||
## 5. Проверка и фиксация
|
||||
|
||||
- [x] 5.1 `tuigram --demo` в TTY — интерфейс рисуется (проверяет владелец;
|
||||
агент фиксирует, что бинарник запускается и не падает на libc++).
|
||||
- [x] 5.2 Обновить `STATUS.md` (раздел «Сделано») и `WALKTHROUGH.md`
|
||||
(раздел про блокировку MTProto и выбор клиента).
|
||||
- [x] 5.3 `openspec validate add-tuigram-tui-client --strict` → archive.
|
||||
@@ -0,0 +1,92 @@
|
||||
# terminal-telegram-client Specification
|
||||
|
||||
## Purpose
|
||||
Терминальный клиент Telegram на bigbox: где он установлен и как обновляется,
|
||||
какие системные библиотеки ему нужны, как проверяется подлинность релиза и
|
||||
как он ходит в Telegram через SOCKS5-туннель, потому что прямой MTProto с
|
||||
этого хоста заблокирован.
|
||||
|
||||
## Requirements
|
||||
|
||||
### Requirement: Service Directory Layout
|
||||
|
||||
The terminal Telegram client MUST be installed under `/opt/tuigram` with the
|
||||
binary at `/opt/tuigram/bin/tuigram` and MUST be reachable as `tuigram` from
|
||||
`PATH` via the symlink `/usr/local/bin/tuigram`.
|
||||
|
||||
#### Scenario: Binary and symlink present
|
||||
- GIVEN the change is applied
|
||||
- WHEN running `ls -l /opt/tuigram/bin/tuigram /usr/local/bin/tuigram`
|
||||
- THEN `/opt/tuigram/bin/tuigram` is an executable regular file
|
||||
- AND `/usr/local/bin/tuigram` is a symlink pointing to it
|
||||
|
||||
#### Scenario: Version reported
|
||||
- GIVEN the client is installed
|
||||
- WHEN running `tuigram --version`
|
||||
- THEN it prints the installed version (e.g. `tuigram 1.8.1`)
|
||||
- AND exits with status 0
|
||||
|
||||
### Requirement: Runtime Libraries
|
||||
|
||||
The system MUST provide the C++ runtime the release binary links against, so
|
||||
that the client starts without `error while loading shared libraries`.
|
||||
|
||||
#### Scenario: No missing shared objects
|
||||
- GIVEN the client binary is installed
|
||||
- WHEN running `ldd /opt/tuigram/bin/tuigram`
|
||||
- THEN no line contains `not found`
|
||||
- AND `libc++.so.1`, `libc++abi.so.1`, `libunwind.so.1` resolve to system paths
|
||||
|
||||
### Requirement: Verified Release Artifacts
|
||||
|
||||
Installation and update MUST use the upstream GitHub release asset for
|
||||
`x86_64-unknown-linux-gnu` and MUST verify its SHA256 against the release's
|
||||
`SHA256SUMS` before the binary is replaced.
|
||||
|
||||
#### Scenario: Checksum matches
|
||||
- GIVEN the release tarball and `SHA256SUMS` were downloaded
|
||||
- WHEN the installer compares the digest
|
||||
- THEN a match installs the new binary atomically (`mv` over the old one)
|
||||
- AND `VERSION` records the release tag
|
||||
|
||||
#### Scenario: Checksum mismatch or missing entry
|
||||
- GIVEN the downloaded tarball has a different digest, or its name is absent
|
||||
from `SHA256SUMS`
|
||||
- WHEN the installer runs
|
||||
- THEN it exits non-zero and leaves the existing binary untouched
|
||||
|
||||
### Requirement: Proxy Preset Before First Login
|
||||
|
||||
The client MUST default to the existing SOCKS5 tunnel at `127.0.0.1:1080`
|
||||
before the first login, because direct MTProto to Telegram datacenters is
|
||||
blocked from this host.
|
||||
|
||||
#### Scenario: Settings file carries the proxy
|
||||
- GIVEN `~/.local/share/tuigram/settings.toml` does not exist yet
|
||||
- WHEN the proxy preset is applied
|
||||
- THEN the file contains `proxy = "socks5://127.0.0.1:1080"`
|
||||
- AND an existing file is not overwritten without an explicit decision
|
||||
|
||||
#### Scenario: Proxy path is reachable
|
||||
- GIVEN `telegram-tunnel.service` is active
|
||||
- WHEN opening a TCP connection to `149.154.167.51:443` through
|
||||
`127.0.0.1:1080`
|
||||
- THEN the connection succeeds
|
||||
- AND the same connection attempted directly fails, confirming the proxy is
|
||||
required rather than optional
|
||||
|
||||
#### Scenario: One-off override
|
||||
- GIVEN the preset points at `127.0.0.1:1080`
|
||||
- WHEN the client is started as `TG_PROXY=socks5://host:port tuigram`
|
||||
- THEN the environment value takes precedence over the saved setting
|
||||
|
||||
### Requirement: Operators' Documentation
|
||||
|
||||
`/opt/tuigram/README.md` MUST document the installed version, how to update
|
||||
and roll back, the proxy setting, and where user data lives.
|
||||
|
||||
#### Scenario: Documented facts match reality
|
||||
- GIVEN the README exists
|
||||
- WHEN comparing it to the installed artifacts
|
||||
- THEN the documented version equals `/opt/tuigram/VERSION`
|
||||
- AND the documented data directory equals the path printed by `tuigram --help`
|
||||
Reference in New Issue
Block a user