mirror of
https://github.com/wownero/wowlet.git
synced 2026-12-03 05:26:22 +01:00
Tor: update to 0.4.5.5-rc, build fixes
This commit is contained in:
+30
-9
@@ -4,9 +4,11 @@
|
||||
#include <QScreen>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDesktopServices>
|
||||
#include <QRegularExpression>
|
||||
#include "utils/utils.h"
|
||||
#include "utils/tor.h"
|
||||
#include "appcontext.h"
|
||||
#include "config-feather.h"
|
||||
|
||||
QString Tor::torHost = "127.0.0.1";
|
||||
quint16 Tor::torPort = 9050;
|
||||
@@ -200,10 +202,19 @@ bool Tor::unpackBins() {
|
||||
QFile f(torFile);
|
||||
QFileInfo fileInfo(f);
|
||||
this->torPath = QDir(this->torDir).filePath(fileInfo.fileName());
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
if(!this->torPath.endsWith(".exe"))
|
||||
this->torPath += ".exe";
|
||||
#endif
|
||||
|
||||
TorVersion embeddedVersion = this->stringToVersion(QString(TOR_VERSION));
|
||||
TorVersion filesystemVersion = this->getVersion(torPath);
|
||||
qDebug() << QString("Tor versions: embedded %1, filesystem %2").arg(embeddedVersion.toString(), filesystemVersion.toString());
|
||||
if (embeddedVersion > filesystemVersion) {
|
||||
QFile::remove(torPath);
|
||||
}
|
||||
|
||||
qDebug() << "Writing Tor executable to " << this->torPath;
|
||||
f.copy(torPath);
|
||||
f.close();
|
||||
@@ -215,7 +226,7 @@ bool Tor::unpackBins() {
|
||||
return true;
|
||||
}
|
||||
|
||||
QString Tor::getVersion() {
|
||||
TorVersion Tor::getVersion(const QString &fileName) {
|
||||
QProcess process;
|
||||
process.setProcessChannelMode(QProcess::MergedChannels);
|
||||
process.start(this->torPath, QStringList() << "--version");
|
||||
@@ -224,13 +235,23 @@ QString Tor::getVersion() {
|
||||
|
||||
if(output.isEmpty()) {
|
||||
qWarning() << "Could not grab Tor version";
|
||||
return "";
|
||||
}
|
||||
QString version = output.split('\n').at(0);
|
||||
if(version.startsWith("Tor version")){
|
||||
return version;
|
||||
} else {
|
||||
qWarning() << "Could not parse Tor version";
|
||||
return "";
|
||||
return TorVersion();
|
||||
}
|
||||
|
||||
return this->stringToVersion(output);
|
||||
}
|
||||
|
||||
TorVersion Tor::stringToVersion(const QString &version) {
|
||||
QRegularExpression re("(?<major>\\d)\\.(?<minor>\\d)\\.(?<patch>\\d)\\.(?<release>\\d)");
|
||||
QRegularExpressionMatch match = re.match(version);
|
||||
|
||||
if (!match.hasMatch()) {
|
||||
qWarning() << "Could not parse Tor version";
|
||||
return TorVersion();
|
||||
}
|
||||
|
||||
return TorVersion(match.captured("major").toInt(),
|
||||
match.captured("minor").toInt(),
|
||||
match.captured("patch").toInt(),
|
||||
match.captured("release").toInt());
|
||||
}
|
||||
+51
-1
@@ -11,6 +11,55 @@
|
||||
#include <QtNetwork>
|
||||
#include "utils/childproc.h"
|
||||
|
||||
struct TorVersion
|
||||
{
|
||||
explicit TorVersion(int major=0, int minor=0, int patch=0, int release=0)
|
||||
: patch(patch), release(release)
|
||||
{
|
||||
this->major = major;
|
||||
this->minor = minor;
|
||||
}
|
||||
|
||||
friend bool operator== (const TorVersion &v1, const TorVersion &v2) {
|
||||
return (v1.major == v2.major &&
|
||||
v1.minor == v2.minor &&
|
||||
v1.patch == v2.patch &&
|
||||
v1.release == v2.release);
|
||||
}
|
||||
|
||||
friend bool operator!= (const TorVersion &v1, const TorVersion &v2) {
|
||||
return !(v1 == v2);
|
||||
}
|
||||
|
||||
friend bool operator> (const TorVersion &v1, const TorVersion &v2) {
|
||||
if (v1.major != v2.major)
|
||||
return v1.major > v2.major;
|
||||
if (v1.minor != v2.minor)
|
||||
return v1.minor > v2.minor;
|
||||
if (v1.patch != v2.patch)
|
||||
return v1.patch > v2.patch;
|
||||
if (v1.release != v2.release)
|
||||
return v1.release > v2.release;
|
||||
return false;
|
||||
}
|
||||
|
||||
friend bool operator< (const TorVersion &v1, const TorVersion &v2) {
|
||||
if (v1 == v2)
|
||||
return false;
|
||||
return !(v1 > v2);
|
||||
}
|
||||
|
||||
QString toString() {
|
||||
return QString("%1.%2.%3.%4").arg(QString::number(major), QString::number(minor),
|
||||
QString::number(patch), QString::number(release));
|
||||
}
|
||||
|
||||
int major;
|
||||
int minor;
|
||||
int patch;
|
||||
int release;
|
||||
};
|
||||
|
||||
class Tor : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -21,7 +70,8 @@ public:
|
||||
void start();
|
||||
void stop();
|
||||
bool unpackBins();
|
||||
QString getVersion();
|
||||
TorVersion getVersion(const QString &fileName);
|
||||
TorVersion stringToVersion(const QString &version);
|
||||
|
||||
bool torConnected = false;
|
||||
bool localTor = false;
|
||||
|
||||
Reference in New Issue
Block a user