mirror of https://github.com/procxx/kepka.git
Optimize unixtime refresh.
This commit is contained in:
parent
9bf8b619fe
commit
2cb7d76417
|
@ -129,7 +129,11 @@ void ConfigLoader::createSpecialLoader() {
|
||||||
const std::string &ip,
|
const std::string &ip,
|
||||||
int port,
|
int port,
|
||||||
bytes::const_span secret) {
|
bytes::const_span secret) {
|
||||||
addSpecialEndpoint(dcId, ip, port, secret);
|
if (ip.empty()) {
|
||||||
|
_specialLoader = nullptr;
|
||||||
|
} else {
|
||||||
|
addSpecialEndpoint(dcId, ip, port, secret);
|
||||||
|
}
|
||||||
}, _phone);
|
}, _phone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -374,19 +374,22 @@ SpecialConfigRequest::SpecialConfigRequest(
|
||||||
while (!domains.empty()) {
|
while (!domains.empty()) {
|
||||||
_attempts.push_back({ Type::Google, takeDomain(), "dns" });
|
_attempts.push_back({ Type::Google, takeDomain(), "dns" });
|
||||||
}
|
}
|
||||||
_attempts.push_back({ Type::Realtime, "firebaseio.com" });
|
if (!_timeDoneCallback) {
|
||||||
_attempts.push_back({ Type::FireStore, "firestore" });
|
_attempts.push_back({ Type::Realtime, "firebaseio.com" });
|
||||||
for (const auto &domain : DnsDomains()) {
|
_attempts.push_back({ Type::FireStore, "firestore" });
|
||||||
_attempts.push_back({ Type::FireStore, domain, "firestore" });
|
for (const auto &domain : DnsDomains()) {
|
||||||
|
_attempts.push_back({ Type::FireStore, domain, "firestore" });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shuffle(0, 2);
|
shuffle(0, 2);
|
||||||
shuffle(2, 4);
|
shuffle(2, 4);
|
||||||
shuffle(
|
if (!_timeDoneCallback) {
|
||||||
_attempts.size() - (2 + domainsCount),
|
shuffle(
|
||||||
_attempts.size() - domainsCount);
|
_attempts.size() - (2 + domainsCount),
|
||||||
shuffle(_attempts.size() - domainsCount, _attempts.size());
|
_attempts.size() - domainsCount);
|
||||||
|
shuffle(_attempts.size() - domainsCount, _attempts.size());
|
||||||
|
}
|
||||||
ranges::reverse(_attempts); // We go from last to first.
|
ranges::reverse(_attempts); // We go from last to first.
|
||||||
|
|
||||||
sendNextRequest();
|
sendNextRequest();
|
||||||
|
@ -666,20 +669,27 @@ void SpecialConfigRequest::handleResponse(const QByteArray &bytes) {
|
||||||
switch (address.type()) {
|
switch (address.type()) {
|
||||||
case mtpc_ipPort: {
|
case mtpc_ipPort: {
|
||||||
const auto &fields = address.c_ipPort();
|
const auto &fields = address.c_ipPort();
|
||||||
_callback(dcId, parseIp(fields.vipv4()), fields.vport().v, {});
|
const auto ip = parseIp(fields.vipv4());
|
||||||
|
if (!ip.empty()) {
|
||||||
|
_callback(dcId, ip, fields.vport().v, {});
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
case mtpc_ipPortSecret: {
|
case mtpc_ipPortSecret: {
|
||||||
const auto &fields = address.c_ipPortSecret();
|
const auto &fields = address.c_ipPortSecret();
|
||||||
_callback(
|
const auto ip = parseIp(fields.vipv4());
|
||||||
dcId,
|
if (!ip.empty()) {
|
||||||
parseIp(fields.vipv4()),
|
_callback(
|
||||||
fields.vport().v,
|
dcId,
|
||||||
bytes::make_span(fields.vsecret().v));
|
ip,
|
||||||
|
fields.vport().v,
|
||||||
|
bytes::make_span(fields.vsecret().v));
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
default: Unexpected("Type in simpleConfig ips.");
|
default: Unexpected("Type in simpleConfig ips.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_callback(0, std::string(), 0, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
DomainResolver::DomainResolver(Fn<void(
|
DomainResolver::DomainResolver(Fn<void(
|
||||||
|
|
Loading…
Reference in New Issue