Skip to content
This repository was archived by the owner on Feb 10, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions grammers-mtsender/src/sender_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,22 +291,30 @@ impl SenderPoolRunner {
) -> Result<Sender<transport::Full, mtp::Encrypted>, InvocationError> {
let transport = transport::Full::new;

let address = match std::env::var("PREFER_V6") {
Comment thread
tsukinaha marked this conversation as resolved.
Outdated
Ok(val) if val == "1" || val.eq_ignore_ascii_case("true") => {
log::info!("Using IPv6 connection");
dc_option.ipv6.into()
}
_ => dc_option.ipv4.into()
};

#[cfg(feature = "proxy")]
let addr = || {
if let Some(proxy) = self.connection_params.proxy_url.clone() {
ServerAddr::Proxied {
address: dc_option.ipv4.into(),
address,
proxy,
}
} else {
ServerAddr::Tcp {
address: dc_option.ipv4.into(),
address,
}
}
};
#[cfg(not(feature = "proxy"))]
let addr = || ServerAddr::Tcp {
address: dc_option.ipv4.into(),
address,
};

let init_connection = tl::functions::InvokeWithLayer {
Expand Down
16 changes: 8 additions & 8 deletions grammers-session/src/dc_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::net::{Ipv4Addr, SocketAddrV4, SocketAddrV6};
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddrV4, SocketAddrV6};

use crate::types::DcOption;

Expand All @@ -16,40 +16,40 @@ const fn ipv4(a: u8, b: u8, c: u8, d: u8) -> SocketAddrV4 {
SocketAddrV4::new(Ipv4Addr::new(a, b, c, d), 443)
}

const fn ipv6(a: u8, b: u8, c: u8, d: u8) -> SocketAddrV6 {
SocketAddrV6::new(ipv4(a, b, c, d).ip().to_ipv6_compatible(), 443, 0, 0)
const fn ipv6(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16, h: u16) -> SocketAddrV6 {
SocketAddrV6::new(Ipv6Addr::new(a, b, c, d, e, f, g, h), 443, 0, 0)
}

/// Hardcoded known `static` options from `functions::help::GetConfig`.
pub(crate) const KNOWN_DC_OPTIONS: [DcOption; 5] = [
DcOption {
id: 1,
ipv4: ipv4(149, 154, 175, 53),
ipv6: ipv6(149, 154, 175, 53),
ipv6: ipv6(0x2001, 0xb28, 0xf23d, 0xf001, 0, 0, 0, 0xa),
auth_key: None,
},
DcOption {
id: 2,
ipv4: ipv4(149, 154, 167, 41),
ipv6: ipv6(149, 154, 167, 41),
ipv6: ipv6(0x2001, 0x67c, 0x4e8, 0xf002, 0, 0, 0, 0xa),
auth_key: None,
},
DcOption {
id: 3,
ipv4: ipv4(149, 154, 175, 100),
ipv6: ipv6(149, 154, 175, 100),
ipv6: ipv6(0x2001, 0xb28, 0xf23d, 0xf003, 0, 0, 0, 0xa),
auth_key: None,
},
DcOption {
id: 4,
ipv4: ipv4(149, 154, 167, 92),
ipv6: ipv6(149, 154, 167, 92),
ipv6: ipv6(0x2001, 0x67c, 0x4e8, 0xf004, 0, 0, 0, 0xa),
auth_key: None,
},
DcOption {
id: 5,
ipv4: ipv4(91, 108, 56, 104),
ipv6: ipv6(91, 108, 56, 104),
ipv6: ipv6(0x2001, 0xb28, 0xf23f, 0xf005, 0, 0, 0, 0xa),
auth_key: None,
},
];
Loading