mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-05-08 14:33:23 +00:00
fix: restore dns after using xray (#1902)
This commit is contained in:
@@ -169,6 +169,7 @@ void XrayProtocol::stop()
|
|||||||
#if defined(Q_OS_WIN) || defined(Q_OS_LINUX) || defined(Q_OS_MACOS)
|
#if defined(Q_OS_WIN) || defined(Q_OS_LINUX) || defined(Q_OS_MACOS)
|
||||||
IpcClient::Interface()->disableKillSwitch();
|
IpcClient::Interface()->disableKillSwitch();
|
||||||
IpcClient::Interface()->StartRoutingIpv6();
|
IpcClient::Interface()->StartRoutingIpv6();
|
||||||
|
IpcClient::Interface()->restoreResolvers();
|
||||||
#endif
|
#endif
|
||||||
qDebug() << "XrayProtocol::stop()";
|
qDebug() << "XrayProtocol::stop()";
|
||||||
m_xrayProcess.disconnect();
|
m_xrayProcess.disconnect();
|
||||||
|
|||||||
@@ -36,5 +36,6 @@ class IpcInterface
|
|||||||
SLOT( bool enablePeerTraffic( const QJsonObject &configStr) );
|
SLOT( bool enablePeerTraffic( const QJsonObject &configStr) );
|
||||||
SLOT( bool enableKillSwitch( const QJsonObject &excludeAddr, int vpnAdapterIndex) );
|
SLOT( bool enableKillSwitch( const QJsonObject &excludeAddr, int vpnAdapterIndex) );
|
||||||
SLOT( bool updateResolvers(const QString& ifname, const QList<QHostAddress>& resolvers) );
|
SLOT( bool updateResolvers(const QString& ifname, const QList<QHostAddress>& resolvers) );
|
||||||
|
SLOT( bool restoreResolvers() );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -157,6 +157,10 @@ bool IpcServer::updateResolvers(const QString &ifname, const QList<QHostAddress>
|
|||||||
return Router::updateResolvers(ifname, resolvers);
|
return Router::updateResolvers(ifname, resolvers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IpcServer::restoreResolvers() {
|
||||||
|
return Router::restoreResolvers();
|
||||||
|
}
|
||||||
|
|
||||||
void IpcServer::StartRoutingIpv6()
|
void IpcServer::StartRoutingIpv6()
|
||||||
{
|
{
|
||||||
Router::StartRoutingIpv6();
|
Router::StartRoutingIpv6();
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public:
|
|||||||
virtual bool disableKillSwitch() override;
|
virtual bool disableKillSwitch() override;
|
||||||
virtual bool refreshKillSwitch( bool enabled ) override;
|
virtual bool refreshKillSwitch( bool enabled ) override;
|
||||||
virtual bool updateResolvers(const QString& ifname, const QList<QHostAddress>& resolvers) override;
|
virtual bool updateResolvers(const QString& ifname, const QList<QHostAddress>& resolvers) override;
|
||||||
|
virtual bool restoreResolvers() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_localpid = 0;
|
int m_localpid = 0;
|
||||||
|
|||||||
@@ -99,6 +99,17 @@ bool Router::updateResolvers(const QString& ifname, const QList<QHostAddress>& r
|
|||||||
#endif
|
#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()
|
void Router::StopRoutingIpv6()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public:
|
|||||||
static void StartRoutingIpv6();
|
static void StartRoutingIpv6();
|
||||||
static void StopRoutingIpv6();
|
static void StopRoutingIpv6();
|
||||||
static bool updateResolvers(const QString& ifname, const QList<QHostAddress>& resolvers);
|
static bool updateResolvers(const QString& ifname, const QList<QHostAddress>& resolvers);
|
||||||
|
static bool restoreResolvers();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ROUTER_H
|
#endif // ROUTER_H
|
||||||
|
|||||||
@@ -279,6 +279,10 @@ bool RouterLinux::updateResolvers(const QString& ifname, const QList<QHostAddres
|
|||||||
return m_dnsUtil->updateResolvers(ifname, resolvers);
|
return m_dnsUtil->updateResolvers(ifname, resolvers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RouterLinux::restoreResolvers() {
|
||||||
|
return m_dnsUtil->restoreResolvers();
|
||||||
|
}
|
||||||
|
|
||||||
void RouterLinux::StartRoutingIpv6()
|
void RouterLinux::StartRoutingIpv6()
|
||||||
{
|
{
|
||||||
QProcess process;
|
QProcess process;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ public:
|
|||||||
void StartRoutingIpv6();
|
void StartRoutingIpv6();
|
||||||
void StopRoutingIpv6();
|
void StopRoutingIpv6();
|
||||||
bool updateResolvers(const QString& ifname, const QList<QHostAddress>& resolvers);
|
bool updateResolvers(const QString& ifname, const QList<QHostAddress>& resolvers);
|
||||||
|
bool restoreResolvers();
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -158,6 +158,9 @@ bool RouterMac::updateResolvers(const QString& ifname, const QList<QHostAddress>
|
|||||||
return m_dnsUtil->updateResolvers(ifname, resolvers);
|
return m_dnsUtil->updateResolvers(ifname, resolvers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RouterMac::restoreResolvers() {
|
||||||
|
return m_dnsUtil->restoreResolvers();
|
||||||
|
}
|
||||||
|
|
||||||
bool RouterMac::deleteTun(const QString &dev)
|
bool RouterMac::deleteTun(const QString &dev)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public:
|
|||||||
bool createTun(const QString &dev, const QString &subnet);
|
bool createTun(const QString &dev, const QString &subnet);
|
||||||
bool deleteTun(const QString &dev);
|
bool deleteTun(const QString &dev);
|
||||||
bool updateResolvers(const QString& ifname, const QList<QHostAddress>& resolvers);
|
bool updateResolvers(const QString& ifname, const QList<QHostAddress>& resolvers);
|
||||||
|
bool restoreResolvers();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
|||||||
@@ -443,6 +443,9 @@ bool RouterWin::updateResolvers(const QString& ifname, const QList<QHostAddress>
|
|||||||
return m_dnsUtil->updateResolvers(ifname, resolvers);
|
return m_dnsUtil->updateResolvers(ifname, resolvers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RouterWin::restoreResolvers() {
|
||||||
|
return m_dnsUtil->restoreResolvers();
|
||||||
|
}
|
||||||
|
|
||||||
void RouterWin::StopRoutingIpv6()
|
void RouterWin::StopRoutingIpv6()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public:
|
|||||||
|
|
||||||
void suspendWcmSvc(bool suspend);
|
void suspendWcmSvc(bool suspend);
|
||||||
bool updateResolvers(const QString& ifname, const QList<QHostAddress>& resolvers);
|
bool updateResolvers(const QString& ifname, const QList<QHostAddress>& resolvers);
|
||||||
|
bool restoreResolvers();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RouterWin(RouterWin const &) = delete;
|
RouterWin(RouterWin const &) = delete;
|
||||||
|
|||||||
Reference in New Issue
Block a user