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