Skip to content

v0.165.0

Choose a tag to compare

@ernado ernado released this 12 Nov 02:17
eae692a

gotd now talks to Telegram more like Telegram Desktop does, keeps server sessions and other DCs' keys across reconnects and restarts, tolerates a skewed local clock, recovers updates faster after errors, caches peers by default and can log out. Most of these came from comparing gotd's wire traffic with Telegram Desktop's on the same account.

Highlights

Traffic like Telegram Desktop

  • invokeWithLayer is sent only until the connection is inited, then queries go without it; it is re-sent after CONNECTION_NOT_INITED/CONNECTION_LAYER_INVALID (#1964).
  • No get_future_salts: salts come from new_session_created and bad_server_salt (#1965).
  • ping_delay_disconnect(60) every 30–45 s with jitter instead of (75) every 60 s (#1966).
  • upload.getFile sets precise only for unaligned parts (#1958); empty entities vectors are omitted (#1956).

Sessions and clock

  • Session data keeps the auth keys of other DCs (no new transfer after a restart), key age, the server time offset and the self user id; old session files load unchanged, newer formats return ErrVersionUnsupported (#1971, #1974, #1975). New Client.SelfID().
  • The server session (session_id) continues across reconnects with the same key; after the server starts a new session, requests it didn't see are resent and updates are re-fetched (#1972).
  • Server time offset like TDLib: msg_ids follow the spec and use server time, a client clock off by minutes works, and bad_msg_notification 16/17/20 are re-sent (#1968). Options.ServerTimeOffset, Client.ServerTimeOffset().
  • Received messages are deduplicated like TDLib's MessageIdDuplicateChecker, including messages inside containers (#1969).
  • PFS: the permanent key is dropped only when the server confirms it is gone; AUTH_KEY_PERM_EMPTY reconnects with a new temporary key (#1973).

Updates and peers

  • Failed getDifference/getChannelDifference are retried with backoff (1 s doubling to 60 s), FLOOD_WAIT is waited out, and PERSISTENT_TIMESTAMP_* resets the state (#1961).
  • telegram/peers caches peers and usernames by default; usernames are normalized like TDLib and cached for 24 h (#1962).
  • peers.Manager can be the updates access hasher, and updates.FileStorage stores user access hashes, avoiding extra differences for known channels (#1963).

Auth and files

  • Client.LogOut logs out on all DCs, returns future_auth_token and wipes the session (#1959).
  • Uploaded documents get a MIME type from the extension (or application/octet-stream) and a file name; before, Telegram Desktop could show them as audio (#1957).
  • A DC auth key dropped after a PFS reset is no longer stored back by a connection still using it (#1967).

Upgrading

  • Session continuity (#1972): reconnects continue the server session; duplicates are filtered by pts, but after a server-side session loss a write the server already executed may be re-sent.

  • Session format (#1971): new optional fields, format version unchanged; older gotd versions ignore them.

  • Duplicates (#1969): a server message re-sent after more than 100 newer ones is dropped, as the spec intends.

  • Salts (#1965): one extra round trip per salt expiry (bad_server_salt + resend). Set SaltFetchInterval for the old periodic fetch.

  • Pings (#1966): every 30–45 s by default; an explicit PingInterval keeps a fixed interval.

  • peers cache (#1962): peers.Options.Cache defaults to an unbounded in-memory cache; pass peers.NoopCache{} to opt out.

  • Difference retries (#1961): failures are retried instead of waiting for the 15-minute idle timer; new updates.Config.Clock.

  • Documents (#1957): audio, video and sticker uploads without an explicit MIME now get one from the extension (Go's mime package, which also reads system MIME tables).

All changes

  • fix(message): omit empty entities vectors by @ernado in #1956
  • fix(message): send MIME type and file name of uploaded documents by @ernado in #1957
  • fix(downloader): send precise only for unaligned parts by @ernado in #1958
  • feat(telegram): add Client.LogOut by @ernado in #1959
  • fix(updates): retry failed differences with backoff by @ernado in #1961
  • feat(peers): cache peers and usernames by default by @ernado in #1962
  • fix(updates): share access hashes with peers by @ernado in #1963
  • fix(telegram): don't store back a DC auth key dropped after a PFS reset by @ernado in #1967
  • fix(manager): send invokeWithLayer only until the connection is inited by @ernado in #1964
  • fix(mtproto): ping like Telegram Desktop by @ernado in #1966
  • fix(mtproto): don't request future salts by default by @ernado in #1965
  • test: fix flaky StopOnApplyError and group call tests by @ernado in #1970
  • fix(mtproto): deduplicate received messages like TDLib by @ernado in #1969
  • feat(mtproto): track server time offset for msg_ids by @ernado in #1968
  • feat(session): persist per-DC keys, key age and self id by @ernado in #1971
  • fix(mtproto): keep session_id across reconnects by @ernado in #1972
  • fix(mtproto): drop PFS perm keys only when the server lost them by @ernado in #1973
  • fix(telegram): mark DC keys authorized when the session arrives after the transfer by @ernado in #1975
  • feat(telegram): persist the server time offset in the session by @ernado in #1974

Full Changelog: v0.164.1...v0.165.0