chore/mozilla upstream (#1136)
* cherry-pick commit 5a51e292d44ec0fb07867aff0401b4c2a8fca1e8 from mozila upstream * cherry-pick commit e8ecb857dcfb804b7766a54e725b442fc6c0e661 from mozila upstream * cherry-pick commit 16269ffa600905b09678014f64951748fb0ff8ad from mozila upstream
This commit is contained in:
parent
c4f32eed31
commit
60de146f03
8 changed files with 21 additions and 29 deletions
|
@ -78,7 +78,7 @@ bool Daemon::activate(const InterfaceConfig& config) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supportDnsUtils() && !dnsutils()->restoreResolvers()) {
|
if (!dnsutils()->restoreResolvers()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,10 +165,6 @@ bool Daemon::activate(const InterfaceConfig& config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Daemon::maybeUpdateResolvers(const InterfaceConfig& config) {
|
bool Daemon::maybeUpdateResolvers(const InterfaceConfig& config) {
|
||||||
if (!supportDnsUtils()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((config.m_hopType == InterfaceConfig::MultiHopExit) ||
|
if ((config.m_hopType == InterfaceConfig::MultiHopExit) ||
|
||||||
(config.m_hopType == InterfaceConfig::SingleHop)) {
|
(config.m_hopType == InterfaceConfig::SingleHop)) {
|
||||||
QList<QHostAddress> resolvers;
|
QList<QHostAddress> resolvers;
|
||||||
|
@ -423,13 +419,8 @@ bool Daemon::deactivate(bool emitSignals) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup DNS
|
// Cleanup DNS
|
||||||
if (supportDnsUtils() && !dnsutils()->restoreResolvers()) {
|
if (!dnsutils()->restoreResolvers()) {
|
||||||
return false;
|
logger.warning() << "Failed to restore DNS resolvers.";
|
||||||
}
|
|
||||||
|
|
||||||
if (!wgutils()->interfaceExists()) {
|
|
||||||
logger.warning() << "Wireguard interface does not exist.";
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup peers and routing
|
// Cleanup peers and routing
|
||||||
|
@ -449,13 +440,9 @@ bool Daemon::deactivate(bool emitSignals) {
|
||||||
}
|
}
|
||||||
m_excludedAddrSet.clear();
|
m_excludedAddrSet.clear();
|
||||||
|
|
||||||
// Delete the interface
|
|
||||||
if (!wgutils()->deleteInterface()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_connections.clear();
|
m_connections.clear();
|
||||||
return true;
|
// Delete the interface
|
||||||
|
return wgutils()->deleteInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Daemon::logs() {
|
QString Daemon::logs() {
|
||||||
|
|
|
@ -69,7 +69,6 @@ class Daemon : public QObject {
|
||||||
virtual WireguardUtils* wgutils() const = 0;
|
virtual WireguardUtils* wgutils() const = 0;
|
||||||
virtual bool supportIPUtils() const { return false; }
|
virtual bool supportIPUtils() const { return false; }
|
||||||
virtual IPUtils* iputils() { return nullptr; }
|
virtual IPUtils* iputils() { return nullptr; }
|
||||||
virtual bool supportDnsUtils() const { return false; }
|
|
||||||
virtual DnsUtils* dnsutils() { return nullptr; }
|
virtual DnsUtils* dnsutils() { return nullptr; }
|
||||||
|
|
||||||
static bool parseStringList(const QJsonObject& obj, const QString& name,
|
static bool parseStringList(const QJsonObject& obj, const QString& name,
|
||||||
|
|
|
@ -92,6 +92,17 @@ void DaemonLocalServerConnection::parseCommand(const QByteArray& data) {
|
||||||
|
|
||||||
logger.debug() << "Command received:" << type;
|
logger.debug() << "Command received:" << type;
|
||||||
|
|
||||||
|
// It is expected that sometimes the client will request backend logs
|
||||||
|
// before the first authentication. In these cases we just return empty
|
||||||
|
// logs.
|
||||||
|
if (type == "logs") {
|
||||||
|
QJsonObject obj;
|
||||||
|
obj.insert("type", "logs");
|
||||||
|
obj.insert("logs", "");
|
||||||
|
write(obj);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (type == "activate") {
|
if (type == "activate") {
|
||||||
InterfaceConfig config;
|
InterfaceConfig config;
|
||||||
if (!Daemon::parseConfig(obj, config)) {
|
if (!Daemon::parseConfig(obj, config)) {
|
||||||
|
@ -115,8 +126,7 @@ void DaemonLocalServerConnection::parseCommand(const QByteArray& data) {
|
||||||
if (type == "status") {
|
if (type == "status") {
|
||||||
QJsonObject obj = Daemon::instance()->getStatus();
|
QJsonObject obj = Daemon::instance()->getStatus();
|
||||||
obj.insert("type", "status");
|
obj.insert("type", "status");
|
||||||
m_socket->write(QJsonDocument(obj).toJson(QJsonDocument::Compact));
|
write(obj);
|
||||||
m_socket->write("\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,8 +134,7 @@ void DaemonLocalServerConnection::parseCommand(const QByteArray& data) {
|
||||||
QJsonObject obj;
|
QJsonObject obj;
|
||||||
obj.insert("type", "logs");
|
obj.insert("type", "logs");
|
||||||
obj.insert("logs", Daemon::instance()->logs().replace("\n", "|"));
|
obj.insert("logs", Daemon::instance()->logs().replace("\n", "|"));
|
||||||
m_socket->write(QJsonDocument(obj).toJson(QJsonDocument::Compact));
|
write(obj);
|
||||||
m_socket->write("\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,8 @@ LocalSocketController::LocalSocketController() {
|
||||||
m_socket = new QLocalSocket(this);
|
m_socket = new QLocalSocket(this);
|
||||||
connect(m_socket, &QLocalSocket::connected, this,
|
connect(m_socket, &QLocalSocket::connected, this,
|
||||||
&LocalSocketController::daemonConnected);
|
&LocalSocketController::daemonConnected);
|
||||||
connect(m_socket, &QLocalSocket::disconnected, this,
|
connect(m_socket, &QLocalSocket::disconnected, this,
|
||||||
&LocalSocketController::disconnected);
|
[&] { errorOccurred(QLocalSocket::PeerClosedError); });
|
||||||
connect(m_socket, &QLocalSocket::errorOccurred, this,
|
connect(m_socket, &QLocalSocket::errorOccurred, this,
|
||||||
&LocalSocketController::errorOccurred);
|
&LocalSocketController::errorOccurred);
|
||||||
connect(m_socket, &QLocalSocket::readyRead, this,
|
connect(m_socket, &QLocalSocket::readyRead, this,
|
||||||
|
|
|
@ -22,7 +22,6 @@ class LinuxDaemon final : public Daemon {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WireguardUtils* wgutils() const override { return m_wgutils; }
|
WireguardUtils* wgutils() const override { return m_wgutils; }
|
||||||
bool supportDnsUtils() const override { return true; }
|
|
||||||
DnsUtils* dnsutils() override { return m_dnsutils; }
|
DnsUtils* dnsutils() override { return m_dnsutils; }
|
||||||
bool supportIPUtils() const override { return true; }
|
bool supportIPUtils() const override { return true; }
|
||||||
IPUtils* iputils() override { return m_iputils; }
|
IPUtils* iputils() override { return m_iputils; }
|
||||||
|
|
|
@ -21,7 +21,6 @@ class MacOSDaemon final : public Daemon {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WireguardUtils* wgutils() const override { return m_wgutils; }
|
WireguardUtils* wgutils() const override { return m_wgutils; }
|
||||||
bool supportDnsUtils() const override { return true; }
|
|
||||||
DnsUtils* dnsutils() override { return m_dnsutils; }
|
DnsUtils* dnsutils() override { return m_dnsutils; }
|
||||||
bool supportIPUtils() const override { return true; }
|
bool supportIPUtils() const override { return true; }
|
||||||
IPUtils* iputils() override { return m_iputils; }
|
IPUtils* iputils() override { return m_iputils; }
|
||||||
|
|
|
@ -26,7 +26,6 @@ class WindowsDaemon final : public Daemon {
|
||||||
protected:
|
protected:
|
||||||
bool run(Op op, const InterfaceConfig& config) override;
|
bool run(Op op, const InterfaceConfig& config) override;
|
||||||
WireguardUtils* wgutils() const override { return m_wgutils; }
|
WireguardUtils* wgutils() const override { return m_wgutils; }
|
||||||
bool supportDnsUtils() const override { return true; }
|
|
||||||
DnsUtils* dnsutils() override { return m_dnsutils; }
|
DnsUtils* dnsutils() override { return m_dnsutils; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -502,7 +502,7 @@ QString WindowsSplitTunnel::convertPath(const QString& path) {
|
||||||
// device should contain : for e.g C:
|
// device should contain : for e.g C:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
QByteArray buffer(2048, 0xFF);
|
QByteArray buffer(2048, 0xFFu);
|
||||||
auto ok = QueryDosDeviceW(qUtf16Printable(driveLetter),
|
auto ok = QueryDosDeviceW(qUtf16Printable(driveLetter),
|
||||||
(wchar_t*)buffer.data(), buffer.size() / 2);
|
(wchar_t*)buffer.data(), buffer.size() / 2);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue