Skip to main content

Crate ferogram_connect

Crate ferogram_connect 

Source
Expand description

Raw TCP connection, MTProto framing, and transport for ferogram.

This crate is part of ferogram, an async Rust MTProto client built by Ankit Chaubey.

Most users do not need this crate directly. The ferogram crate wraps everything. Use ferogram-connect only if you are building a custom transport layer, an MTProxy relay, or need low-level control over how frames are sent and received.

§What’s in here

  • connect_to_dc: Dials a Telegram DC, performs the MTProto handshake (auth key generation or reuse), and returns a Connection ready for encrypted RPC traffic.
  • TransportKind: Selects the wire framing: Abridged, Intermediate, Full (default), Obfuscated2, PaddedIntermediate, or FakeTLS. Obfuscated variants are required for MTProxy and resist DPI.
  • FrameKind: Runtime framing state attached to a live connection. Full transport tracks per-direction sequence numbers and CRC32; Obfuscated variants share an Arc<Mutex<ObfuscatedCipher>> so TX and RX run concurrently without a separate lock per direction.
  • send_frame / recv_frame_plain: Frame serialisation and deserialisation helpers for the various transport shapes.
  • SOCKS5 / MTProxy: Socks5Config and MtProxyConfig let you route connections through a proxy before the MTProto handshake.
  • PFS helpers: decode_bind_response / decode_bind_single decode the auth.bindTempAuthKey response without pulling in the full TL schema crate.
  • Utilities: gz_inflate, maybe_gz_decompress, build_container_body, maybe_gz_pack, crc32_ieee, and friends used by the sender layer.

§Example: establish a plain connection

use ferogram_connect::{TransportKind, connect_to_dc};

// DC 2 production address; in practice load this from your session/config.
let (stream, frame_kind, session) =
    connect_to_dc("149.154.167.51:443", 2, &TransportKind::Full, None, None).await?;
println!("connected, salt={}", session.salt);

Re-exports§

pub use connection::Connection;
pub use connection::FrameKind;
pub use connection::FutureSalt;
pub use connection::connect_to_dc;
pub use error::ConnectError;
pub use frame::send_frame;
pub use pfs::decode_bind_response;
pub use pfs::decode_bind_single;
pub use proxy::MtProxyConfig;
pub use socks5::Socks5Config;
pub use transport_intermediate::FullTransport;
pub use transport_intermediate::IntermediateTransport;
pub use transport_intermediate::PaddedIntermediateTransport;
pub use transport_kind::TransportKind;
pub use transport_obfuscated::ObfuscatedFraming;
pub use transport_obfuscated::ObfuscatedStream;
pub use util::crc32_ieee;
pub use util::gz_inflate;
pub use util::maybe_gz_decompress;
pub use util::random_i64;
pub use util::tl_read_bytes;
pub use connection::NO_PING_DISCONNECT;
pub use connection::PING_DELAY_SECS;
pub use connection::SALT_USE_DELAY;
pub use frame::recv_frame_plain;
pub use util::COMPRESSION_THRESHOLD;
pub use util::build_container_body;
pub use util::build_msgs_ack_body;
pub use util::gz_pack_body;
pub use util::jitter_delay;
pub use util::maybe_gz_pack;
pub use util::tl_read_string;
pub use util::tl_write_bytes;

Modules§

connection
error
frame
pfs
PFS (Perfect Forward Secrecy) bind response decoder.
proxy
socks5
transport
transport_intermediate
transport_kind
transport_obfuscated
util