mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-24 02:00:24 +07:00
set timelimit for flushDns
This commit is contained in:
@@ -55,9 +55,7 @@ AmneziaApplication::~AmneziaApplication()
|
||||
if (m_vpnConnection) {
|
||||
qDebug() << "AmneziaApplication have m_vpnConnection";
|
||||
QMetaObject::invokeMethod(m_vpnConnection.get(), "disconnectFromVpn", Qt::QueuedConnection);
|
||||
#ifndef Q_OS_LINUX
|
||||
QMetaObject::invokeMethod(m_vpnConnection.get(), "deleteLater", Qt::QueuedConnection);
|
||||
#endif
|
||||
}
|
||||
|
||||
m_vpnConnectionThread.quit();
|
||||
|
||||
@@ -443,12 +443,14 @@ void VpnConnection::disconnectFromVpn()
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
QString proto = m_settings->defaultContainerName(m_settings->defaultServerIndex());
|
||||
if (IpcClient::Interface()) {
|
||||
IpcClient::Interface()->flushDns();
|
||||
|
||||
QRemoteObjectPendingReply<bool> flushDnsResp = IpcClient::Interface()->flushDns();
|
||||
flushDnsResp.waitForFinished(1000);
|
||||
|
||||
qDebug() << "Flushed DNS";
|
||||
// delete cached routes
|
||||
QRemoteObjectPendingReply<bool> response = IpcClient::Interface()->clearSavedRoutes();
|
||||
response.waitForFinished(1000);
|
||||
QRemoteObjectPendingReply<bool> clearSavedRoutesResp = IpcClient::Interface()->clearSavedRoutes();
|
||||
clearSavedRoutesResp.waitForFinished(1000);
|
||||
}
|
||||
|
||||
qDebug() << "Flushed DNS and routes";
|
||||
|
||||
@@ -12,7 +12,7 @@ class IpcInterface
|
||||
SLOT( int routeAddList(const QString &gw, const QStringList &ips) );
|
||||
SLOT( bool clearSavedRoutes() );
|
||||
SLOT( bool routeDeleteList(const QString &gw, const QStringList &ip) );
|
||||
SLOT( void flushDns() );
|
||||
SLOT( bool flushDns() );
|
||||
SLOT( void resetIpStack() );
|
||||
|
||||
SLOT( bool checkAndInstallDriver() );
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ bool IpcServer::routeDeleteList(const QString &gw, const QStringList &ips)
|
||||
return Router::routeDeleteList(gw, ips);
|
||||
}
|
||||
|
||||
void IpcServer::flushDns()
|
||||
bool IpcServer::flushDns()
|
||||
{
|
||||
#ifdef MZ_DEBUG
|
||||
qDebug() << "IpcServer::flushDns";
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ public:
|
||||
virtual int routeAddList(const QString &gw, const QStringList &ips) override;
|
||||
virtual bool clearSavedRoutes() override;
|
||||
virtual bool routeDeleteList(const QString &gw, const QStringList &ips) override;
|
||||
virtual void flushDns() override;
|
||||
virtual bool flushDns() override;
|
||||
virtual void resetIpStack() override;
|
||||
virtual bool checkAndInstallDriver() override;
|
||||
virtual QStringList getTapList() override;
|
||||
|
||||
@@ -42,14 +42,14 @@ int Router::routeDeleteList(const QString &gw, const QStringList &ips)
|
||||
#endif
|
||||
}
|
||||
|
||||
void Router::flushDns()
|
||||
bool Router::flushDns()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
RouterWin::Instance().flushDns();
|
||||
return RouterWin::Instance().flushDns();
|
||||
#elif defined (Q_OS_MAC)
|
||||
RouterMac::Instance().flushDns();
|
||||
return RouterMac::Instance().flushDns();
|
||||
#elif defined Q_OS_LINUX
|
||||
RouterLinux::Instance().flushDns();
|
||||
return RouterLinux::Instance().flushDns();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
static int routeAddList(const QString &gw, const QStringList &ips);
|
||||
static bool clearSavedRoutes();
|
||||
static int routeDeleteList(const QString &gw, const QStringList &ips);
|
||||
static void flushDns();
|
||||
static bool flushDns();
|
||||
static void resetIpStack();
|
||||
static bool createTun(const QString &dev, const QString &subnet);
|
||||
static bool deleteTun(const QString &dev);
|
||||
|
||||
@@ -160,7 +160,7 @@ bool RouterLinux::isServiceActive(const QString &serviceName) {
|
||||
return process.exitCode() == 0;
|
||||
}
|
||||
|
||||
void RouterLinux::flushDns()
|
||||
bool RouterLinux::flushDns()
|
||||
{
|
||||
QProcess p;
|
||||
p.setProcessChannelMode(QProcess::MergedChannels);
|
||||
@@ -174,7 +174,7 @@ void RouterLinux::flushDns()
|
||||
p.start("systemctl", { "restart", "systemd-resolved" });
|
||||
} else {
|
||||
qDebug() << "No suitable DNS manager found.";
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
p.waitForFinished();
|
||||
@@ -183,6 +183,8 @@ void RouterLinux::flushDns()
|
||||
qDebug().noquote() << "Flush dns completed";
|
||||
else
|
||||
qDebug().noquote() << "OUTPUT systemctl restart nscd/systemd-resolved: " + output;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RouterLinux::createTun(const QString &dev, const QString &subnet) {
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
bool routeDelete(const QString &ip, const QString &gw, const int &sock);
|
||||
bool routeDeleteList(const QString &gw, const QStringList &ips);
|
||||
QString getgatewayandiface();
|
||||
void flushDns();
|
||||
bool flushDns();
|
||||
bool createTun(const QString &dev, const QString &subnet);
|
||||
bool deleteTun(const QString &dev);
|
||||
void StartRoutingIpv6();
|
||||
|
||||
@@ -166,7 +166,7 @@ bool RouterMac::deleteTun(const QString &dev)
|
||||
return true;
|
||||
}
|
||||
|
||||
void RouterMac::flushDns()
|
||||
bool RouterMac::flushDns()
|
||||
{
|
||||
// sudo killall -HUP mDNSResponder
|
||||
QProcess p;
|
||||
@@ -174,5 +174,7 @@ void RouterMac::flushDns()
|
||||
|
||||
p.start("killall", QStringList() << "-HUP" << "mDNSResponder");
|
||||
p.waitForFinished();
|
||||
|
||||
qDebug().noquote() << "OUTPUT killall -HUP mDNSResponder: " + p.readAll();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
bool clearSavedRoutes();
|
||||
bool routeDelete(const QString &ip, const QString &gw);
|
||||
bool routeDeleteList(const QString &gw, const QStringList &ips);
|
||||
void flushDns();
|
||||
bool flushDns();
|
||||
bool createTun(const QString &dev, const QString &subnet);
|
||||
bool deleteTun(const QString &dev);
|
||||
bool updateResolvers(const QString& ifname, const QList<QHostAddress>& resolvers);
|
||||
|
||||
@@ -273,7 +273,7 @@ int RouterWin::routeDeleteList(const QString &gw, const QStringList &ips)
|
||||
return success_count;
|
||||
}
|
||||
|
||||
void RouterWin::flushDns()
|
||||
bool RouterWin::flushDns()
|
||||
{
|
||||
QProcess p;
|
||||
p.setProcessChannelMode(QProcess::MergedChannels);
|
||||
@@ -281,6 +281,7 @@ void RouterWin::flushDns()
|
||||
|
||||
p.start(command);
|
||||
p.waitForFinished();
|
||||
return true;
|
||||
//qDebug().noquote() << "OUTPUT ipconfig /flushdns: " + p.readAll();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
int routeAddList(const QString &gw, const QStringList &ips);
|
||||
bool clearSavedRoutes();
|
||||
int routeDeleteList(const QString &gw, const QStringList &ips);
|
||||
void flushDns();
|
||||
bool flushDns();
|
||||
void resetIpStack();
|
||||
|
||||
void StartRoutingIpv6();
|
||||
|
||||
Reference in New Issue
Block a user