diff --git a/CHANGELOG.md b/CHANGELOG.md index daf622cae..00eedd8d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ - replaced stock string `DC_STR_ONE_MOMENT` by `DC_STR_NOT_CONNECTED` #3222 - add `dc_resend_msgs()` #3238 +- `dc_provider_new_from_email()` does no longer do an DNS lookup for checking custom domains, + this is done by `dc_provider_new_from_email_with_dns()` now #3256 ### Fixes diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 4aca4afc2..3e08daa05 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -4648,9 +4648,10 @@ int dc_contact_is_verified (dc_contact_t* contact); /** - * Create a provider struct for the given e-mail address. + * Create a provider struct for the given e-mail address by local lookup. * - * The provider is extracted from the e-mail address and it's information is returned. + * Lookup is done from the local database by extracting the domain from the e-mail address. + * Therefore the provider for custom domains cannot be identified. * * @memberof dc_provider_t * @param context The context object. @@ -4662,6 +4663,23 @@ int dc_contact_is_verified (dc_contact_t* contact); dc_provider_t* dc_provider_new_from_email (const dc_context_t* context, const char* email); +/** + * Create a provider struct for the given e-mail address by local and DNS lookup. + * + * First lookup is done from the local database as of dc_provider_new_from_email(). + * If the first lookup fails, an additional DNS lookup is done, + * trying to figure out the provider belonging to custom domains. + * + * @memberof dc_provider_t + * @param context The context object. + * @param email The user's e-mail address to extract the provider info form. + * @return A dc_provider_t struct which can be used with the dc_provider_get_* + * accessor functions. If no provider info is found, NULL will be + * returned. + */ +dc_provider_t* dc_provider_new_from_email_with_dns (const dc_context_t* context, const char* email); + + /** * URL of the overview page. * diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index d19f9d3ab..cf5ed81ea 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -3973,6 +3973,25 @@ pub unsafe extern "C" fn dc_provider_new_from_email( } let addr = to_string_lossy(addr); + let ctx = &*context; + + match block_on(provider::get_provider_info(ctx, addr.as_str(), true)) { + Some(provider) => provider, + None => ptr::null_mut(), + } +} + +#[no_mangle] +pub unsafe extern "C" fn dc_provider_new_from_email_with_dns( + context: *const dc_context_t, + addr: *const libc::c_char, +) -> *const dc_provider_t { + if context.is_null() || addr.is_null() { + eprintln!("ignoring careless call to dc_provider_new_from_email_with_dns()"); + return ptr::null(); + } + let addr = to_string_lossy(addr); + let ctx = &*context; let socks5_enabled = block_on(async move { ctx.get_config_bool(config::Config::Socks5Enabled)