Files
DefaultVPN/service/server/router_win.h
Yaroslav Gurov 24895752c1 fix: added enablePeerTraffic call to xray (#2179)
* fix: add enablePeerTraffic call to xray

* chore: remove unnecessary steps during xray TUN setup phase

* chore: move tun init from tun2socks code to ipcserver

* chore: rework xray routing
* get rid of redundant delays
* check if remote calls are successful

* chore: xray routing fine-tuning

* fix: add service qt deps to deployment build
2026-02-04 12:35:53 +08:00

75 lines
1.7 KiB
C++

#ifndef ROUTERWIN_H
#define ROUTERWIN_H
#include <QTimer>
#include <QString>
#include <QSettings>
#include <QHash>
#include <QDebug>
#include <QObject>
#include <QNetworkInterface>
#include "../client/platforms/windows/daemon/dnsutilswindows.h"
#include <WinSock2.h> //includes Windows.h
#include <WS2tcpip.h>
#include <iphlpapi.h>
#include <IcmpAPI.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
//typedef uint8_t u8_t ;
//#ifndef WIN32_LEAN_AND_MEAN
//#define WIN32_LEAN_AND_MEAN
//#endif
/**
* @brief The Router class - General class for handling ip routing
*/
class RouterWin : public QObject
{
Q_OBJECT
public:
static RouterWin& Instance();
int routeAddList(const QString &gw, const QStringList &ips);
bool clearSavedRoutes();
int routeDeleteList(const QString &gw, const QStringList &ips);
bool flushDns();
void resetIpStack();
bool StartRoutingIpv6();
bool StopRoutingIpv6();
bool createTun(const QString &dev, const QString &subnet);
void suspendWcmSvc(bool suspend);
bool updateResolvers(const QString& ifname, const QList<QHostAddress>& resolvers);
bool restoreResolvers();
private:
static QList<QString> kIpv6Subnets;
RouterWin(RouterWin const &) = delete;
RouterWin& operator= (RouterWin const&) = delete;
DWORD GetServicePid(LPCWSTR serviceName);
BOOL ListProcessThreads(DWORD dwOwnerPID);
BOOL EnableDebugPrivilege();
BOOL InitNtFunctions();
BOOL SuspendProcess(BOOL fSuspend, DWORD dwProcessId);
QNetworkInterface findLoopbackIface();
private:
RouterWin() {m_dnsUtil = new DnsUtilsWindows(this);}
QMultiMap<QString, MIB_IPFORWARDROW> m_ipForwardRows;
bool m_suspended = false;
DnsUtilsWindows *m_dnsUtil;
};
#endif // ROUTERWIN_H