route delete fixed (Windows)
This commit is contained in:
parent
d831d68e73
commit
c2f6c7d939
10 changed files with 24 additions and 15 deletions
|
@ -298,6 +298,13 @@ void MainWindow::onPushButtonNewServerConnectWithNewData(bool)
|
|||
serverCredentials.userName = ui->lineEdit_new_server_login->text();
|
||||
if (ui->pushButton_new_server_connect_key->isChecked()){
|
||||
QString key = ui->textEdit_new_server_ssh_key->toPlainText();
|
||||
if (key.startsWith("ssh-rsa")) {
|
||||
QMessageBox::warning(this, APPLICATION_NAME,
|
||||
tr("It's public key. Private key required"));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (key.contains("OPENSSH") && key.contains("BEGIN") && key.contains("PRIVATE KEY")) {
|
||||
key = OpenVpnConfigurator::convertOpenSShKey(key);
|
||||
}
|
||||
|
@ -833,7 +840,7 @@ void MainWindow::onPushButtonDeleteCustomSiteClicked(const QString &siteToDelete
|
|||
updateSettings();
|
||||
|
||||
if (m_vpnConnection->connectionState() == VpnProtocol::ConnectionState::Connected) {
|
||||
IpcClient::Interface()->routeDelete(ipToDelete);
|
||||
IpcClient::Interface()->routeDelete(ipToDelete, "");
|
||||
IpcClient::Interface()->flushDns();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,11 +40,13 @@ void VpnConnection::onConnectionStateChanged(VpnProtocol::ConnectionState state)
|
|||
IpcClient::Interface()->flushDns();
|
||||
|
||||
if (m_settings.customRouting()) {
|
||||
IpcClient::Interface()->routeDelete("0.0.0.0", m_vpnProtocol->vpnGateway());
|
||||
|
||||
IpcClient::Interface()->routeAddList(m_vpnProtocol->vpnGateway(),
|
||||
QStringList() << m_settings.primaryDns() << m_settings.secondaryDns());
|
||||
|
||||
const QStringList &black_custom = m_settings.customIps();
|
||||
qDebug() << "onConnect :: adding custom black routes, count:" << black_custom.size();
|
||||
qDebug() << "VpnConnection::onConnectionStateChanged :: adding custom routes, count:" << black_custom.size();
|
||||
|
||||
IpcClient::Interface()->routeAddList(m_vpnProtocol->vpnGateway(), black_custom);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ class IpcInterface
|
|||
SLOT( bool routeAdd(const QString &ip, const QString &gw, const QString &mask) );
|
||||
SLOT( int routeAddList(const QString &gw, const QStringList &ips) );
|
||||
SLOT( bool clearSavedRoutes() );
|
||||
SLOT( bool routeDelete(const QString &ip) );
|
||||
SLOT( bool routeDelete(const QString &ip, const QString &gw) );
|
||||
SLOT( void flushDns() );
|
||||
|
||||
SLOT( bool checkAndInstallDriver() );
|
||||
|
|
|
@ -68,9 +68,9 @@ bool IpcServer::clearSavedRoutes()
|
|||
return Router::clearSavedRoutes();
|
||||
}
|
||||
|
||||
bool IpcServer::routeDelete(const QString &ip)
|
||||
bool IpcServer::routeDelete(const QString &ip, const QString &gw)
|
||||
{
|
||||
return Router::routeDelete(ip);
|
||||
return Router::routeDelete(ip, gw);
|
||||
}
|
||||
|
||||
void IpcServer::flushDns()
|
||||
|
|
|
@ -18,7 +18,7 @@ public:
|
|||
virtual bool routeAdd(const QString &ip, const QString &gw, const QString &mask = QString()) override;
|
||||
virtual int routeAddList(const QString &gw, const QStringList &ips) override;
|
||||
virtual bool clearSavedRoutes() override;
|
||||
virtual bool routeDelete(const QString &ip) override;
|
||||
virtual bool routeDelete(const QString &ip, const QString &gw) override;
|
||||
virtual void flushDns() override;
|
||||
virtual bool checkAndInstallDriver() override;
|
||||
virtual QStringList getTapList() override;
|
||||
|
|
|
@ -34,10 +34,10 @@ bool Router::clearSavedRoutes()
|
|||
#endif
|
||||
}
|
||||
|
||||
bool Router::routeDelete(const QString &ip)
|
||||
bool Router::routeDelete(const QString &ip, const QString &gw)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
return RouterWin::Instance().routeDelete(ip);
|
||||
return RouterWin::Instance().routeDelete(ip, gw);
|
||||
#elif defined (Q_OS_MAC)
|
||||
return RouterMac::Instance().routeDelete(ip);
|
||||
#endif
|
||||
|
|
|
@ -18,7 +18,7 @@ public:
|
|||
static bool routeAdd(const QString &ip, const QString &gw, QString mask = QString());
|
||||
static int routeAddList(const QString &gw, const QStringList &ips);
|
||||
static bool clearSavedRoutes();
|
||||
static bool routeDelete(const QString &ip);
|
||||
static bool routeDelete(const QString &ip, const QString &gw);
|
||||
static void flushDns();
|
||||
};
|
||||
|
||||
|
|
|
@ -55,7 +55,8 @@ bool RouterMac::routeDelete(const QString &ip)
|
|||
p.waitForFinished();
|
||||
qDebug().noquote() << "OUTPUT routeDelete: " + p.readAll();
|
||||
|
||||
return p.exitCode() == 0;}
|
||||
return p.exitCode() == 0;
|
||||
}
|
||||
|
||||
void RouterMac::flushDns()
|
||||
{
|
||||
|
|
|
@ -274,14 +274,13 @@ bool RouterWin::clearSavedRoutes()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool RouterWin::routeDelete(const QString &ip)
|
||||
bool RouterWin::routeDelete(const QString &ip, const QString &gw)
|
||||
{
|
||||
qDebug().noquote() << QString("ROUTE DELETE, IP: %1").arg(ip);
|
||||
qDebug().noquote() << QString("ROUTE DELETE, IP: %1 GW %2").arg(ip).arg(gw);
|
||||
|
||||
QProcess p;
|
||||
p.setProcessChannelMode(QProcess::MergedChannels);
|
||||
QString command = QString("route delete %1")
|
||||
.arg(ip);
|
||||
QString command = QString("route delete %1 %2").arg(ip).arg(gw);
|
||||
|
||||
p.start(command);
|
||||
p.waitForFinished();
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
bool routeAdd(const QString &ip, const QString &gw, QString mask = QString());
|
||||
int routeAddList(const QString &gw, const QStringList &ips);
|
||||
bool clearSavedRoutes();
|
||||
bool routeDelete(const QString &ip);
|
||||
bool routeDelete(const QString &ip, const QString &gw);
|
||||
void flushDns();
|
||||
|
||||
public slots:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue