diff --git a/client/protocols/xrayprotocol.cpp b/client/protocols/xrayprotocol.cpp index 84922634..4b369b80 100755 --- a/client/protocols/xrayprotocol.cpp +++ b/client/protocols/xrayprotocol.cpp @@ -169,6 +169,7 @@ void XrayProtocol::stop() #if defined(Q_OS_WIN) || defined(Q_OS_LINUX) || defined(Q_OS_MACOS) IpcClient::Interface()->disableKillSwitch(); IpcClient::Interface()->StartRoutingIpv6(); + IpcClient::Interface()->restoreResolvers(); #endif qDebug() << "XrayProtocol::stop()"; m_xrayProcess.disconnect(); diff --git a/ipc/ipc_interface.rep b/ipc/ipc_interface.rep index 4ecae9bc..d9eb3e0f 100644 --- a/ipc/ipc_interface.rep +++ b/ipc/ipc_interface.rep @@ -36,5 +36,6 @@ class IpcInterface SLOT( bool enablePeerTraffic( const QJsonObject &configStr) ); SLOT( bool enableKillSwitch( const QJsonObject &excludeAddr, int vpnAdapterIndex) ); SLOT( bool updateResolvers(const QString& ifname, const QList& resolvers) ); + SLOT( bool restoreResolvers() ); }; diff --git a/ipc/ipcserver.cpp b/ipc/ipcserver.cpp index 0c7f5295..cb669c68 100644 --- a/ipc/ipcserver.cpp +++ b/ipc/ipcserver.cpp @@ -157,6 +157,10 @@ bool IpcServer::updateResolvers(const QString &ifname, const QList return Router::updateResolvers(ifname, resolvers); } +bool IpcServer::restoreResolvers() { + return Router::restoreResolvers(); +} + void IpcServer::StartRoutingIpv6() { Router::StartRoutingIpv6(); diff --git a/ipc/ipcserver.h b/ipc/ipcserver.h index 00d36354..bcc5733a 100644 --- a/ipc/ipcserver.h +++ b/ipc/ipcserver.h @@ -42,6 +42,7 @@ public: virtual bool disableKillSwitch() override; virtual bool refreshKillSwitch( bool enabled ) override; virtual bool updateResolvers(const QString& ifname, const QList& resolvers) override; + virtual bool restoreResolvers() override; private: int m_localpid = 0; diff --git a/service/server/router.cpp b/service/server/router.cpp index fdf03232..be422f04 100644 --- a/service/server/router.cpp +++ b/service/server/router.cpp @@ -99,6 +99,17 @@ bool Router::updateResolvers(const QString& ifname, const QList& r #endif } +bool Router::restoreResolvers() { +#ifdef Q_OS_LINUX + return RouterLinux::Instance().restoreResolvers(); +#endif +#ifdef Q_OS_MACOS + return RouterMac::Instance().restoreResolvers(); +#endif +#ifdef Q_OS_WIN + return RouterWin::Instance().restoreResolvers(); +#endif +} void Router::StopRoutingIpv6() { diff --git a/service/server/router.h b/service/server/router.h index dfaf9021..2285cdce 100644 --- a/service/server/router.h +++ b/service/server/router.h @@ -26,6 +26,7 @@ public: static void StartRoutingIpv6(); static void StopRoutingIpv6(); static bool updateResolvers(const QString& ifname, const QList& resolvers); + static bool restoreResolvers(); }; #endif // ROUTER_H diff --git a/service/server/router_linux.cpp b/service/server/router_linux.cpp index 852c878f..7601265b 100644 --- a/service/server/router_linux.cpp +++ b/service/server/router_linux.cpp @@ -279,6 +279,10 @@ bool RouterLinux::updateResolvers(const QString& ifname, const QListupdateResolvers(ifname, resolvers); } +bool RouterLinux::restoreResolvers() { + return m_dnsUtil->restoreResolvers(); +} + void RouterLinux::StartRoutingIpv6() { QProcess process; diff --git a/service/server/router_linux.h b/service/server/router_linux.h index 2094f596..a7bf534d 100644 --- a/service/server/router_linux.h +++ b/service/server/router_linux.h @@ -36,6 +36,7 @@ public: void StartRoutingIpv6(); void StopRoutingIpv6(); bool updateResolvers(const QString& ifname, const QList& resolvers); + bool restoreResolvers(); public slots: private: diff --git a/service/server/router_mac.cpp b/service/server/router_mac.cpp index d1afb68f..056517b5 100644 --- a/service/server/router_mac.cpp +++ b/service/server/router_mac.cpp @@ -158,6 +158,9 @@ bool RouterMac::updateResolvers(const QString& ifname, const QList return m_dnsUtil->updateResolvers(ifname, resolvers); } +bool RouterMac::restoreResolvers() { + return m_dnsUtil->restoreResolvers(); +} bool RouterMac::deleteTun(const QString &dev) { diff --git a/service/server/router_mac.h b/service/server/router_mac.h index d23e40fa..9289ce56 100644 --- a/service/server/router_mac.h +++ b/service/server/router_mac.h @@ -33,6 +33,7 @@ public: bool createTun(const QString &dev, const QString &subnet); bool deleteTun(const QString &dev); bool updateResolvers(const QString& ifname, const QList& resolvers); + bool restoreResolvers(); public slots: diff --git a/service/server/router_win.cpp b/service/server/router_win.cpp index 998f4193..849b8059 100644 --- a/service/server/router_win.cpp +++ b/service/server/router_win.cpp @@ -443,6 +443,9 @@ bool RouterWin::updateResolvers(const QString& ifname, const QList return m_dnsUtil->updateResolvers(ifname, resolvers); } +bool RouterWin::restoreResolvers() { + return m_dnsUtil->restoreResolvers(); +} void RouterWin::StopRoutingIpv6() { diff --git a/service/server/router_win.h b/service/server/router_win.h index 07b5be35..a137487e 100644 --- a/service/server/router_win.h +++ b/service/server/router_win.h @@ -47,6 +47,7 @@ public: void suspendWcmSvc(bool suspend); bool updateResolvers(const QString& ifname, const QList& resolvers); + bool restoreResolvers(); private: RouterWin(RouterWin const &) = delete;