From 436e1de82046188344ce73d8209941ca2569db2e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 16 Oct 2020 12:36:03 +0200 Subject: [PATCH 1/3] [libcalamares] Be more chatty in GeoIP test application --- src/libcalamares/geoip/test_geoip.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libcalamares/geoip/test_geoip.cpp b/src/libcalamares/geoip/test_geoip.cpp index 0c475b9c0..fd50cecff 100644 --- a/src/libcalamares/geoip/test_geoip.cpp +++ b/src/libcalamares/geoip/test_geoip.cpp @@ -11,7 +11,6 @@ * This is a test-application that does one GeoIP parse. */ -#include #include "GeoIPFixed.h" #include "GeoIPJSON.h" @@ -19,6 +18,10 @@ #include "GeoIPXML.h" #endif +#include "utils/Logger.h" + +#include + using std::cerr; using namespace CalamaresUtils::GeoIP; @@ -34,6 +37,9 @@ main( int argc, char** argv ) QString format( argv[ 1 ] ); QString selector = argc == 3 ? QString( argv[ 2 ] ) : QString(); + Logger::setupLogLevel(Logger::LOGVERBOSE); + cDebug() << "Doing GeoIP interpretation with format=" << format << "selector=" << selector; + Interface* handler = nullptr; if ( QStringLiteral( "json" ) == format ) { From 3b14e354b0a7c5379bafd446a0c5e558f68c7ca3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 16 Oct 2020 13:07:57 +0200 Subject: [PATCH 2/3] [libcalamares] Log more HTTP errors during requests --- src/libcalamares/network/Manager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libcalamares/network/Manager.cpp b/src/libcalamares/network/Manager.cpp index 57faae28c..d089551bb 100644 --- a/src/libcalamares/network/Manager.cpp +++ b/src/libcalamares/network/Manager.cpp @@ -223,6 +223,7 @@ synchronousRun( QNetworkAccessManager* nam, const QUrl& url, const RequestOption auto* reply = asynchronousRun( nam, url, options ); if ( !reply ) { + cDebug() << "Could not create request for" << url; return qMakePair( RequestStatus( RequestStatus::Failed ), nullptr ); } @@ -232,10 +233,12 @@ synchronousRun( QNetworkAccessManager* nam, const QUrl& url, const RequestOption reply->deleteLater(); if ( reply->isRunning() ) { + cDebug() << "Timeout on request for" << url; return qMakePair( RequestStatus( RequestStatus::Timeout ), nullptr ); } else if ( reply->error() != QNetworkReply::NoError ) { + cDebug() << "HTTP error" << reply->error() << "on request for" << url; return qMakePair( RequestStatus( RequestStatus::HttpError ), nullptr ); } else From 81f12cb23028d82d9253390b43c3d02c639c1cd4 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 16 Oct 2020 13:54:29 +0200 Subject: [PATCH 3/3] [libcalamares] Do GeoIP lookups with a fake User-Agent --- src/libcalamares/geoip/Handler.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libcalamares/geoip/Handler.cpp b/src/libcalamares/geoip/Handler.cpp index d954b8fc0..648ea69f4 100644 --- a/src/libcalamares/geoip/Handler.cpp +++ b/src/libcalamares/geoip/Handler.cpp @@ -113,7 +113,9 @@ do_query( Handler::Type type, const QString& url, const QString& selector ) return RegionZonePair(); } - return interface->processReply( CalamaresUtils::Network::Manager::instance().synchronousGet( url ) ); + using namespace CalamaresUtils::Network; + return interface->processReply( + CalamaresUtils::Network::Manager::instance().synchronousGet( url, { RequestOptions::FakeUserAgent } ) ); } static QString @@ -125,7 +127,9 @@ do_raw_query( Handler::Type type, const QString& url, const QString& selector ) return QString(); } - return interface->rawReply( CalamaresUtils::Network::Manager::instance().synchronousGet( url ) ); + using namespace CalamaresUtils::Network; + return interface->rawReply( + CalamaresUtils::Network::Manager::instance().synchronousGet( url, { RequestOptions::FakeUserAgent } ) ); } RegionZonePair