1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-10 23:07:59 +00:00

Clean up code

This commit is contained in:
Chocobo1 2022-05-15 15:38:41 +08:00
parent 538c88ced4
commit e82c50ed73
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C

View File

@ -87,11 +87,11 @@ namespace Utils
protocolEquivalentAddress = QHostAddress(addr.toIPv4Address(&addrConversionOk)); protocolEquivalentAddress = QHostAddress(addr.toIPv4Address(&addrConversionOk));
} }
for (const Subnet &subnet : subnets) return std::any_of(subnets.begin(), subnets.end(), [&](const Subnet &subnet)
if (addr.isInSubnet(subnet) || (addrConversionOk && protocolEquivalentAddress.isInSubnet(subnet))) {
return true; return addr.isInSubnet(subnet)
|| (addrConversionOk && protocolEquivalentAddress.isInSubnet(subnet));
return false; });
} }
QString subnetToString(const Subnet &subnet) QString subnetToString(const Subnet &subnet)
@ -133,9 +133,11 @@ namespace Utils
QList<QSslCertificate> loadSSLCertificate(const QByteArray &data) QList<QSslCertificate> loadSSLCertificate(const QByteArray &data)
{ {
const QList<QSslCertificate> certs {QSslCertificate::fromData(data)}; const QList<QSslCertificate> certs {QSslCertificate::fromData(data)};
if (std::any_of(certs.cbegin(), certs.cend(), [](const QSslCertificate &c) { return c.isNull(); })) const bool hasInvalidCerts = std::any_of(certs.cbegin(), certs.cend(), [](const QSslCertificate &cert)
return {}; {
return certs; return cert.isNull();
});
return hasInvalidCerts ? QList<QSslCertificate>() : certs;
} }
bool isSSLCertificatesValid(const QByteArray &data) bool isSSLCertificatesValid(const QByteArray &data)
@ -146,7 +148,7 @@ namespace Utils
QSslKey loadSSLKey(const QByteArray &data) QSslKey loadSSLKey(const QByteArray &data)
{ {
// try different formats // try different formats
QSslKey key {data, QSsl::Rsa}; const QSslKey key {data, QSsl::Rsa};
if (!key.isNull()) if (!key.isNull())
return key; return key;
return {data, QSsl::Ec}; return {data, QSsl::Ec};