2021-02-21 09:44:53 -08:00
|
|
|
#ifndef ROUTERMAC_H
|
|
|
|
|
#define ROUTERMAC_H
|
|
|
|
|
|
|
|
|
|
#include <QTimer>
|
|
|
|
|
#include <QString>
|
|
|
|
|
#include <QSettings>
|
|
|
|
|
#include <QHash>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
2024-03-27 11:02:34 +00:00
|
|
|
#include "../client/platforms/macos/daemon/dnsutilsmacos.h"
|
2021-02-21 09:44:53 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief The Router class - General class for handling ip routing
|
|
|
|
|
*/
|
|
|
|
|
class RouterMac : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
static RouterMac& Instance();
|
|
|
|
|
|
2023-08-08 16:41:00 -07:00
|
|
|
struct Route {
|
|
|
|
|
QString dst;
|
|
|
|
|
QString gw;
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-27 22:18:36 +03:00
|
|
|
bool routeAdd(const QString &ip, const QString &gw);
|
2021-02-21 09:44:53 -08:00
|
|
|
int routeAddList(const QString &gw, const QStringList &ips);
|
|
|
|
|
bool clearSavedRoutes();
|
2021-06-01 08:45:26 -07:00
|
|
|
bool routeDelete(const QString &ip, const QString &gw);
|
2021-06-01 18:18:09 +03:00
|
|
|
bool routeDeleteList(const QString &gw, const QStringList &ips);
|
2025-11-30 18:49:16 -08:00
|
|
|
bool flushDns();
|
2024-03-27 11:02:34 +00:00
|
|
|
bool createTun(const QString &dev, const QString &subnet);
|
|
|
|
|
bool deleteTun(const QString &dev);
|
|
|
|
|
bool updateResolvers(const QString& ifname, const QList<QHostAddress>& resolvers);
|
2025-10-02 14:58:53 +02:00
|
|
|
bool restoreResolvers();
|
2026-05-04 15:39:07 +04:00
|
|
|
bool routeAddXray(const QString& ifname, const QString& gateway);
|
|
|
|
|
bool routeDeleteXray(const QString& ifname, const QString& gateway);
|
2024-03-27 11:02:34 +00:00
|
|
|
|
2021-02-21 09:44:53 -08:00
|
|
|
public slots:
|
|
|
|
|
|
|
|
|
|
private:
|
2024-03-27 11:02:34 +00:00
|
|
|
RouterMac() {m_dnsUtil = new DnsUtilsMacos(this);}
|
2021-02-21 09:44:53 -08:00
|
|
|
RouterMac(RouterMac const &) = delete;
|
|
|
|
|
RouterMac& operator= (RouterMac const&) = delete;
|
|
|
|
|
|
2023-08-08 16:41:00 -07:00
|
|
|
QList<Route> m_addedRoutes;
|
2024-03-27 11:02:34 +00:00
|
|
|
DnsUtilsMacos *m_dnsUtil;
|
2021-02-21 09:44:53 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // ROUTERMAC_H
|