Skip to content

miniproto.auth.dc.select_dc_option

select_dc_option(options: Iterable[DCOption], dc_id: int, *, prefer_ipv6: bool = False, allow_media_only: bool = False) -> DCOption

Choose the best endpoint for a data center.

Parameters:

  • options (Iterable[DCOption]) – Candidate connection options.
  • dc_id (int) – Required Telegram data-center identifier.
  • prefer_ipv6 (bool) – Prefer an IPv6 candidate when one is available.
  • allow_media_only (bool) – Permit endpoints reserved for media traffic.

Returns:

  • DCOption – A non-media endpoint when possible, otherwise the best available candidate.

Raises:

  • ValueError – If options has no endpoint for dc_id.