refactoring: moved gateway interaction functions to a separate class

This commit is contained in:
vladimir.kuznetsov 2025-01-31 14:33:12 +07:00
parent 7c8ae9c311
commit 3f55f6a629
6 changed files with 369 additions and 261 deletions

View file

@ -107,6 +107,26 @@ QStringList NetworkUtilities::summarizeRoutes(const QStringList &ips, const QStr
return QStringList();
}
amnezia::ErrorCode NetworkUtilities::checkNetworkReplyErrors(const QList<QSslError> &sslErrors, QNetworkReply *reply)
{
if (!sslErrors.empty()) {
qDebug().noquote() << sslErrors;
return amnezia::ErrorCode::ApiConfigSslError;
} else if (reply->error() == QNetworkReply::NoError) {
return amnezia::ErrorCode::NoError;
} else if (reply->error() == QNetworkReply::NetworkError::OperationCanceledError
|| reply->error() == QNetworkReply::NetworkError::TimeoutError) {
return amnezia::ErrorCode::ApiConfigTimeoutError;
} else {
QString err = reply->errorString();
qDebug() << QString::fromUtf8(reply->readAll());
qDebug() << reply->error();
qDebug() << err;
qDebug() << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
return amnezia::ErrorCode::ApiConfigDownloadError;
}
}
QString NetworkUtilities::getIPAddress(const QString &host)
{
QHostAddress address(host);