UpdateChecker: Use MCat tool instead of NC for connectivity test, which adds IPv6 support and even is a bit faster.
This commit is contained in:
parent
62471a93e8
commit
5fe443cb1e
@ -81,7 +81,7 @@ namespace MUtils
|
|||||||
}
|
}
|
||||||
update_status_t;
|
update_status_t;
|
||||||
|
|
||||||
UpdateChecker(const QString &binWGet, const QString &binNC, const QString &binGnuPG, const QString &binKeys, const QString &applicationId, const quint32 &installedBuildNo, const bool betaUpdates, const bool testMode = false);
|
UpdateChecker(const QString &binWGet, const QString &binMCat, const QString &binGnuPG, const QString &binKeys, const QString &applicationId, const quint32 &installedBuildNo, const bool betaUpdates, const bool testMode = false);
|
||||||
~UpdateChecker(void);
|
~UpdateChecker(void);
|
||||||
|
|
||||||
const int getUpdateStatus(void) const { return m_status; }
|
const int getUpdateStatus(void) const { return m_status; }
|
||||||
@ -116,7 +116,7 @@ namespace MUtils
|
|||||||
const quint32 m_installedBuildNo;
|
const quint32 m_installedBuildNo;
|
||||||
|
|
||||||
const QString m_binaryWGet;
|
const QString m_binaryWGet;
|
||||||
const QString m_binaryNC;
|
const QString m_binaryMCat;
|
||||||
const QString m_binaryGnuPG;
|
const QString m_binaryGnuPG;
|
||||||
const QString m_binaryKeys;
|
const QString m_binaryKeys;
|
||||||
|
|
||||||
|
@ -298,11 +298,11 @@ bool UpdateCheckerInfo::isComplete(void)
|
|||||||
// Constructor & Destructor
|
// Constructor & Destructor
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
UpdateChecker::UpdateChecker(const QString &binWGet, const QString &binNC, const QString &binGnuPG, const QString &binKeys, const QString &applicationId, const quint32 &installedBuildNo, const bool betaUpdates, const bool testMode)
|
UpdateChecker::UpdateChecker(const QString &binWGet, const QString &binMCat, const QString &binGnuPG, const QString &binKeys, const QString &applicationId, const quint32 &installedBuildNo, const bool betaUpdates, const bool testMode)
|
||||||
:
|
:
|
||||||
m_updateInfo(new UpdateCheckerInfo()),
|
m_updateInfo(new UpdateCheckerInfo()),
|
||||||
m_binaryWGet(binWGet),
|
m_binaryWGet(binWGet),
|
||||||
m_binaryNC(binNC),
|
m_binaryMCat(binMCat),
|
||||||
m_binaryGnuPG(binGnuPG),
|
m_binaryGnuPG(binGnuPG),
|
||||||
m_binaryKeys(binKeys),
|
m_binaryKeys(binKeys),
|
||||||
m_applicationId(applicationId),
|
m_applicationId(applicationId),
|
||||||
@ -541,7 +541,7 @@ bool UpdateChecker::tryUpdateMirror(UpdateCheckerInfo *updateInfo, const QString
|
|||||||
log("", "Download okay, checking signature:");
|
log("", "Download okay, checking signature:");
|
||||||
if (checkSignature(outFileVers, outFileSign))
|
if (checkSignature(outFileVers, outFileSign))
|
||||||
{
|
{
|
||||||
log("", "Signature okay, parsing info:");
|
log("", "Signature okay, parsing info:", "");
|
||||||
success = parseVersionInfo(outFileVers, updateInfo);
|
success = parseVersionInfo(outFileVers, updateInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -562,19 +562,19 @@ bool UpdateChecker::tryUpdateMirror(UpdateCheckerInfo *updateInfo, const QString
|
|||||||
|
|
||||||
bool UpdateChecker::getUpdateInfo(const QString &url, const QString &outFileVers, const QString &outFileSign)
|
bool UpdateChecker::getUpdateInfo(const QString &url, const QString &outFileVers, const QString &outFileSign)
|
||||||
{
|
{
|
||||||
log("Downloading update info:");
|
log("Downloading update info:", "");
|
||||||
if(!getFile(QString("%1%2" ).arg(url, mirror_url_postfix[m_betaUpdates ? 1 : 0]), outFileVers))
|
if(getFile(QString("%1%2").arg(url, mirror_url_postfix[m_betaUpdates ? 1 : 0]), outFileVers))
|
||||||
{
|
{
|
||||||
return false;
|
if (!m_cancelled)
|
||||||
|
{
|
||||||
|
log("", "Downloading signature:", "");
|
||||||
|
if (getFile(QString("%1%2.sig2").arg(url, mirror_url_postfix[m_betaUpdates ? 1 : 0]), outFileSign))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
log("", "Downloading signature:");
|
|
||||||
if(!getFile(QString("%1%2.sig2").arg(url, mirror_url_postfix[m_betaUpdates ? 1 : 0]), outFileSign))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UpdateChecker::parseVersionInfo(const QString &file, UpdateCheckerInfo *updateInfo)
|
bool UpdateChecker::parseVersionInfo(const QString &file, UpdateCheckerInfo *updateInfo)
|
||||||
@ -692,6 +692,10 @@ bool UpdateChecker::getFile(const QString &url, const QString &outFile, const un
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (m_cancelled)
|
||||||
|
{
|
||||||
|
break; /*cancelled*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -772,13 +776,13 @@ bool UpdateChecker::getFile(const QString &url, const bool forceIp4, const QStri
|
|||||||
|
|
||||||
bool UpdateChecker::tryContactHost(const QString &hostname, const int &timeoutMsec)
|
bool UpdateChecker::tryContactHost(const QString &hostname, const int &timeoutMsec)
|
||||||
{
|
{
|
||||||
log(QString("Connecting to host: %1").arg(hostname));
|
log(QString("Connecting to host: %1").arg(hostname), "");
|
||||||
|
|
||||||
QProcess process;
|
QProcess process;
|
||||||
init_process(process, temp_folder());
|
init_process(process, temp_folder());
|
||||||
|
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << "-z" << hostname << QString::number(80);
|
args << "--retry" << QString::number(3) << hostname << QString::number(80);
|
||||||
|
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
connect(&process, SIGNAL(error(QProcess::ProcessError)), &loop, SLOT(quit()));
|
connect(&process, SIGNAL(error(QProcess::ProcessError)), &loop, SLOT(quit()));
|
||||||
@ -789,7 +793,7 @@ bool UpdateChecker::tryContactHost(const QString &hostname, const int &timeoutMs
|
|||||||
timer.setSingleShot(true);
|
timer.setSingleShot(true);
|
||||||
connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
|
connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
|
||||||
|
|
||||||
process.start(m_binaryNC, args);
|
process.start(m_binaryMCat, args);
|
||||||
|
|
||||||
if (!process.waitForStarted())
|
if (!process.waitForStarted())
|
||||||
{
|
{
|
||||||
@ -809,7 +813,7 @@ bool UpdateChecker::tryContactHost(const QString &hostname, const int &timeoutMs
|
|||||||
}
|
}
|
||||||
if (bTimeOut || m_cancelled)
|
if (bTimeOut || m_cancelled)
|
||||||
{
|
{
|
||||||
qWarning("NC process timed out <-- killing!");
|
qWarning("MCat process timed out <-- killing!");
|
||||||
process.kill();
|
process.kill();
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
log(bTimeOut ? "!!! TIMEOUT !!!" : "!!! CANCELLED !!!");
|
log(bTimeOut ? "!!! TIMEOUT !!!" : "!!! CANCELLED !!!");
|
||||||
|
Loading…
Reference in New Issue
Block a user