Skip to content

Commit 214a1d3

Browse files
committed
feat: do not resolve MX records during configuration
MX record lookup was only used to detect Google Workspace domains. They can still be configured manually. We anyway do not want to encourage creating new profiles with Google Workspace as we don't have Gmail OAUTH2 token anymore and new users can more easily onboard with a chatmail relay.
1 parent e270a50 commit 214a1d3

File tree

11 files changed

+47
-205
lines changed

11 files changed

+47
-205
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ fd-lock = "4"
6161
futures-lite = { workspace = true }
6262
futures = { workspace = true }
6363
hex = "0.4.0"
64-
hickory-resolver = "0.25.2"
6564
http-body-util = "0.1.3"
6665
humansize = "2"
6766
hyper = "1"

deltachat-ffi/deltachat.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5350,18 +5350,17 @@ dc_provider_t* dc_provider_new_from_email (const dc_context_t* conte
53505350

53515351

53525352
/**
5353-
* Create a provider struct for the given e-mail address by local and DNS lookup.
5353+
* Create a provider struct for the given e-mail address by local lookup.
53545354
*
5355-
* First lookup is done from the local database as of dc_provider_new_from_email().
5356-
* If the first lookup fails, an additional DNS lookup is done,
5357-
* trying to figure out the provider belonging to custom domains.
5355+
* DNS lookup is not used anymore and this function is deprecated.
53585356
*
53595357
* @memberof dc_provider_t
53605358
* @param context The context object.
53615359
* @param email The user's e-mail address to extract the provider info form.
53625360
* @return A dc_provider_t struct which can be used with the dc_provider_get_*
53635361
* accessor functions. If no provider info is found, NULL will be
53645362
* returned.
5363+
* @deprecated 2025-10-17 use dc_provider_new_from_email() instead.
53655364
*/
53665365
dc_provider_t* dc_provider_new_from_email_with_dns (const dc_context_t* context, const char* email);
53675366

deltachat-ffi/src/lib.rs

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4661,13 +4661,9 @@ pub unsafe extern "C" fn dc_provider_new_from_email(
46614661

46624662
let ctx = &*context;
46634663

4664-
match block_on(provider::get_provider_info_by_addr(
4665-
ctx,
4666-
addr.as_str(),
4667-
true,
4668-
))
4669-
.log_err(ctx)
4670-
.unwrap_or_default()
4664+
match provider::get_provider_info_by_addr(addr.as_str())
4665+
.log_err(ctx)
4666+
.unwrap_or_default()
46714667
{
46724668
Some(provider) => provider,
46734669
None => ptr::null_mut(),
@@ -4686,25 +4682,13 @@ pub unsafe extern "C" fn dc_provider_new_from_email_with_dns(
46864682
let addr = to_string_lossy(addr);
46874683

46884684
let ctx = &*context;
4689-
let proxy_enabled = block_on(ctx.get_config_bool(config::Config::ProxyEnabled))
4690-
.context("Can't get config")
4691-
.log_err(ctx);
46924685

4693-
match proxy_enabled {
4694-
Ok(proxy_enabled) => {
4695-
match block_on(provider::get_provider_info_by_addr(
4696-
ctx,
4697-
addr.as_str(),
4698-
proxy_enabled,
4699-
))
4700-
.log_err(ctx)
4701-
.unwrap_or_default()
4702-
{
4703-
Some(provider) => provider,
4704-
None => ptr::null_mut(),
4705-
}
4706-
}
4707-
Err(_) => ptr::null_mut(),
4686+
match provider::get_provider_info_by_addr(addr.as_str())
4687+
.log_err(ctx)
4688+
.unwrap_or_default()
4689+
{
4690+
Some(provider) => provider,
4691+
None => ptr::null_mut(),
47084692
}
47094693
}
47104694

deltachat-jsonrpc/src/api.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -336,21 +336,10 @@ impl CommandApi {
336336
/// instead of the domain.
337337
async fn get_provider_info(
338338
&self,
339-
account_id: u32,
339+
_account_id: u32,
340340
email: String,
341341
) -> Result<Option<ProviderInfo>> {
342-
let ctx = self.get_context(account_id).await?;
343-
344-
let proxy_enabled = ctx
345-
.get_config_bool(deltachat::config::Config::ProxyEnabled)
346-
.await?;
347-
348-
let provider_info = get_provider_info(
349-
&ctx,
350-
email.split('@').next_back().unwrap_or(""),
351-
proxy_enabled,
352-
)
353-
.await;
342+
let provider_info = get_provider_info(email.split('@').next_back().unwrap_or(""));
354343
Ok(ProviderInfo::from_dc_type(provider_info))
355344
}
356345

deltachat-repl/src/cmdline.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,10 +1266,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
12661266
}
12671267
"providerinfo" => {
12681268
ensure!(!arg1.is_empty(), "Argument <addr> missing.");
1269-
let proxy_enabled = context
1270-
.get_config_bool(config::Config::ProxyEnabled)
1271-
.await?;
1272-
match provider::get_provider_info(&context, arg1, proxy_enabled).await {
1269+
match provider::get_provider_info(arg1) {
12731270
Some(info) => {
12741271
println!("Information for provider belonging to {arg1}:");
12751272
println!("status: {}", info.status as u32);

deltachat-rpc-client/tests/test_something.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,11 @@ def test_provider_info(rpc) -> None:
570570
assert provider_info is None
571571

572572
# Test MX record resolution.
573+
# This previously resulted in Gmail provider
574+
# because MX record pointed to google.com domain,
575+
# but MX record resolution has been removed.
573576
provider_info = rpc.get_provider_info(account_id, "github.com")
574-
assert provider_info["id"] == "gmail"
577+
assert provider_info is None
575578

576579
# Disable MX record resolution.
577580
rpc.set_config(account_id, "proxy_enabled", "1")

src/configure.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,6 @@ async fn get_configured_param(
300300
param.smtp.password.clone()
301301
};
302302

303-
let proxy_enabled = ctx.get_config_bool(Config::ProxyEnabled).await?;
304-
305303
let mut addr = param.addr.clone();
306304
if param.oauth2 {
307305
// the used oauth2 addr may differ, check this.
@@ -343,7 +341,7 @@ async fn get_configured_param(
343341
"checking internal provider-info for offline autoconfig"
344342
);
345343

346-
provider = provider::get_provider_info(ctx, &param_domain, proxy_enabled).await;
344+
provider = provider::get_provider_info(&param_domain);
347345
if let Some(provider) = provider {
348346
if provider.server.is_empty() {
349347
info!(ctx, "Offline autoconfig found, but no servers defined.");

src/oauth2.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub async fn get_oauth2_url(
5353
addr: &str,
5454
redirect_uri: &str,
5555
) -> Result<Option<String>> {
56-
if let Some(oauth2) = Oauth2::from_address(context, addr).await {
56+
if let Some(oauth2) = Oauth2::from_address(addr) {
5757
context
5858
.sql
5959
.set_raw_config("oauth2_pending_redirect_uri", Some(redirect_uri))
@@ -73,7 +73,7 @@ pub(crate) async fn get_oauth2_access_token(
7373
code: &str,
7474
regenerate: bool,
7575
) -> Result<Option<String>> {
76-
if let Some(oauth2) = Oauth2::from_address(context, addr).await {
76+
if let Some(oauth2) = Oauth2::from_address(addr) {
7777
let lock = context.oauth2_mutex.lock().await;
7878

7979
// read generated token
@@ -221,7 +221,7 @@ pub(crate) async fn get_oauth2_addr(
221221
addr: &str,
222222
code: &str,
223223
) -> Result<Option<String>> {
224-
let oauth2 = match Oauth2::from_address(context, addr).await {
224+
let oauth2 = match Oauth2::from_address(addr) {
225225
Some(o) => o,
226226
None => return Ok(None),
227227
};
@@ -256,15 +256,13 @@ pub(crate) async fn get_oauth2_addr(
256256
}
257257

258258
impl Oauth2 {
259-
async fn from_address(context: &Context, addr: &str) -> Option<Self> {
259+
fn from_address(addr: &str) -> Option<Self> {
260260
let addr_normalized = normalize_addr(addr);
261-
let skip_mx = true;
262261
if let Some(domain) = addr_normalized
263262
.find('@')
264263
.map(|index| addr_normalized.split_at(index + 1).1)
265264
{
266-
if let Some(oauth2_authorizer) = provider::get_provider_info(context, domain, skip_mx)
267-
.await
265+
if let Some(oauth2_authorizer) = provider::get_provider_info(domain)
268266
.and_then(|provider| provider.oauth2_authorizer.as_ref())
269267
{
270268
return Some(match oauth2_authorizer {
@@ -354,21 +352,16 @@ mod tests {
354352

355353
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
356354
async fn test_oauth_from_address() {
357-
let t = TestContext::new().await;
358-
359355
// Delta Chat does not have working Gmail client ID anymore.
360-
assert_eq!(Oauth2::from_address(&t, "hello@gmail.com").await, None);
361-
assert_eq!(Oauth2::from_address(&t, "hello@googlemail.com").await, None);
356+
assert_eq!(Oauth2::from_address("hello@gmail.com"), None);
357+
assert_eq!(Oauth2::from_address("hello@googlemail.com"), None);
362358

363359
assert_eq!(
364-
Oauth2::from_address(&t, "hello@yandex.com").await,
365-
Some(OAUTH2_YANDEX)
366-
);
367-
assert_eq!(
368-
Oauth2::from_address(&t, "hello@yandex.ru").await,
360+
Oauth2::from_address("hello@yandex.com"),
369361
Some(OAUTH2_YANDEX)
370362
);
371-
assert_eq!(Oauth2::from_address(&t, "hello@web.de").await, None);
363+
assert_eq!(Oauth2::from_address("hello@yandex.ru"), Some(OAUTH2_YANDEX));
364+
assert_eq!(Oauth2::from_address("hello@web.de"), None);
372365
}
373366

374367
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]

0 commit comments

Comments
 (0)