
* 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>
67 lines
2 KiB
C++
67 lines
2 KiB
C++
/* 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/. */
|
|
|
|
#ifndef MACOSROUTEMONITOR_H
|
|
#define MACOSROUTEMONITOR_H
|
|
|
|
#include <QByteArray>
|
|
#include <QHostAddress>
|
|
#include <QList>
|
|
#include <QObject>
|
|
#include <QSocketNotifier>
|
|
|
|
#include "ipaddress.h"
|
|
|
|
struct if_msghdr;
|
|
struct rt_msghdr;
|
|
struct sockaddr;
|
|
|
|
class MacosRouteMonitor final : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
MacosRouteMonitor(const QString& ifname, QObject* parent = nullptr);
|
|
~MacosRouteMonitor();
|
|
|
|
bool insertRoute(const IPAddress& prefix, int flags = 0);
|
|
bool deleteRoute(const IPAddress& prefix, int flags = 0);
|
|
int interfaceFlags() { return m_ifflags; }
|
|
|
|
bool addExclusionRoute(const IPAddress& prefix);
|
|
bool deleteExclusionRoute(const IPAddress& prefix);
|
|
void flushExclusionRoutes();
|
|
|
|
private:
|
|
void handleRtmDelete(const struct rt_msghdr* msg, const QByteArray& payload);
|
|
void handleRtmUpdate(const struct rt_msghdr* msg, const QByteArray& payload);
|
|
void handleIfaceInfo(const struct if_msghdr* msg, const QByteArray& payload);
|
|
bool rtmSendRoute(int action, const IPAddress& prefix, unsigned int ifindex,
|
|
const void* gateway, int flags = 0);
|
|
bool rtmFetchRoutes(int family);
|
|
static void rtmAppendAddr(struct rt_msghdr* rtm, size_t maxlen, int rtaddr,
|
|
const void* sa);
|
|
static QList<QByteArray> parseAddrList(const QByteArray& data);
|
|
|
|
private slots:
|
|
void rtsockReady();
|
|
|
|
private:
|
|
static QString addrToString(const struct sockaddr* sa);
|
|
static QString addrToString(const QByteArray& data);
|
|
|
|
QList<IPAddress> m_exclusionRoutes;
|
|
QByteArray m_defaultGatewayIpv4;
|
|
QByteArray m_defaultGatewayIpv6;
|
|
unsigned int m_defaultIfindexIpv4 = 0;
|
|
unsigned int m_defaultIfindexIpv6 = 0;
|
|
|
|
QString m_ifname;
|
|
unsigned int m_ifindex = 0;
|
|
int m_ifflags = 0;
|
|
int m_rtsock = -1;
|
|
int m_rtseq = 0;
|
|
QSocketNotifier* m_notifier = nullptr;
|
|
};
|
|
|
|
#endif // MACOSROUTEMONITOR_H
|