Support dc_txt_domain_name.

GitOrigin-RevId: 6762d63f67b886cb990eae24536adcabda557316
This commit is contained in:
levlam 2018-06-26 23:46:15 +03:00
parent 7150cfc8b2
commit e806037eea
3 changed files with 10 additions and 7 deletions

View File

@ -138,6 +138,7 @@ ActorOwn<> get_simple_config_google_dns(Promise<SimpleConfig> promise, bool is_t
#if TD_EMSCRIPTEN // FIXME #if TD_EMSCRIPTEN // FIXME
return ActorOwn<>(); return ActorOwn<>();
#else #else
auto name = G()->shared_config().get_option_string("dc_txt_domain_name", is_test ? "tapv2.stel.com" : "apv2.stel.com");
return ActorOwn<>(create_actor_on_scheduler<Wget>( return ActorOwn<>(create_actor_on_scheduler<Wget>(
"Wget", scheduler_id, "Wget", scheduler_id,
PromiseCreator::lambda([promise = std::move(promise)](Result<HttpQueryPtr> r_query) mutable { PromiseCreator::lambda([promise = std::move(promise)](Result<HttpQueryPtr> r_query) mutable {
@ -171,7 +172,7 @@ ActorOwn<> get_simple_config_google_dns(Promise<SimpleConfig> promise, bool is_t
return decode_config(data); return decode_config(data);
}()); }());
}), }),
PSTRING() << "https://www.google.com/resolve?name=" << (is_test ? "t" : "") << "apv2.stel.com&type=16", PSTRING() << "https://www.google.com/resolve?name=" << url_encode(name) << "&type=16",
std::vector<std::pair<string, string>>({{"Host", "dns.google.com"}}), 10 /*timeout*/, 3 /*ttl*/, std::vector<std::pair<string, string>>({{"Host", "dns.google.com"}}), 10 /*timeout*/, 3 /*ttl*/,
SslFd::VerifyPeer::Off)); SslFd::VerifyPeer::Off));
#endif #endif
@ -759,6 +760,9 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
shared_config.set_option_boolean("expect_blocking", shared_config.set_option_boolean("expect_blocking",
(config->flags_ & telegram_api::config::BLOCKED_MODE_MASK) != 0); (config->flags_ & telegram_api::config::BLOCKED_MODE_MASK) != 0);
} }
if (is_from_main_dc || !shared_config.have_option("dc_txt_domain_name")) {
shared_config.set_option_string("dc_txt_domain_name", config->dc_txt_domain_name_);
}
if (is_from_main_dc || !shared_config.have_option("t_me_url")) { if (is_from_main_dc || !shared_config.have_option("t_me_url")) {
auto url = config->me_url_prefix_; auto url = config->me_url_prefix_;
if (!url.empty()) { if (!url.empty()) {
@ -769,6 +773,7 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
} }
} }
if (is_from_main_dc) { if (is_from_main_dc) {
shared_config.set_option_integer("webfile_dc_id", config->webfile_dc_id_);
if ((config->flags_ & telegram_api::config::TMP_SESSIONS_MASK) != 0) { if ((config->flags_ & telegram_api::config::TMP_SESSIONS_MASK) != 0) {
G()->shared_config().set_option_integer("session_count", config->tmp_sessions_); G()->shared_config().set_option_integer("session_count", config->tmp_sessions_);
} else { } else {
@ -792,8 +797,6 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
shared_config.set_option_integer("call_packet_timeout_ms", config->call_packet_timeout_ms_); shared_config.set_option_integer("call_packet_timeout_ms", config->call_packet_timeout_ms_);
shared_config.set_option_integer("call_receive_timeout_ms", config->call_receive_timeout_ms_); shared_config.set_option_integer("call_receive_timeout_ms", config->call_receive_timeout_ms_);
shared_config.set_option_integer("webfile_dc_id", config->webfile_dc_id_);
// delete outdated options // delete outdated options
shared_config.set_option_empty("chat_big_size"); shared_config.set_option_empty("chat_big_size");
shared_config.set_option_empty("group_size_max"); shared_config.set_option_empty("group_size_max");

View File

@ -89,11 +89,11 @@ int32 ConfigShared::get_option_integer(Slice name, int32 default_value) const {
string ConfigShared::get_option_string(Slice name, string default_value) const { string ConfigShared::get_option_string(Slice name, string default_value) const {
auto str_value = get_option(name); auto str_value = get_option(name);
if (str_value.empty()) { if (str_value.empty()) {
return default_value; return std::move(default_value);
} }
if (str_value[0] != 'S') { if (str_value[0] != 'S') {
LOG(ERROR) << "Found \"" << str_value << "\" instead of string option"; LOG(ERROR) << "Found \"" << str_value << "\" instead of string option";
return default_value; return std::move(default_value);
} }
return str_value.substr(1); return str_value.substr(1);
} }

View File

@ -4236,8 +4236,8 @@ bool Td::is_internal_config_option(Slice name) {
return name == "call_ring_timeout_ms" || name == "call_receive_timeout_ms" || name == "channels_read_media_period" || return name == "call_ring_timeout_ms" || name == "call_receive_timeout_ms" || name == "channels_read_media_period" ||
name == "edit_time_limit" || name == "revoke_pm_inbox" || name == "revoke_time_limit" || name == "edit_time_limit" || name == "revoke_pm_inbox" || name == "revoke_time_limit" ||
name == "revoke_pm_time_limit" || name == "rating_e_decay" || name == "saved_animations_limit" || name == "revoke_pm_time_limit" || name == "rating_e_decay" || name == "saved_animations_limit" ||
name == "recent_stickers_limit" || name == "expect_blocking" || name == "my_phone_number" || name == "recent_stickers_limit" || name == "expect_blocking" || name == "dc_txt_domain_name" ||
name == "webfile_dc_id" || name == "auth"; name == "my_phone_number" || name == "webfile_dc_id" || name == "auth";
} }
void Td::on_config_option_updated(const string &name) { void Td::on_config_option_updated(const string &name) {