feature/mozilla upstream (#1237)
* cherry-pick 4dfcad96506fb5b88c5bb27342b6d9413fc361c9 from mozilla upstream * cherry-pick a95fa8c088b9edaff2de18751336942c2d145a9a from mozilla * cherry-pick commit 4fc1ebbad86a9abcafdc761725a7afd811c8d2d3 from mozilla * cherry-pick 4dfcad96506fb5b88c5bb27342b6d9413fc361c9 from mozilla upstream * cherry-pick 22de4fcbd454c64ff496c3380eeaeeb6afff4d64 from mozilla upstream * cherry-pick 649673be561b66c96367adf379da1545f8838763 from mozilla upstream * cherry-pick 41bdad34517d0ddaef32139482e5505d92e4b533 from mozilla upstream * cherry-pick f6e49a85538eaa230d3a8634fa7600966132ccab from mozilla upstream * cherry-pick 86c585387efa0a09c7937dfe799a90a666404fcd from mozilla upstream * cherry-pick a18c1fac740469ca3566751b74a16227518630c4 from mozilla upstream * fixed missing ; * added excludeLocalNetworks() for linux * build fixes on windows after cherry-picks * Add rules for excluded sites splittunell mode * Fix app splittunell when ipv6 is not setup * Fix Linux build --------- Co-authored-by: Mykola Baibuz <mykola.baibuz@gmail.com>
This commit is contained in:
parent
f1c6067485
commit
8ca31e0c90
27 changed files with 1119 additions and 607 deletions
|
|
@ -114,12 +114,23 @@ bool Daemon::activate(const InterfaceConfig& config) {
|
|||
|
||||
// Bring up the wireguard interface if not already done.
|
||||
if (!wgutils()->interfaceExists()) {
|
||||
// Create the interface.
|
||||
if (!wgutils()->addInterface(config)) {
|
||||
logger.error() << "Interface creation failed.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Bring the interface up.
|
||||
if (supportIPUtils()) {
|
||||
if (!iputils()->addInterfaceIPs(config)) {
|
||||
return false;
|
||||
}
|
||||
if (!iputils()->setMTUAndUp(config)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Configure routing for excluded addresses.
|
||||
for (const QString& i : config.m_excludedAddresses) {
|
||||
addExclusionRoute(IPAddress(i));
|
||||
|
|
@ -135,15 +146,6 @@ bool Daemon::activate(const InterfaceConfig& config) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (supportIPUtils()) {
|
||||
if (!iputils()->addInterfaceIPs(config)) {
|
||||
return false;
|
||||
}
|
||||
if (!iputils()->setMTUAndUp(config)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// set routing
|
||||
for (const IPAddress& ip : config.m_allowedIPAddressRanges) {
|
||||
if (!wgutils()->updateRoutePrefix(ip)) {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
#include <QDateTime>
|
||||
#include <QTimer>
|
||||
|
||||
#include "daemon/daemonerrors.h"
|
||||
#include "daemonerrors.h"
|
||||
#include "dnsutils.h"
|
||||
#include "interfaceconfig.h"
|
||||
#include "iputils.h"
|
||||
|
|
@ -51,7 +53,7 @@ class Daemon : public QObject {
|
|||
*/
|
||||
void activationFailure();
|
||||
void disconnected();
|
||||
void backendFailure();
|
||||
void backendFailure(DaemonError reason = DaemonError::ERROR_FATAL);
|
||||
|
||||
private:
|
||||
bool maybeUpdateResolvers(const InterfaceConfig& config);
|
||||
|
|
|
|||
17
client/daemon/daemonerrors.h
Normal file
17
client/daemon/daemonerrors.h
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
enum class DaemonError : uint8_t {
|
||||
ERROR_NONE = 0u,
|
||||
ERROR_FATAL = 1u,
|
||||
ERROR_SPLIT_TUNNEL_INIT_FAILURE = 2u,
|
||||
ERROR_SPLIT_TUNNEL_START_FAILURE = 3u,
|
||||
ERROR_SPLIT_TUNNEL_EXCLUDE_FAILURE = 4u,
|
||||
|
||||
DAEMON_ERROR_MAX = 5u,
|
||||
};
|
||||
|
|
@ -159,9 +159,10 @@ void DaemonLocalServerConnection::disconnected() {
|
|||
write(obj);
|
||||
}
|
||||
|
||||
void DaemonLocalServerConnection::backendFailure() {
|
||||
void DaemonLocalServerConnection::backendFailure(DaemonError err) {
|
||||
QJsonObject obj;
|
||||
obj.insert("type", "backendFailure");
|
||||
obj.insert("errorCode", static_cast<int>(err));
|
||||
write(obj);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
#include "daemonerrors.h"
|
||||
|
||||
class QLocalSocket;
|
||||
|
||||
class DaemonLocalServerConnection final : public QObject {
|
||||
|
|
@ -23,7 +25,7 @@ class DaemonLocalServerConnection final : public QObject {
|
|||
|
||||
void connected(const QString& pubkey);
|
||||
void disconnected();
|
||||
void backendFailure();
|
||||
void backendFailure(DaemonError err);
|
||||
|
||||
void write(const QJsonObject& obj);
|
||||
|
||||
|
|
|
|||
|
|
@ -45,9 +45,11 @@ class WireguardUtils : public QObject {
|
|||
|
||||
virtual bool updateRoutePrefix(const IPAddress& prefix) = 0;
|
||||
virtual bool deleteRoutePrefix(const IPAddress& prefix) = 0;
|
||||
|
||||
|
||||
virtual bool addExclusionRoute(const IPAddress& prefix) = 0;
|
||||
virtual bool deleteExclusionRoute(const IPAddress& prefix) = 0;
|
||||
|
||||
virtual bool excludeLocalNetworks(const QList<IPAddress>& addresses) = 0;
|
||||
};
|
||||
|
||||
#endif // WIREGUARDUTILS_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue