2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-01 15:05:56 +00:00

Limit special config request types.

This commit is contained in:
John Preston
2023-01-10 15:03:37 +04:00
parent 05911a7172
commit 1176421bf2
4 changed files with 25 additions and 14 deletions

View File

@@ -188,6 +188,7 @@ SpecialConfigRequest::SpecialConfigRequest(
int port,
bytes::const_span secret)> callback,
Fn<void()> timeDoneCallback,
bool isTestMode,
const QString &domainString,
const QString &phone)
: _callback(std::move(callback))
@@ -219,14 +220,9 @@ SpecialConfigRequest::SpecialConfigRequest(
_attempts = {};
_attempts.push_back({ Type::Google, "dns.google.com" });
_attempts.push_back({ Type::Google, takeDomain(), "dns" });
_attempts.push_back({ Type::Mozilla, "mozilla.cloudflare-dns.com" });
_attempts.push_back({ Type::RemoteConfig, "firebaseremoteconfig" });
while (!domains.empty()) {
_attempts.push_back({ Type::Google, takeDomain(), "dns" });
}
if (!_timeDoneCallback) {
_attempts.push_back({ Type::Realtime, "firebaseio.com" });
_attempts.push_back({ Type::FireStore, "firestore" });
for (const auto &domain : DnsDomains()) {
_attempts.push_back({ Type::FireStore, domain, "firestore" });
@@ -234,12 +230,15 @@ SpecialConfigRequest::SpecialConfigRequest(
}
shuffle(0, 2);
shuffle(2, 4);
if (!_timeDoneCallback) {
shuffle(
_attempts.size() - (2 + domainsCount),
_attempts.size() - domainsCount);
shuffle(_attempts.size() - domainsCount, _attempts.size());
shuffle(_attempts.size() - (domainsCount + 1), _attempts.size());
}
if (isTestMode) {
_attempts.erase(ranges::remove_if(_attempts, [](
const Attempt &attempt) {
return (attempt.type != Type::Google)
&& (attempt.type != Type::Mozilla);
}), _attempts.end());
}
ranges::reverse(_attempts); // We go from last to first.
@@ -252,17 +251,25 @@ SpecialConfigRequest::SpecialConfigRequest(
const std::string &ip,
int port,
bytes::const_span secret)> callback,
bool isTestMode,
const QString &domainString,
const QString &phone)
: SpecialConfigRequest(std::move(callback), nullptr, domainString, phone) {
: SpecialConfigRequest(
std::move(callback),
nullptr,
isTestMode,
domainString,
phone) {
}
SpecialConfigRequest::SpecialConfigRequest(
Fn<void()> timeDoneCallback,
bool isTestMode,
const QString &domainString)
: SpecialConfigRequest(
nullptr,
std::move(timeDoneCallback),
isTestMode,
domainString,
QString()) {
}