mirror of https://github.com/procxx/kepka.git
Fix crash in proxy list.
This commit is contained in:
parent
cabe06256b
commit
c22aeb8b40
|
@ -1049,55 +1049,51 @@ void ProxiesBoxController::refreshChecker(Item &item) {
|
||||||
const auto dcId = mtproto->mainDcId();
|
const auto dcId = mtproto->mainDcId();
|
||||||
|
|
||||||
item.state = ItemState::Checking;
|
item.state = ItemState::Checking;
|
||||||
const auto setup = [&](Checker &checker) {
|
const auto setup = [&](Checker &checker, const bytes::vector &secret) {
|
||||||
checker = MTP::internal::AbstractConnection::Create(
|
checker = MTP::internal::AbstractConnection::Create(
|
||||||
mtproto,
|
mtproto,
|
||||||
type,
|
type,
|
||||||
QThread::currentThread(),
|
QThread::currentThread(),
|
||||||
item.data.secretFromMtprotoPassword(),
|
secret,
|
||||||
item.data);
|
item.data);
|
||||||
setupChecker(item.id, checker);
|
setupChecker(item.id, checker);
|
||||||
};
|
};
|
||||||
setup(item.checker);
|
|
||||||
if (item.data.type == Type::Mtproto) {
|
if (item.data.type == Type::Mtproto) {
|
||||||
item.checkerv6 = nullptr;
|
const auto secret = item.data.secretFromMtprotoPassword();
|
||||||
|
setup(item.checker, secret);
|
||||||
item.checker->connectToServer(
|
item.checker->connectToServer(
|
||||||
item.data.host,
|
item.data.host,
|
||||||
item.data.port,
|
item.data.port,
|
||||||
item.data.secretFromMtprotoPassword(),
|
secret,
|
||||||
dcId);
|
dcId);
|
||||||
|
item.checkerv6 = nullptr;
|
||||||
} else {
|
} else {
|
||||||
const auto options = mtproto->dcOptions()->lookup(
|
const auto options = mtproto->dcOptions()->lookup(
|
||||||
dcId,
|
dcId,
|
||||||
MTP::DcType::Regular,
|
MTP::DcType::Regular,
|
||||||
true);
|
true);
|
||||||
const auto endpoint = options.data[Variants::IPv4][type];
|
const auto connect = [&](
|
||||||
const auto endpointv6 = options.data[Variants::IPv6][type];
|
Checker &checker,
|
||||||
if (endpoint.empty()) {
|
Variants::Address address) {
|
||||||
item.checker = nullptr;
|
const auto &list = options.data[address][type];
|
||||||
}
|
if (list.empty()
|
||||||
if (Global::TryIPv6() && !endpointv6.empty()) {
|
|| (address == Variants::IPv6 && !Global::TryIPv6())) {
|
||||||
setup(item.checkerv6);
|
checker = nullptr;
|
||||||
} else {
|
return;
|
||||||
item.checkerv6 = nullptr;
|
}
|
||||||
}
|
const auto &endpoint = list.front();
|
||||||
|
setup(checker, endpoint.secret);
|
||||||
|
checker->connectToServer(
|
||||||
|
QString::fromStdString(endpoint.ip),
|
||||||
|
endpoint.port,
|
||||||
|
endpoint.secret,
|
||||||
|
dcId);
|
||||||
|
};
|
||||||
|
connect(item.checker, Variants::IPv4);
|
||||||
|
connect(item.checkerv6, Variants::IPv6);
|
||||||
if (!item.checker && !item.checkerv6) {
|
if (!item.checker && !item.checkerv6) {
|
||||||
item.state = ItemState::Unavailable;
|
item.state = ItemState::Unavailable;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const auto connect = [&](
|
|
||||||
const Checker &checker,
|
|
||||||
const std::vector<MTP::DcOptions::Endpoint> &endpoints) {
|
|
||||||
if (checker) {
|
|
||||||
checker->connectToServer(
|
|
||||||
QString::fromStdString(endpoints.front().ip),
|
|
||||||
endpoints.front().port,
|
|
||||||
endpoints.front().secret,
|
|
||||||
dcId);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
connect(item.checker, endpoint);
|
|
||||||
connect(item.checkerv6, endpointv6);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue