Skip to content

Commit

Permalink
resetIpStack added
Browse files Browse the repository at this point in the history
  • Loading branch information
pokamest committed Dec 15, 2021
1 parent 5aa47d3 commit 343e6a5
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/vpnconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ void VpnConnection::onConnectionStateChanged(VpnProtocol::VpnConnectionState sta
{
if (IpcClient::Interface()) {
if (state == VpnProtocol::Connected){
IpcClient::Interface()->resetIpStack();
IpcClient::Interface()->flushDns();

if (m_settings.routeMode() != Settings::VpnAllSites) {
Expand Down
1 change: 1 addition & 0 deletions ipc/ipc_interface.rep
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class IpcInterface
SLOT( bool clearSavedRoutes() );
SLOT( bool routeDeleteList(const QString &gw, const QStringList &ip) );
SLOT( void flushDns() );
SLOT( void resetIpStack() );

SLOT( bool checkAndInstallDriver() );
SLOT( QStringList getTapList() );
Expand Down
5 changes: 5 additions & 0 deletions ipc/ipcserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ void IpcServer::flushDns()
return Router::flushDns();
}

void IpcServer::resetIpStack()
{
Router::resetIpStack();
}

bool IpcServer::checkAndInstallDriver()
{
#ifdef Q_OS_WIN
Expand Down
1 change: 1 addition & 0 deletions ipc/ipcserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class IpcServer : public IpcInterfaceSource
virtual bool clearSavedRoutes() override;
virtual bool routeDeleteList(const QString &gw, const QStringList &ips) override;
virtual void flushDns() override;
virtual void resetIpStack() override;
virtual bool checkAndInstallDriver() override;
virtual QStringList getTapList() override;

Expand Down
11 changes: 11 additions & 0 deletions service/server/router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,14 @@ void Router::flushDns()
#endif
}

void Router::resetIpStack()
{
#ifdef Q_OS_WIN
RouterWin::Instance().resetIpStack();
#elif defined (Q_OS_MAC)
// todo fixme
#elif defined Q_OS_LINUX
// todo fixme
#endif
}

1 change: 1 addition & 0 deletions service/server/router.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Router : public QObject
static bool clearSavedRoutes();
static int routeDeleteList(const QString &gw, const QStringList &ips);
static void flushDns();
static void resetIpStack();
};

#endif // ROUTER_H
Expand Down
21 changes: 21 additions & 0 deletions service/server/router_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,27 @@ void RouterWin::flushDns()
//qDebug().noquote() << "OUTPUT ipconfig /flushdns: " + p.readAll();
}

void RouterWin::resetIpStack()
{
// {
// QProcess p;
// QString command = QString("ipconfig /release");
// p.start(command);
// }
{
QProcess p;
QString command = QString("netsh int ip reset");
p.start(command);
p.waitForFinished();
}
{
QProcess p;
QString command = QString("netsh winsock reset");
p.start(command);
p.waitForFinished();
}
}

void RouterWin::suspendWcmSvc(bool suspend)
{
if (suspend == m_suspended) return;
Expand Down
1 change: 1 addition & 0 deletions service/server/router_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class RouterWin : public QObject
bool clearSavedRoutes();
int routeDeleteList(const QString &gw, const QStringList &ips);
void flushDns();
void resetIpStack();

void suspendWcmSvc(bool suspend);

Expand Down

0 comments on commit 343e6a5

Please sign in to comment.