mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Limit special config request types.
This commit is contained in:
parent
05911a7172
commit
1176421bf2
4 changed files with 25 additions and 14 deletions
|
@ -116,7 +116,7 @@ void ConfigLoader::enumerate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigLoader::refreshSpecialLoader() {
|
void ConfigLoader::refreshSpecialLoader() {
|
||||||
if (_proxyEnabled) {
|
if (_proxyEnabled || _instance->isKeysDestroyer()) {
|
||||||
_specialLoader.reset();
|
_specialLoader.reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,7 @@ void ConfigLoader::setPhone(const QString &phone) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigLoader::createSpecialLoader() {
|
void ConfigLoader::createSpecialLoader() {
|
||||||
|
const auto testMode = _instance->isTestMode();
|
||||||
_triedSpecialEndpoints.clear();
|
_triedSpecialEndpoints.clear();
|
||||||
_specialLoader = std::make_unique<SpecialConfigRequest>([=](
|
_specialLoader = std::make_unique<SpecialConfigRequest>([=](
|
||||||
DcId dcId,
|
DcId dcId,
|
||||||
|
@ -147,7 +148,7 @@ void ConfigLoader::createSpecialLoader() {
|
||||||
} else {
|
} else {
|
||||||
addSpecialEndpoint(dcId, ip, port, secret);
|
addSpecialEndpoint(dcId, ip, port, secret);
|
||||||
}
|
}
|
||||||
}, _instance->configValues().txtDomainString, _phone);
|
}, testMode, _instance->configValues().txtDomainString, _phone);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigLoader::addSpecialEndpoint(
|
void ConfigLoader::addSpecialEndpoint(
|
||||||
|
|
|
@ -542,7 +542,7 @@ void Instance::Private::syncHttpUnixtime() {
|
||||||
InvokeQueued(_instance, [=] {
|
InvokeQueued(_instance, [=] {
|
||||||
_httpUnixtimeLoader = nullptr;
|
_httpUnixtimeLoader = nullptr;
|
||||||
});
|
});
|
||||||
}, configValues().txtDomainString);
|
}, isTestMode(), configValues().txtDomainString);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instance::Private::restartedByTimeout(ShiftedDcId shiftedDcId) {
|
void Instance::Private::restartedByTimeout(ShiftedDcId shiftedDcId) {
|
||||||
|
|
|
@ -188,6 +188,7 @@ SpecialConfigRequest::SpecialConfigRequest(
|
||||||
int port,
|
int port,
|
||||||
bytes::const_span secret)> callback,
|
bytes::const_span secret)> callback,
|
||||||
Fn<void()> timeDoneCallback,
|
Fn<void()> timeDoneCallback,
|
||||||
|
bool isTestMode,
|
||||||
const QString &domainString,
|
const QString &domainString,
|
||||||
const QString &phone)
|
const QString &phone)
|
||||||
: _callback(std::move(callback))
|
: _callback(std::move(callback))
|
||||||
|
@ -219,14 +220,9 @@ SpecialConfigRequest::SpecialConfigRequest(
|
||||||
|
|
||||||
_attempts = {};
|
_attempts = {};
|
||||||
_attempts.push_back({ Type::Google, "dns.google.com" });
|
_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::Mozilla, "mozilla.cloudflare-dns.com" });
|
||||||
_attempts.push_back({ Type::RemoteConfig, "firebaseremoteconfig" });
|
_attempts.push_back({ Type::RemoteConfig, "firebaseremoteconfig" });
|
||||||
while (!domains.empty()) {
|
|
||||||
_attempts.push_back({ Type::Google, takeDomain(), "dns" });
|
|
||||||
}
|
|
||||||
if (!_timeDoneCallback) {
|
if (!_timeDoneCallback) {
|
||||||
_attempts.push_back({ Type::Realtime, "firebaseio.com" });
|
|
||||||
_attempts.push_back({ Type::FireStore, "firestore" });
|
_attempts.push_back({ Type::FireStore, "firestore" });
|
||||||
for (const auto &domain : DnsDomains()) {
|
for (const auto &domain : DnsDomains()) {
|
||||||
_attempts.push_back({ Type::FireStore, domain, "firestore" });
|
_attempts.push_back({ Type::FireStore, domain, "firestore" });
|
||||||
|
@ -234,12 +230,15 @@ SpecialConfigRequest::SpecialConfigRequest(
|
||||||
}
|
}
|
||||||
|
|
||||||
shuffle(0, 2);
|
shuffle(0, 2);
|
||||||
shuffle(2, 4);
|
|
||||||
if (!_timeDoneCallback) {
|
if (!_timeDoneCallback) {
|
||||||
shuffle(
|
shuffle(_attempts.size() - (domainsCount + 1), _attempts.size());
|
||||||
_attempts.size() - (2 + domainsCount),
|
}
|
||||||
_attempts.size() - domainsCount);
|
if (isTestMode) {
|
||||||
shuffle(_attempts.size() - domainsCount, _attempts.size());
|
_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.
|
ranges::reverse(_attempts); // We go from last to first.
|
||||||
|
|
||||||
|
@ -252,17 +251,25 @@ SpecialConfigRequest::SpecialConfigRequest(
|
||||||
const std::string &ip,
|
const std::string &ip,
|
||||||
int port,
|
int port,
|
||||||
bytes::const_span secret)> callback,
|
bytes::const_span secret)> callback,
|
||||||
|
bool isTestMode,
|
||||||
const QString &domainString,
|
const QString &domainString,
|
||||||
const QString &phone)
|
const QString &phone)
|
||||||
: SpecialConfigRequest(std::move(callback), nullptr, domainString, phone) {
|
: SpecialConfigRequest(
|
||||||
|
std::move(callback),
|
||||||
|
nullptr,
|
||||||
|
isTestMode,
|
||||||
|
domainString,
|
||||||
|
phone) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SpecialConfigRequest::SpecialConfigRequest(
|
SpecialConfigRequest::SpecialConfigRequest(
|
||||||
Fn<void()> timeDoneCallback,
|
Fn<void()> timeDoneCallback,
|
||||||
|
bool isTestMode,
|
||||||
const QString &domainString)
|
const QString &domainString)
|
||||||
: SpecialConfigRequest(
|
: SpecialConfigRequest(
|
||||||
nullptr,
|
nullptr,
|
||||||
std::move(timeDoneCallback),
|
std::move(timeDoneCallback),
|
||||||
|
isTestMode,
|
||||||
domainString,
|
domainString,
|
||||||
QString()) {
|
QString()) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,12 @@ public:
|
||||||
const std::string &ip,
|
const std::string &ip,
|
||||||
int port,
|
int port,
|
||||||
bytes::const_span secret)> callback,
|
bytes::const_span secret)> callback,
|
||||||
|
bool isTestMode,
|
||||||
const QString &domainString,
|
const QString &domainString,
|
||||||
const QString &phone);
|
const QString &phone);
|
||||||
SpecialConfigRequest(
|
SpecialConfigRequest(
|
||||||
Fn<void()> timeDoneCallback,
|
Fn<void()> timeDoneCallback,
|
||||||
|
bool isTestMode,
|
||||||
const QString &domainString);
|
const QString &domainString);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -52,6 +54,7 @@ private:
|
||||||
int port,
|
int port,
|
||||||
bytes::const_span secret)> callback,
|
bytes::const_span secret)> callback,
|
||||||
Fn<void()> timeDoneCallback,
|
Fn<void()> timeDoneCallback,
|
||||||
|
bool isTestMode,
|
||||||
const QString &domainString,
|
const QString &domainString,
|
||||||
const QString &phone);
|
const QString &phone);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue