Fix: There is no method to check ipv6 conflict.
修复无Ipv6地址检测的Bug Link:http://172.17.66.192/biz/bug-view-39031.html
This commit is contained in:
parent
7cbc2f7884
commit
0ae784318c
|
@ -494,18 +494,72 @@ bool ConfForm::check_ip_conflict(QString ifname)
|
||||||
ret[strlen(ret)-1]=0;
|
ret[strlen(ret)-1]=0;
|
||||||
|
|
||||||
if ( ret != NULL ) {
|
if ( ret != NULL ) {
|
||||||
if (!strcmp(ret,"0")) {
|
// if (!strcmp(ret,"0")) {
|
||||||
//printf("正常连接");
|
// //printf("正常连接");
|
||||||
return false;
|
// return false;
|
||||||
} else {
|
// } else {
|
||||||
//printf("ip地址冲突");
|
if (strcmp(ret,"0")) {
|
||||||
QString strInfo = tr("IP address conflict, Please change IP");
|
//printf("ipv4地址冲突");
|
||||||
QString buffer = "notify-send -i network-offline " + strInfo;
|
QString strInfo = tr("IPV4 address conflict, Please change IP");
|
||||||
|
// QString buffer = "notify-send -i network-offline " + strInfo;
|
||||||
showNotify(strInfo);
|
showNotify(strInfo);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ui->leAddr_ipv6->text().isEmpty() || ui->leAddr_ipv6->text() == "") {
|
||||||
|
//未配置ipv6地址,跳过ipv6地址冲突检测
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
isIpv6Conflict = false;
|
||||||
|
QProcess * process = new QProcess;
|
||||||
|
if (this->isActWifi) {
|
||||||
|
//指定无线网卡检测
|
||||||
|
process->start(QString("ping6 %1%%2").arg(ui->leAddr_ipv6->text()).arg(wcard));
|
||||||
|
} else {
|
||||||
|
//指定有线网卡检测
|
||||||
|
process->start(QString("ping6 %1%%2").arg(ui->leAddr_ipv6->text()).arg(lcard));
|
||||||
|
}
|
||||||
|
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
|
||||||
|
process->deleteLater();
|
||||||
|
});
|
||||||
|
connect(process, &QProcess::readyReadStandardOutput, this, [ = ]() {
|
||||||
|
QString str = process->readAllStandardOutput();
|
||||||
|
if (!str.contains("PING")) {
|
||||||
|
if (str.contains("unreachable")) {
|
||||||
|
isIpv6Conflict = false;
|
||||||
|
} else {
|
||||||
|
//如果能ping通,需要看是不是当前本机连接的ipv6地址,如果是本机连接的,也不算冲突
|
||||||
|
if (this->isActWifi) {
|
||||||
|
if (ui->leAddr_ipv6->text() == actWifiIpv6Addr) {
|
||||||
|
//新地址与当前本机连接的wifi的ipv6地址一直,不算冲突
|
||||||
|
isIpv6Conflict = false;
|
||||||
|
} else {
|
||||||
|
isIpv6Conflict = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (ui->leAddr_ipv6->text() == actLanIpv6Addr) {
|
||||||
|
//新地址与当前本机连接的有线的ipv6地址一直,不算冲突
|
||||||
|
isIpv6Conflict = false;
|
||||||
|
} else {
|
||||||
|
isIpv6Conflict = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
process->close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connect(process, &QProcess::readyReadStandardError, this, [ = ]() {
|
||||||
|
isIpv6Conflict = false;
|
||||||
|
process->close();
|
||||||
|
});
|
||||||
|
process->waitForFinished();
|
||||||
|
if (isIpv6Conflict) {
|
||||||
|
//printf("ipv6地址冲突");
|
||||||
|
QString strInfo = tr("IPV6 address conflict, Please change IP");
|
||||||
|
showNotify(strInfo);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
//printf("正常连接");
|
//printf("正常连接");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QListView>
|
#include <QListView>
|
||||||
|
#include "kylin-dbus-interface.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ConfForm;
|
class ConfForm;
|
||||||
|
@ -41,6 +42,9 @@ public:
|
||||||
~ConfForm();
|
~ConfForm();
|
||||||
|
|
||||||
void setProp(QString connName, QString uuidName, QString v4method, QString v4addr, QString v6method, QString v6addr, QString mask, QString gateway, QString dns, bool isActConf, bool isWiFi);
|
void setProp(QString connName, QString uuidName, QString v4method, QString v4addr, QString v6method, QString v6addr, QString mask, QString gateway, QString dns, bool isActConf, bool isWiFi);
|
||||||
|
QString actLanIpv6Addr;
|
||||||
|
QString actWifiIpv6Addr;
|
||||||
|
QString lcard, wcard;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void cbTypeChanged(int index);
|
void cbTypeChanged(int index);
|
||||||
|
@ -95,6 +99,7 @@ private:
|
||||||
QString lastConnName, lastIpv4, netUuid, newUuid;
|
QString lastConnName, lastIpv4, netUuid, newUuid;
|
||||||
bool isActWifi; //是否是wifi网络
|
bool isActWifi; //是否是wifi网络
|
||||||
bool canCheckIpConflict = true; //当前是否可以执行IP冲突的检测
|
bool canCheckIpConflict = true; //当前是否可以执行IP冲突的检测
|
||||||
|
bool isIpv6Conflict = false; //ipv6地址是否冲突
|
||||||
|
|
||||||
QString labelQss, cbxQss, leQss, lineQss, btnOnQss, btnOffQss;
|
QString labelQss, cbxQss, leQss, lineQss, btnOnQss, btnOffQss;
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ void KSimpleNM::execGetWifiList(const QString& wname)
|
||||||
shellOutputWifi = "";
|
shellOutputWifi = "";
|
||||||
QString cmd;
|
QString cmd;
|
||||||
if (wname.isEmpty() || wname == "") {
|
if (wname.isEmpty() || wname == "") {
|
||||||
cmd = "nmcli -f in-use,signal,security,freq,bssid,ssid,dbus-path device wifi";
|
cmd = "nmcli -f in-use,signal,security,freq,bssid,ssid,dbus-path,category device wifi";
|
||||||
} else {
|
} else {
|
||||||
cmd = "nmcli -f in-use,signal,security,freq,bssid,ssid,dbus-path,category device wifi list ifname " + wname;
|
cmd = "nmcli -f in-use,signal,security,freq,bssid,ssid,dbus-path,category device wifi list ifname " + wname;
|
||||||
}
|
}
|
||||||
|
|
|
@ -467,6 +467,8 @@ void MainWindow::initNetwork()
|
||||||
lwname = iface->wname;
|
lwname = iface->wname;
|
||||||
lcardname = iface->lname;
|
lcardname = iface->lname;
|
||||||
llname = iface->lname;
|
llname = iface->lname;
|
||||||
|
confForm->lcard = lcardname;
|
||||||
|
confForm->wcard = wcardname;
|
||||||
|
|
||||||
mwBandWidth = bt->execChkLanWidth(lcardname);
|
mwBandWidth = bt->execChkLanWidth(lcardname);
|
||||||
|
|
||||||
|
@ -537,6 +539,11 @@ void MainWindow::initNetwork()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ksnm->execGetConnList();
|
ksnm->execGetConnList();
|
||||||
|
|
||||||
|
QString actWifiUuid = objKyDBus->getActiveWifiUuid();
|
||||||
|
objKyDBus->getConnectNetIp(actWifiUuid);
|
||||||
|
objKyDBus->getWifiIp(actWifiUuid);
|
||||||
|
confForm->actWifiIpv6Addr = objKyDBus->dbusActiveWifiIpv6;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化定时器
|
// 初始化定时器
|
||||||
|
@ -1398,6 +1405,7 @@ void MainWindow::on_wifi_changed()
|
||||||
QString actWifiUuid = objKyDBus->getActiveWifiUuid();
|
QString actWifiUuid = objKyDBus->getActiveWifiUuid();
|
||||||
objKyDBus->getConnectNetIp(actWifiUuid);
|
objKyDBus->getConnectNetIp(actWifiUuid);
|
||||||
objKyDBus->getWifiIp(actWifiUuid);
|
objKyDBus->getWifiIp(actWifiUuid);
|
||||||
|
confForm->actWifiIpv6Addr = objKyDBus->dbusActiveWifiIpv6;
|
||||||
if (oldWifiIpv4Method == "") {
|
if (oldWifiIpv4Method == "") {
|
||||||
oldWifiIpv4Method = objKyDBus-> dbusWifiIpv4Method;
|
oldWifiIpv4Method = objKyDBus-> dbusWifiIpv4Method;
|
||||||
}
|
}
|
||||||
|
@ -1556,6 +1564,7 @@ void MainWindow::getLanListDone(QStringList slist)
|
||||||
ifLanConnected = true;
|
ifLanConnected = true;
|
||||||
|
|
||||||
objKyDBus->getConnectNetIp(nuuid);
|
objKyDBus->getConnectNetIp(nuuid);
|
||||||
|
confForm->actLanIpv6Addr = objKyDBus->dbusActiveLanIpv6;
|
||||||
if (mwBandWidth == "Unknown!") { getLanBandWidth(); }
|
if (mwBandWidth == "Unknown!") { getLanBandWidth(); }
|
||||||
//QString strLanName = TranslateLanName(nname); //进行中英文系统环境下有线网络名称的汉化
|
//QString strLanName = TranslateLanName(nname); //进行中英文系统环境下有线网络名称的汉化
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -112,9 +112,14 @@
|
||||||
<translation type="unfinished">即将检测IP地址冲突</translation>
|
<translation type="unfinished">即将检测IP地址冲突</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/confform.cpp" line="359"/>
|
<location filename="../src/confform.cpp" line="503"/>
|
||||||
<source>IP address conflict, Please change IP</source>
|
<source>IPV4 address conflict, Please change IP</source>
|
||||||
<translation type="unfinished">IP地址冲突,请更换IP</translation>
|
<translation>IPV4地址冲突,请更换IP</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/confform.cpp" line="559"/>
|
||||||
|
<source>IPV6 address conflict, Please change IP</source>
|
||||||
|
<translation>IPV6地址冲突,请更换IP</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/confform.cpp" line="386"/>
|
<location filename="../src/confform.cpp" line="386"/>
|
||||||
|
|
Loading…
Reference in New Issue