mirror of
https://gitverse.ru/kpa39l/infrastructure.git
synced 2026-11-27 14:33:13 +00:00
openspec: switch-telegram-egress-vps03 — SOCKS5 127.0.0.1:1082 через vps03 (egress 77.67.89.154), tuigram использует его (validate -> archive)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# Infrastructure — Статус
|
# Infrastructure — Статус
|
||||||
|
|
||||||
Обновлено: 2026-11-05 (сессия: tuigram — TUI-клиент Telegram)
|
Обновлено: 2026-11-07 (сессия: tuigram — рабочий egress через vps03)
|
||||||
|
|
||||||
## Текущее состояние
|
## Текущее состояние
|
||||||
- Инфраструктура-репозиторий /opt/infrastructure (git, openspec) — живой.
|
- Инфраструктура-репозиторий /opt/infrastructure (git, openspec) — живой.
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
- herdr: установлен плагин herdr-sidebar (v0.11.0) у пользователя estorozhenko + шрифт JetBrainsMono Nerd Font; опыт зафиксирован в WALKTHROUGH.
|
- herdr: установлен плагин herdr-sidebar (v0.11.0) у пользователя estorozhenko + шрифт JetBrainsMono Nerd Font; опыт зафиксирован в WALKTHROUGH.
|
||||||
|
|
||||||
## Сделано
|
## Сделано
|
||||||
|
- 2026-11-07: tuigram — рабочий egress. Через `telegram-tunnel.service` (vps01, 1080) TCP до DC открывается, но MTProto-хендшейк виснет (`Timeout expired`), egress vps01 = `5.129.217.146` — та же сеть, что у bigbox. Поднят `telegram-tunnel-vps03.service` (ssh `-D 127.0.0.1:1082` → vps03 `77.67.89.154`, enabled, `Restart=always`), пресет прокси переведён на `socks5://127.0.0.1:1082`; проверено: `auth_key_id` в `tdlib.log`, живой QR, `Connecting…` пропадает. MTProto-прокси владельца (`87.242.100.206:8443`) доступен, но tuigram 1.8.1 `t.me/proxy`-ссылку игнорирует и уходит напрямую — зафиксировано в README/спеке. Спека: `openspec/specs/terminal-telegram-client`.
|
||||||
- 2026-11-05: TUI-клиент Telegram — `tele` (apt 2.1.1) нерабочий на этом хосте: MTProto до DC режется, прокси клиент не умеет. Развёрнут `tuigram` v1.8.1 в `/opt/tuigram` (бинарь + `install.sh` со сверкой SHA256 + README, симлинк `/usr/local/bin/tuigram`, runtime-пакеты `libc++1 libc++abi1 libunwind8`). Прокси задан до логина: `proxy = "socks5://127.0.0.1:1080"` в `~/.local/share/tuigram/settings.toml` (туннель `telegram-tunnel`). Проверено: `nc` через 1080 до DC4 ok, напрямую fail; живой QR-экран, в `tdlib.log` — сессии DC1/DC4 и `auth_key_id`. Спека: `openspec/specs/terminal-telegram-client`.
|
- 2026-11-05: TUI-клиент Telegram — `tele` (apt 2.1.1) нерабочий на этом хосте: MTProto до DC режется, прокси клиент не умеет. Развёрнут `tuigram` v1.8.1 в `/opt/tuigram` (бинарь + `install.sh` со сверкой SHA256 + README, симлинк `/usr/local/bin/tuigram`, runtime-пакеты `libc++1 libc++abi1 libunwind8`). Прокси задан до логина: `proxy = "socks5://127.0.0.1:1080"` в `~/.local/share/tuigram/settings.toml` (туннель `telegram-tunnel`). Проверено: `nc` через 1080 до DC4 ok, напрямую fail; живой QR-экран, в `tdlib.log` — сессии DC1/DC4 и `auth_key_id`. Спека: `openspec/specs/terminal-telegram-client`.
|
||||||
- 2026-11-01: vps02 — fail2ban джейл `caddy-vesti` для https://vesti.nixg.ru: отдельный JSON-лог `/data/logs/vesti.access.log` в блоке Caddy, фильтр `caddy-vesti` (POST /login → 302 + `Location: /login?error=1`; успешный вход не считается), джейл maxretry 5 / findtime 10m / bantime 1h, порты http,https. Живой тест: 5 неверных паролей → бан IP, сайт 000, SSH цел, unban вернул 200. Спека: `openspec/specs/edge-security`.
|
- 2026-11-01: vps02 — fail2ban джейл `caddy-vesti` для https://vesti.nixg.ru: отдельный JSON-лог `/data/logs/vesti.access.log` в блоке Caddy, фильтр `caddy-vesti` (POST /login → 302 + `Location: /login?error=1`; успешный вход не считается), джейл maxretry 5 / findtime 10m / bantime 1h, порты http,https. Живой тест: 5 неверных паролей → бан IP, сайт 000, SSH цел, unban вернул 200. Спека: `openspec/specs/edge-security`.
|
||||||
- 2026-10-25/26: Проект deepseekharness — `/opt/deepseekharness` сделан bind-маунтом на `/mnt/raid1/deepseekharness` (fstab `bind,nofail,x-systemd.requires-mounts-for=/mnt/raid1`, юнит `opt-deepseekharness.mount`), битый самоссылочный симлинк удалён. Спека: `openspec/specs/host-storage`. Сервис развёрнут: контейнер `dsh` (DSH + плагин `dsh-admin-gateway`, публикация `10.8.0.2:3081`), на vps02 — сайт `dsh.nixg.ru` в Caddy + fail2ban джейл `caddy-dsh`; проверено AC-01…AC-03, AC-05…AC-08.
|
- 2026-10-25/26: Проект deepseekharness — `/opt/deepseekharness` сделан bind-маунтом на `/mnt/raid1/deepseekharness` (fstab `bind,nofail,x-systemd.requires-mounts-for=/mnt/raid1`, юнит `opt-deepseekharness.mount`), битый самоссылочный симлинк удалён. Спека: `openspec/specs/host-storage`. Сервис развёрнут: контейнер `dsh` (DSH + плагин `dsh-admin-gateway`, публикация `10.8.0.2:3081`), на vps02 — сайт `dsh.nixg.ru` в Caddy + fail2ban джейл `caddy-dsh`; проверено AC-01…AC-03, AC-05…AC-08.
|
||||||
@@ -27,7 +28,7 @@
|
|||||||
- Проверить монтирование: `grep yandex /proc/mounts`, `ls /mnt/yandex-disk/`
|
- Проверить монтирование: `grep yandex /proc/mounts`, `ls /mnt/yandex-disk/`
|
||||||
- Демон: `ps aux | grep mount.davfs`
|
- Демон: `ps aux | grep mount.davfs`
|
||||||
- herdr: `herdr plugin list` (должен показать herdr-sidebar enabled); шрифт: `fc-list | grep -i "JetBrainsMono Nerd"`
|
- herdr: `herdr plugin list` (должен показать herdr-sidebar enabled); шрифт: `fc-list | grep -i "JetBrainsMono Nerd"`
|
||||||
- tuigram: `tuigram --version`, `tuigram --demo` (демо без логина), прокси: `grep proxy ~/.local/share/tuigram/settings.toml`; обновление: `sudo /opt/tuigram/install.sh`
|
- tuigram: `tuigram --version`, `tuigram --demo` (демо без логина), прокси: `grep proxy ~/.local/share/tuigram/settings.toml` (должен быть `socks5://127.0.0.1:1082`), туннель: `systemctl is-active telegram-tunnel-vps03`; обновление: `sudo /opt/tuigram/install.sh`
|
||||||
|
|
||||||
## Ключевые артефакты
|
## Ключевые артефакты
|
||||||
- WALKTHROUGH.md — разбор инцидента davfs2 + кейс herdr-sidebar (установка, Nerd Font) + разбор блокировки MTProto и развёртывание tuigram
|
- WALKTHROUGH.md — разбор инцидента davfs2 + кейс herdr-sidebar (установка, Nerd Font) + разбор блокировки MTProto и развёртывание tuigram
|
||||||
|
|||||||
@@ -145,3 +145,50 @@ proxy = "socks5://127.0.0.1:1080"
|
|||||||
- Спека: `openspec/specs/terminal-telegram-client/spec.md` (change `add-tuigram-tui-client`).
|
- Спека: `openspec/specs/terminal-telegram-client/spec.md` (change `add-tuigram-tui-client`).
|
||||||
- `/opt/tuigram/README.md` — запуск, прокси, обновление, откат.
|
- `/opt/tuigram/README.md` — запуск, прокси, обновление, откат.
|
||||||
- `tele` удалён: apt-пакет `sudo apt remove tele` + вторая копия в `~/.local/bin/tele` (стояла от install-скрипта, перекрывала apt-версию в PATH). Конфиг `~/.config/tele/config.yml` оставлен (данные пользователя, `api_id: 0`).
|
- `tele` удалён: apt-пакет `sudo apt remove tele` + вторая копия в `~/.local/bin/tele` (стояла от install-скрипта, перекрывала apt-версию в PATH). Конфиг `~/.config/tele/config.yml` оставлен (данные пользователя, `api_id: 0`).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2026-11-07 — tuigram: туннель был «включён», но выход тот же, что у хоста
|
||||||
|
|
||||||
|
### Симптом
|
||||||
|
Клиент запущен, прокси прописан (`socks5://127.0.0.1:1080`), телефон введён — в статусе `Connecting…`, снизу `Sending…`, кода нет.
|
||||||
|
|
||||||
|
### Разбор
|
||||||
|
1. Туннель живой: `systemctl is-active telegram-tunnel` → active, TCP через `127.0.0.1:1080` до `149.154.175.50:443` открывается.
|
||||||
|
2. Но в `tdlib.log` циклично:
|
||||||
|
`Failed to open connection: [Error : 0 : Timeout expired : [149.154.175.50:443] to DcId{1} from [10.24.0.210:…]]`.
|
||||||
|
То есть соединение до прокси есть, а **MTProto-хендшейк не завершается**.
|
||||||
|
3. Проверка egress: `curl --socks5-hostname 127.0.0.1:1080 ifconfig.me` → `5.129.217.146` — ровно тот же адрес, что и без прокси. Туннель ведёт в ту же российскую сеть, блокировка не обходится. (5 ноября через него хендшейк ещё проходил — трафик зарезали позже.)
|
||||||
|
4. Рабочий выход — vps03 (`77.67.89.154`): через `ssh -D` до него `auth_key_id` появляется за ~2 с, QR живой.
|
||||||
|
|
||||||
|
### Попутно: MTProto-прокси владельца клиент не принимает
|
||||||
|
Прокси `87.242.100.206:8443`, secret `ee70a1…2e7275` (FakeTLS, домен `tgate.nixg.ru`). Сам прокси рабочий: TCP открыт, `openssl s_client -servername tgate.nixg.ru` → `Verify return code: 0`.
|
||||||
|
Но tuigram 1.8.1 ссылку не применяет ни в `settings.toml` (`proxy = "https://t.me/proxy?…"`), ни в `TG_PROXY=…`:
|
||||||
|
- в `lsof` у процесса прямые `SYN_SENT` на `149.154.175.50:443` и `194.221.250.50:443`;
|
||||||
|
- тот же `socks5://…` тем же путём применяется (ESTABLISHED на локальный порт).
|
||||||
|
Вывод: парсер настроек работает, сломана именно ветка `t.me/proxy` — обходить её патчем бинарника не стали.
|
||||||
|
|
||||||
|
### Сделано
|
||||||
|
- `telegram-tunnel-vps03.service`: `ssh -D 127.0.0.1:1082` → `root@77.67.89.154`, ключ `hostkeyVPS`, `Restart=always`, enabled. Bind на localhost (старый туннель слушает `0.0.0.0` — шире, чем нужно).
|
||||||
|
- `~/.local/share/tuigram/settings.toml` → `proxy = "socks5://127.0.0.1:1082"`.
|
||||||
|
- `telegram-tunnel.service` (vps01, 1080) не тронут — им пользуются другие задачи.
|
||||||
|
|
||||||
|
### Проверка
|
||||||
|
```bash
|
||||||
|
systemctl is-active telegram-tunnel-vps03 # active
|
||||||
|
ss -ltn | grep 1082 # 127.0.0.1:1082
|
||||||
|
curl -s --socks5-hostname 127.0.0.1:1082 https://ifconfig.me # 77.67.89.154
|
||||||
|
```
|
||||||
|
Живой клиент с отдельным `TG_DATA_DIR`: `auth_key_id` в `tdlib.log`, по `Tab` — QR-код, статус `Connecting…` отсутствует.
|
||||||
|
|
||||||
|
### Выводы / правила на будущее
|
||||||
|
1. «Прокси включён» ≠ «блокировка обойдена». Проверять egress: `curl --socks5-hostname <proxy> ifconfig.me` и сравнивать с адресом без прокси. Совпал — туннель бесполезен для обхода.
|
||||||
|
2. Симптом «TCP через прокси открывается, но MTProto висит» = режут по содержимому/юрисдикции, а не по порту. Лечится сменой выхода, а не перезапуском туннеля.
|
||||||
|
3. tuigram 1.8.1: рабочая ветка прокси — `socks5://` и `http://`; `t.me/proxy`-ссылки игнорируются молча и клиент уходит напрямую. Проверять фактом (`lsof` на соединения), а не по README.
|
||||||
|
4. Настройка прокси читается при старте: после правки `settings.toml` клиент нужно перезапустить.
|
||||||
|
5. При проверке TUI в tmux первый кадр может не отрисоваться — нажать любую клавишу и только потом `capture-pane`; иначе экран пустой и легко принять это за сбой прокси.
|
||||||
|
|
||||||
|
### Артефакты
|
||||||
|
- Спека: `openspec/specs/terminal-telegram-client` (change `switch-telegram-egress-vps03`).
|
||||||
|
- Юнит: `/etc/systemd/system/telegram-tunnel-vps03.service`.
|
||||||
|
- `/opt/tuigram/README.md` — обновлённый раздел про прокси.
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
schema: spec-driven
|
||||||
|
created: 2026-11-07
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
# Design — switch-telegram-egress-vps03
|
||||||
|
|
||||||
|
## Почему vps01 не годится
|
||||||
|
|
||||||
|
| Проверка | vps01 (1080) | vps03 (1082) |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| TCP до `149.154.175.50:443` через SOCKS | ok | ok |
|
||||||
|
| MTProto handshake | `Timeout expired` (10 с), циклично | `auth_key_id` за ~2 с |
|
||||||
|
| Egress IP | `5.129.217.146` (та же сеть, что у bigbox) | `77.67.89.154` |
|
||||||
|
| UI tuigram | `Connecting…` навсегда | экран логина без ошибок, QR живой |
|
||||||
|
|
||||||
|
Вывод: смена выхода важнее, чем «прокси включён». Туннель в той же сети
|
||||||
|
блокировку не обходит.
|
||||||
|
|
||||||
|
## Почему не MTProto-прокси владельца
|
||||||
|
|
||||||
|
`87.242.100.206:8443`, secret `ee70a1…2e7275` (FakeTLS, домен
|
||||||
|
`tgate.nixg.ru`) — TCP открыт, TLS-хендшейк с SNI `tgate.nixg.ru` проходит
|
||||||
|
(`Verify return code: 0`). Но tuigram 1.8.1 ссылку не применяет:
|
||||||
|
|
||||||
|
- `settings.toml` с `proxy = "https://t.me/proxy?server=…&port=8443&secret=…"`
|
||||||
|
→ в `lsof` прямые `SYN_SENT` на `149.154.175.50:443` и `194.221.250.50:443`;
|
||||||
|
- `TG_PROXY=<та же ссылка>` → то же самое;
|
||||||
|
- `socks5://127.0.0.1:1080` тем же способом применяется (видно ESTABLISHED
|
||||||
|
на локальный порт), то есть парсер настроек работает, проблема именно в
|
||||||
|
`t.me/proxy`-ветке.
|
||||||
|
|
||||||
|
Поэтому путь через SOCKS5 — поддерживаемый и проверенный.
|
||||||
|
|
||||||
|
## Реализация
|
||||||
|
|
||||||
|
`/etc/systemd/system/telegram-tunnel-vps03.service`:
|
||||||
|
|
||||||
|
```
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=estorozhenko
|
||||||
|
ExecStart=/usr/bin/ssh -i /home/estorozhenko/.ssh/hostkeyVPS \
|
||||||
|
-D 127.0.0.1:1082 -N \
|
||||||
|
-o ServerAliveInterval=30 -o ServerAliveCountMax=3 \
|
||||||
|
-o ExitOnForwardFailure=yes -o StrictHostKeyChecking=accept-new \
|
||||||
|
-o IdentitiesOnly=yes root@77.67.89.154
|
||||||
|
Restart=always
|
||||||
|
RestartSec=10
|
||||||
|
```
|
||||||
|
|
||||||
|
Отличия от `telegram-tunnel.service`: bind на `127.0.0.1` (старый слушает
|
||||||
|
`0.0.0.0`, что шире нужного), нет зависимости от `wg-quick@wg0` (SSH идёт
|
||||||
|
прямо в интернет, не по WG).
|
||||||
|
|
||||||
|
Пресет: `~/.local/share/tuigram/settings.toml` → `proxy =
|
||||||
|
"socks5://127.0.0.1:1082"`. Применяется при старте клиента, поэтому после
|
||||||
|
смены настройки запущенный tuigram нужно перезапустить.
|
||||||
|
|
||||||
|
## Проверка
|
||||||
|
|
||||||
|
```bash
|
||||||
|
systemctl is-active telegram-tunnel-vps03 # active
|
||||||
|
ss -ltn | grep 1082 # 127.0.0.1:1082
|
||||||
|
curl -s --socks5-hostname 127.0.0.1:1082 https://ifconfig.me # 77.67.89.154
|
||||||
|
nc -zv -X 5 -x 127.0.0.1:1082 149.154.175.50 443 # succeeded
|
||||||
|
```
|
||||||
|
|
||||||
|
Живой клиент: свежий `TG_DATA_DIR` + `TG_PROXY=socks5://127.0.0.1:1082` →
|
||||||
|
`tdlib.log` содержит `auth_key_id`, в UI по `Tab` появляется QR.
|
||||||
|
|
||||||
|
## Риски
|
||||||
|
|
||||||
|
- Зависимость от доступности vps03 и ключа `hostkeyVPS`; при падении SSH
|
||||||
|
юнит перезапускается сам (Restart=always), при долгом отказе — клиент
|
||||||
|
покажет `Connecting…`.
|
||||||
|
- Через vps03 пойдёт и другой трафик, если им пользуются другие сервисы
|
||||||
|
(там уже есть `firecrawl-tunnel.service` на 1081) — это разные ssh-сессии,
|
||||||
|
они не конфликтуют.
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
# Смена выхода для tuigram: SOCKS5 через vps03 вместо vps01
|
||||||
|
|
||||||
|
## Why
|
||||||
|
|
||||||
|
Первый вариант (`telegram-tunnel.service` → vps01, `127.0.0.1:1080`)
|
||||||
|
перестал доводить MTProto-хендшейк: TCP до DC открывается, но TDLib
|
||||||
|
бесконечно висит на `Connecting…`, а `Failed to open connection: Timeout
|
||||||
|
expired` в `tdlib.log` повторяется. Egress vps01 и bigbox находятся в одной
|
||||||
|
российской сети (оба показывают `5.129.217.146`), то есть туннель не меняет
|
||||||
|
юрисдикцию выхода — именно это и режется.
|
||||||
|
|
||||||
|
vps03 (`77.67.89.154`) отдаёт иностранный egress, и через него TDLib
|
||||||
|
получает `auth_key` за ~2 секунды, а tuigram показывает живой QR-код.
|
||||||
|
|
||||||
|
Дополнительно проверена альтернатива — MTProto-прокси владельца
|
||||||
|
(`87.242.100.206:8443`, secret с доменом `tgate.nixg.ru`, TCP/TLS отвечают).
|
||||||
|
tuigram 1.8.1 её НЕ применяет: и `proxy = "https://t.me/proxy?…"` в
|
||||||
|
`settings.toml`, и `TG_PROXY` с той же ссылкой игнорируются — процесс уходит
|
||||||
|
напрямую на `149.154.175.50:443` (видно в `lsof`, `SYN_SENT`). Поэтому
|
||||||
|
рабочий путь — SOCKS5, а не `t.me/proxy`-ссылка.
|
||||||
|
|
||||||
|
## What Changes
|
||||||
|
|
||||||
|
- Новый systemd-юнит `telegram-tunnel-vps03.service`: `ssh -D 127.0.0.1:1082`
|
||||||
|
→ `root@77.67.89.154`, ключ `hostkeyVPS`, `Restart=always`, включён в
|
||||||
|
автозапуск. Слушает ТОЛЬКО localhost.
|
||||||
|
- Пресет прокси в `~/.local/share/tuigram/settings.toml` переводится с
|
||||||
|
`socks5://127.0.0.1:1080` на `socks5://127.0.0.1:1082`.
|
||||||
|
- `telegram-tunnel.service` (vps01, 1080) НЕ трогаем: он остаётся для других
|
||||||
|
задач и покрыт спекой `tunnel-proxy`.
|
||||||
|
|
||||||
|
## Impact
|
||||||
|
|
||||||
|
- bigbox, `/etc/systemd/system/telegram-tunnel-vps03.service`, порт
|
||||||
|
`127.0.0.1:1082`, исходящий SSH 22 до `77.67.89.154`.
|
||||||
|
- Rollback: `systemctl disable --now telegram-tunnel-vps03`, вернуть
|
||||||
|
`settings.toml` на `socks5://127.0.0.1:1080`.
|
||||||
|
|
||||||
|
## Non-goals
|
||||||
|
|
||||||
|
- Не чиним egress vps01 и не выясняем, почему Telegram перестал отвечать
|
||||||
|
через него: для клиента достаточно рабочего выхода.
|
||||||
|
- Не настраиваем MTProto-прокси в tuigram обходными путями (патч бинарника,
|
||||||
|
локальный шим) — ограничиваемся поддерживаемым SOCKS5.
|
||||||
+69
@@ -0,0 +1,69 @@
|
|||||||
|
# terminal-telegram-client Specification
|
||||||
|
|
||||||
|
## MODIFIED Requirements
|
||||||
|
|
||||||
|
### Requirement: Proxy Preset Before First Login
|
||||||
|
|
||||||
|
The client MUST default to the SOCKS5 tunnel that leaves the country
|
||||||
|
(`127.0.0.1:1082` → vps03) before the first login, because direct MTProto to
|
||||||
|
Telegram datacenters is blocked from this host and a tunnel that egresses from
|
||||||
|
the same network as the host does not bypass the block.
|
||||||
|
|
||||||
|
#### 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:1082"`
|
||||||
|
- AND an existing file is not overwritten without an explicit decision
|
||||||
|
|
||||||
|
#### Scenario: Proxy path is reachable
|
||||||
|
- GIVEN `telegram-tunnel-vps03.service` is active
|
||||||
|
- WHEN opening a TCP connection to `149.154.175.50:443` through
|
||||||
|
`127.0.0.1:1082`
|
||||||
|
- THEN the connection succeeds
|
||||||
|
- AND `tdlib.log` records an `auth_key_id` for the main datacenter, i.e. the
|
||||||
|
MTProto handshake actually completed through the tunnel
|
||||||
|
- AND the same connection attempted directly fails, confirming the proxy is
|
||||||
|
required rather than optional
|
||||||
|
|
||||||
|
#### Scenario: Egress differs from the host's own address
|
||||||
|
- GIVEN the tunnel is up
|
||||||
|
- WHEN querying `https://ifconfig.me` through `127.0.0.1:1082`
|
||||||
|
- THEN the reported address is `77.67.89.154` (vps03)
|
||||||
|
- AND it differs from the address seen without a proxy, which is the condition
|
||||||
|
that makes the tunnel useful at all
|
||||||
|
|
||||||
|
#### Scenario: One-off override
|
||||||
|
- GIVEN the preset points at `127.0.0.1:1082`
|
||||||
|
- WHEN the client is started as `TG_PROXY=socks5://host:port tuigram`
|
||||||
|
- THEN the environment value takes precedence over the saved setting
|
||||||
|
|
||||||
|
#### Scenario: MTProto proxy links are not a substitute
|
||||||
|
- GIVEN a working MTProto proxy reachable from the host
|
||||||
|
- WHEN it is supplied as a `t.me/proxy` link through `settings.toml` or
|
||||||
|
`TG_PROXY`
|
||||||
|
- THEN tuigram 1.8.1 MUST NOT be assumed to use it: the observed behaviour is a
|
||||||
|
direct connection attempt to the datacenter, so the SOCKS5 preset stays the
|
||||||
|
supported path
|
||||||
|
|
||||||
|
## ADDED Requirements
|
||||||
|
|
||||||
|
### Requirement: Dedicated Egress Tunnel
|
||||||
|
|
||||||
|
The host MUST run a dedicated SOCKS5 tunnel to vps03 for the terminal Telegram
|
||||||
|
client, independent of tunnels serving other tools.
|
||||||
|
|
||||||
|
#### Scenario: Unit is enabled and listening on localhost only
|
||||||
|
- GIVEN the host boots
|
||||||
|
- WHEN systemd starts `telegram-tunnel-vps03.service`
|
||||||
|
- THEN it listens on `127.0.0.1:1082` and not on wildcard addresses
|
||||||
|
- AND the unit is enabled in `multi-user.target.wants`
|
||||||
|
|
||||||
|
#### Scenario: Tunnel dies
|
||||||
|
- GIVEN the SSH process exits unexpectedly
|
||||||
|
- WHEN systemd detects the failure
|
||||||
|
- THEN the service restarts automatically (`Restart=always`, `RestartSec=10`)
|
||||||
|
|
||||||
|
#### Scenario: Existing tunnels are untouched
|
||||||
|
- GIVEN `telegram-tunnel.service` (vps01, `127.0.0.1:1080`) serves other tasks
|
||||||
|
- WHEN the vps03 tunnel is added or restarted
|
||||||
|
- THEN the vps01 tunnel keeps running and its port binding is unchanged
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# Tasks — switch-telegram-egress-vps03
|
||||||
|
|
||||||
|
## 1. Диагностика (подтвердить, что дело в выходе)
|
||||||
|
|
||||||
|
- [x] 1.1 Прямой TCP до DC заблокирован, через `127.0.0.1:1080` (vps01) —
|
||||||
|
открывается; egress vps01 = `5.129.217.146`, как у bigbox.
|
||||||
|
- [x] 1.2 Через SOCKS vps01 TDLib не доходит до `auth_key`
|
||||||
|
(`Failed to open connection: Timeout expired`), UI висит на `Connecting…`.
|
||||||
|
- [x] 1.3 MTProto-прокси владельца (`87.242.100.206:8443`, FakeTLS
|
||||||
|
`tgate.nixg.ru`) доступен (TCP + TLS ok), но tuigram 1.8.1 ссылку
|
||||||
|
`t.me/proxy` не применяет — уходит напрямую (`SYN_SENT` на DC).
|
||||||
|
|
||||||
|
## 2. Туннель
|
||||||
|
|
||||||
|
- [x] 2.1 Создать `/etc/systemd/system/telegram-tunnel-vps03.service`
|
||||||
|
(`ssh -D 127.0.0.1:1082` → `root@77.67.89.154`, ключ `hostkeyVPS`).
|
||||||
|
Верификация: `systemctl is-active` → active, `ss -ltn | grep 1082`.
|
||||||
|
- [x] 2.2 Включить в автозапуск: `systemctl enable --now`.
|
||||||
|
Верификация: симлинк в `multi-user.target.wants`.
|
||||||
|
- [x] 2.3 Проверить выход и доступность DC:
|
||||||
|
`curl --socks5-hostname 127.0.0.1:1082 https://ifconfig.me` → `77.67.89.154`;
|
||||||
|
`nc -zv -X 5 -x 127.0.0.1:1082 149.154.175.50 443` → succeeded.
|
||||||
|
|
||||||
|
## 3. Клиент
|
||||||
|
|
||||||
|
- [x] 3.1 `~/.local/share/tuigram/settings.toml` →
|
||||||
|
`proxy = "socks5://127.0.0.1:1082"`.
|
||||||
|
Верификация: `grep proxy …/settings.toml`.
|
||||||
|
- [x] 3.2 Живой прогон с отдельным `TG_DATA_DIR`: `auth_key_id` в
|
||||||
|
`tdlib.log`, по `Tab` — QR-код, статус `Connecting…` отсутствует.
|
||||||
|
- [ ] 3.3 Перезапустить рабочий экземпляр клиента у владельца (настройка
|
||||||
|
читается только при старте) и войти по номеру/QR.
|
||||||
|
|
||||||
|
## 4. Фиксация
|
||||||
|
|
||||||
|
- [x] 4.1 Обновить `/opt/tuigram/README.md` (прокси 1082, юнит, почему не
|
||||||
|
`t.me/proxy`).
|
||||||
|
- [x] 4.2 Обновить `STATUS.md` и `WALKTHROUGH.md`.
|
||||||
|
- [x] 4.3 `openspec validate switch-telegram-egress-vps03 --strict` → archive.
|
||||||
@@ -57,29 +57,47 @@ Installation and update MUST use the upstream GitHub release asset for
|
|||||||
|
|
||||||
### Requirement: Proxy Preset Before First Login
|
### Requirement: Proxy Preset Before First Login
|
||||||
|
|
||||||
The client MUST default to the existing SOCKS5 tunnel at `127.0.0.1:1080`
|
The client MUST default to the SOCKS5 tunnel that leaves the country
|
||||||
before the first login, because direct MTProto to Telegram datacenters is
|
(`127.0.0.1:1082` → vps03) before the first login, because direct MTProto to
|
||||||
blocked from this host.
|
Telegram datacenters is blocked from this host and a tunnel that egresses from
|
||||||
|
the same network as the host does not bypass the block.
|
||||||
|
|
||||||
#### Scenario: Settings file carries the proxy
|
#### Scenario: Settings file carries the proxy
|
||||||
- GIVEN `~/.local/share/tuigram/settings.toml` does not exist yet
|
- GIVEN `~/.local/share/tuigram/settings.toml` does not exist yet
|
||||||
- WHEN the proxy preset is applied
|
- WHEN the proxy preset is applied
|
||||||
- THEN the file contains `proxy = "socks5://127.0.0.1:1080"`
|
- THEN the file contains `proxy = "socks5://127.0.0.1:1082"`
|
||||||
- AND an existing file is not overwritten without an explicit decision
|
- AND an existing file is not overwritten without an explicit decision
|
||||||
|
|
||||||
#### Scenario: Proxy path is reachable
|
#### Scenario: Proxy path is reachable
|
||||||
- GIVEN `telegram-tunnel.service` is active
|
- GIVEN `telegram-tunnel-vps03.service` is active
|
||||||
- WHEN opening a TCP connection to `149.154.167.51:443` through
|
- WHEN opening a TCP connection to `149.154.175.50:443` through
|
||||||
`127.0.0.1:1080`
|
`127.0.0.1:1082`
|
||||||
- THEN the connection succeeds
|
- THEN the connection succeeds
|
||||||
|
- AND `tdlib.log` records an `auth_key_id` for the main datacenter, i.e. the
|
||||||
|
MTProto handshake actually completed through the tunnel
|
||||||
- AND the same connection attempted directly fails, confirming the proxy is
|
- AND the same connection attempted directly fails, confirming the proxy is
|
||||||
required rather than optional
|
required rather than optional
|
||||||
|
|
||||||
|
#### Scenario: Egress differs from the host's own address
|
||||||
|
- GIVEN the tunnel is up
|
||||||
|
- WHEN querying `https://ifconfig.me` through `127.0.0.1:1082`
|
||||||
|
- THEN the reported address is `77.67.89.154` (vps03)
|
||||||
|
- AND it differs from the address seen without a proxy, which is the condition
|
||||||
|
that makes the tunnel useful at all
|
||||||
|
|
||||||
#### Scenario: One-off override
|
#### Scenario: One-off override
|
||||||
- GIVEN the preset points at `127.0.0.1:1080`
|
- GIVEN the preset points at `127.0.0.1:1082`
|
||||||
- WHEN the client is started as `TG_PROXY=socks5://host:port tuigram`
|
- WHEN the client is started as `TG_PROXY=socks5://host:port tuigram`
|
||||||
- THEN the environment value takes precedence over the saved setting
|
- THEN the environment value takes precedence over the saved setting
|
||||||
|
|
||||||
|
#### Scenario: MTProto proxy links are not a substitute
|
||||||
|
- GIVEN a working MTProto proxy reachable from the host
|
||||||
|
- WHEN it is supplied as a `t.me/proxy` link through `settings.toml` or
|
||||||
|
`TG_PROXY`
|
||||||
|
- THEN tuigram 1.8.1 MUST NOT be assumed to use it: the observed behaviour is a
|
||||||
|
direct connection attempt to the datacenter, so the SOCKS5 preset stays the
|
||||||
|
supported path
|
||||||
|
|
||||||
### Requirement: Operators' Documentation
|
### Requirement: Operators' Documentation
|
||||||
|
|
||||||
`/opt/tuigram/README.md` MUST document the installed version, how to update
|
`/opt/tuigram/README.md` MUST document the installed version, how to update
|
||||||
@@ -90,3 +108,24 @@ and roll back, the proxy setting, and where user data lives.
|
|||||||
- WHEN comparing it to the installed artifacts
|
- WHEN comparing it to the installed artifacts
|
||||||
- THEN the documented version equals `/opt/tuigram/VERSION`
|
- THEN the documented version equals `/opt/tuigram/VERSION`
|
||||||
- AND the documented data directory equals the path printed by `tuigram --help`
|
- AND the documented data directory equals the path printed by `tuigram --help`
|
||||||
|
|
||||||
|
### Requirement: Dedicated Egress Tunnel
|
||||||
|
|
||||||
|
The host MUST run a dedicated SOCKS5 tunnel to vps03 for the terminal Telegram
|
||||||
|
client, independent of tunnels serving other tools.
|
||||||
|
|
||||||
|
#### Scenario: Unit is enabled and listening on localhost only
|
||||||
|
- GIVEN the host boots
|
||||||
|
- WHEN systemd starts `telegram-tunnel-vps03.service`
|
||||||
|
- THEN it listens on `127.0.0.1:1082` and not on wildcard addresses
|
||||||
|
- AND the unit is enabled in `multi-user.target.wants`
|
||||||
|
|
||||||
|
#### Scenario: Tunnel dies
|
||||||
|
- GIVEN the SSH process exits unexpectedly
|
||||||
|
- WHEN systemd detects the failure
|
||||||
|
- THEN the service restarts automatically (`Restart=always`, `RestartSec=10`)
|
||||||
|
|
||||||
|
#### Scenario: Existing tunnels are untouched
|
||||||
|
- GIVEN `telegram-tunnel.service` (vps01, `127.0.0.1:1080`) serves other tasks
|
||||||
|
- WHEN the vps03 tunnel is added or restarted
|
||||||
|
- THEN the vps01 tunnel keeps running and its port binding is unchanged
|
||||||
|
|||||||
Reference in New Issue
Block a user