diff --git a/td/telegram/ConfigManager.cpp b/td/telegram/ConfigManager.cpp index 97603c173..81f5e028a 100644 --- a/td/telegram/ConfigManager.cpp +++ b/td/telegram/ConfigManager.cpp @@ -229,9 +229,9 @@ ActorOwn<> get_simple_config_azure(Promise promise, const Co return get_simple_config_impl(std::move(promise), scheduler_id, std::move(url), "tcdnb.azureedge.net", prefer_ipv6); } -ActorOwn<> get_simple_config_google_dns(Promise promise, const ConfigShared *shared_config, - bool is_test, int32 scheduler_id) { - VLOG(config_recoverer) << "Request simple config from Google DNS"; +static ActorOwn<> get_simple_config_dns(Slice address, Slice host, Promise promise, + const ConfigShared *shared_config, bool is_test, int32 scheduler_id) { + VLOG(config_recoverer) << "Request simple config from DNS"; #if TD_EMSCRIPTEN // FIXME return ActorOwn<>(); #else @@ -281,12 +281,24 @@ ActorOwn<> get_simple_config_google_dns(Promise promise, con return std::move(res); }()); }), - PSTRING() << "https://www.google.com/resolve?name=" << url_encode(name) << "&type=16", - std::vector>({{"Host", "dns.google.com"}}), timeout, ttl, prefer_ipv6, - SslStream::VerifyPeer::Off)); + PSTRING() << "https://" << address << "?name=" << url_encode(name) << "&type=16", + std::vector>({{"Host", host.str()}, {"Accept", "application/dns-json"}}), timeout, ttl, + prefer_ipv6, SslStream::VerifyPeer::Off)); #endif } +ActorOwn<> get_simple_config_google_dns(Promise promise, const ConfigShared *shared_config, + bool is_test, int32 scheduler_id) { + return get_simple_config_dns("www.google.com/resolve", "dns.google.com", std::move(promise), shared_config, is_test, + scheduler_id); +} + +ActorOwn<> get_simple_config_mozilla_dns(Promise promise, const ConfigShared *shared_config, + bool is_test, int32 scheduler_id) { + return get_simple_config_dns("mozilla.cloudflare-dns.com/dns-query", "mozilla.cloudflare-dns.com", std::move(promise), + shared_config, is_test, scheduler_id); +} + ActorOwn<> get_full_config(DcOption option, Promise promise, ActorShared<> parent) { class SessionCallback : public Session::Callback { public: diff --git a/td/telegram/ConfigManager.h b/td/telegram/ConfigManager.h index 849853f57..ea7d1c1b1 100644 --- a/td/telegram/ConfigManager.h +++ b/td/telegram/ConfigManager.h @@ -41,6 +41,9 @@ ActorOwn<> get_simple_config_azure(Promise promise, const Co ActorOwn<> get_simple_config_google_dns(Promise promise, const ConfigShared *shared_config, bool is_test, int32 scheduler_id); +ActorOwn<> get_simple_config_mozilla_dns(Promise promise, const ConfigShared *shared_config, + bool is_test, int32 scheduler_id); + class HttpDate { static bool is_leap(int32 year) { return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0); diff --git a/test/mtproto.cpp b/test/mtproto.cpp index ac4d07603..d11f69827 100644 --- a/test/mtproto.cpp +++ b/test/mtproto.cpp @@ -166,8 +166,10 @@ TEST(Mtproto, config) { run(get_simple_config_azure, false); run(get_simple_config_google_dns, false); + run(get_simple_config_mozilla_dns, false); run(get_simple_config_azure, true); run(get_simple_config_google_dns, true); + run(get_simple_config_mozilla_dns, true); } cnt--; sched.start();