feature: additional logs for proxy bypass
This commit is contained in:
parent
f283858490
commit
a72082ad13
2 changed files with 11 additions and 4 deletions
|
|
@ -66,6 +66,7 @@ amnezia::ErrorCode apiUtils::checkNetworkReplyErrors(const QList<QSslError> &ssl
|
||||||
return amnezia::ErrorCode::NoError;
|
return amnezia::ErrorCode::NoError;
|
||||||
} else if (reply->error() == QNetworkReply::NetworkError::OperationCanceledError
|
} else if (reply->error() == QNetworkReply::NetworkError::OperationCanceledError
|
||||||
|| reply->error() == QNetworkReply::NetworkError::TimeoutError) {
|
|| reply->error() == QNetworkReply::NetworkError::TimeoutError) {
|
||||||
|
qDebug() << reply->error();
|
||||||
return amnezia::ErrorCode::ApiConfigTimeoutError;
|
return amnezia::ErrorCode::ApiConfigTimeoutError;
|
||||||
} else {
|
} else {
|
||||||
QString err = reply->errorString();
|
QString err = reply->errorString();
|
||||||
|
|
|
||||||
|
|
@ -251,6 +251,9 @@ QStringList GatewayController::getProxyUrls()
|
||||||
}
|
}
|
||||||
return endpoints;
|
return endpoints;
|
||||||
} else {
|
} else {
|
||||||
|
apiUtils::checkNetworkReplyErrors(sslErrors, reply);
|
||||||
|
qDebug() << "go to the next storage endpoint";
|
||||||
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -261,26 +264,29 @@ bool GatewayController::shouldBypassProxy(QNetworkReply *reply, const QByteArray
|
||||||
const QByteArray &iv, const QByteArray &salt)
|
const QByteArray &iv, const QByteArray &salt)
|
||||||
{
|
{
|
||||||
if (reply->error() == QNetworkReply::NetworkError::OperationCanceledError || reply->error() == QNetworkReply::NetworkError::TimeoutError) {
|
if (reply->error() == QNetworkReply::NetworkError::OperationCanceledError || reply->error() == QNetworkReply::NetworkError::TimeoutError) {
|
||||||
qDebug() << "Timeout occurred";
|
qDebug() << "timeout occurred";
|
||||||
|
qDebug() << reply->error();
|
||||||
return true;
|
return true;
|
||||||
} else if (responseBody.contains("html")) {
|
} else if (responseBody.contains("html")) {
|
||||||
qDebug() << "The response contains an html tag";
|
qDebug() << "the response contains an html tag";
|
||||||
return true;
|
return true;
|
||||||
} else if (reply->error() == QNetworkReply::NetworkError::ContentNotFoundError) {
|
} else if (reply->error() == QNetworkReply::NetworkError::ContentNotFoundError) {
|
||||||
if (responseBody.contains(errorResponsePattern1) || responseBody.contains(errorResponsePattern2)
|
if (responseBody.contains(errorResponsePattern1) || responseBody.contains(errorResponsePattern2)
|
||||||
|| responseBody.contains(errorResponsePattern3)) {
|
|| responseBody.contains(errorResponsePattern3)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
qDebug() << reply->error();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (reply->error() != QNetworkReply::NetworkError::NoError) {
|
} else if (reply->error() != QNetworkReply::NetworkError::NoError) {
|
||||||
|
qDebug() << reply->error();
|
||||||
return true;
|
return true;
|
||||||
} else if (checkEncryption) {
|
} else if (checkEncryption) {
|
||||||
try {
|
try {
|
||||||
QSimpleCrypto::QBlockCipher blockCipher;
|
QSimpleCrypto::QBlockCipher blockCipher;
|
||||||
static_cast<void>(blockCipher.decryptAesBlockCipher(responseBody, key, iv, "", salt));
|
static_cast<void>(blockCipher.decryptAesBlockCipher(responseBody, key, iv, "", salt));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
qDebug() << "Failed to decrypt the data";
|
qDebug() << "failed to decrypt the data";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -301,7 +307,7 @@ void GatewayController::bypassProxy(const QString &endpoint, QNetworkReply *repl
|
||||||
QByteArray responseBody;
|
QByteArray responseBody;
|
||||||
|
|
||||||
for (const QString &proxyUrl : proxyUrls) {
|
for (const QString &proxyUrl : proxyUrls) {
|
||||||
qDebug() << "Go to the next endpoint";
|
qDebug() << "go to the next proxy endpoint";
|
||||||
reply->deleteLater(); // delete the previous reply
|
reply->deleteLater(); // delete the previous reply
|
||||||
reply = requestFunction(endpoint.arg(proxyUrl));
|
reply = requestFunction(endpoint.arg(proxyUrl));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue