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:
2026-11-07 15:48:05 +00:00
parent 9ea191533b
commit 02fb8f1810
8 changed files with 325 additions and 10 deletions
@@ -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