From 0ae784318c95c1ddf177a0b079b01c0a779b7410 Mon Sep 17 00:00:00 2001 From: zhangjiaping Date: Thu, 22 Apr 2021 14:32:38 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20There=20is=20no=20method=20to=20check=20?= =?UTF-8?q?ipv6=20conflict.=20=E4=BF=AE=E5=A4=8D=E6=97=A0Ipv6=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E6=A3=80=E6=B5=8B=E7=9A=84Bug=20Link:http://172.17.66?= =?UTF-8?q?.192/biz/bug-view-39031.html?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/confform.cpp | 68 +++++++++++++++++++++++++++++---- src/confform.h | 5 +++ src/ksimplenm.cpp | 2 +- src/mainwindow.cpp | 9 +++++ translations/kylin-nm_zh_CN.qm | Bin 23172 -> 23282 bytes translations/kylin-nm_zh_CN.ts | 11 ++++-- 6 files changed, 84 insertions(+), 11 deletions(-) diff --git a/src/confform.cpp b/src/confform.cpp index e46b1389..2b1d89e7 100644 --- a/src/confform.cpp +++ b/src/confform.cpp @@ -494,18 +494,72 @@ bool ConfForm::check_ip_conflict(QString ifname) ret[strlen(ret)-1]=0; if ( ret != NULL ) { - if (!strcmp(ret,"0")) { - //printf("正常连接"); - return false; - } else { - //printf("ip地址冲突"); - QString strInfo = tr("IP address conflict, Please change IP"); - QString buffer = "notify-send -i network-offline " + strInfo; +// if (!strcmp(ret,"0")) { +// //printf("正常连接"); +// return false; +// } else { + if (strcmp(ret,"0")) { + //printf("ipv4地址冲突"); + QString strInfo = tr("IPV4 address conflict, Please change IP"); +// QString buffer = "notify-send -i network-offline " + strInfo; showNotify(strInfo); 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(&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("正常连接"); return false; } diff --git a/src/confform.h b/src/confform.h index b283b2dd..db6220b4 100644 --- a/src/confform.h +++ b/src/confform.h @@ -27,6 +27,7 @@ #include #include #include +#include "kylin-dbus-interface.h" namespace Ui { class ConfForm; @@ -41,6 +42,9 @@ public: ~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); + QString actLanIpv6Addr; + QString actWifiIpv6Addr; + QString lcard, wcard; public slots: void cbTypeChanged(int index); @@ -95,6 +99,7 @@ private: QString lastConnName, lastIpv4, netUuid, newUuid; bool isActWifi; //是否是wifi网络 bool canCheckIpConflict = true; //当前是否可以执行IP冲突的检测 + bool isIpv6Conflict = false; //ipv6地址是否冲突 QString labelQss, cbxQss, leQss, lineQss, btnOnQss, btnOffQss; diff --git a/src/ksimplenm.cpp b/src/ksimplenm.cpp index 1f9ba9c4..0d61dfb5 100644 --- a/src/ksimplenm.cpp +++ b/src/ksimplenm.cpp @@ -87,7 +87,7 @@ void KSimpleNM::execGetWifiList(const QString& wname) shellOutputWifi = ""; QString cmd; 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 { cmd = "nmcli -f in-use,signal,security,freq,bssid,ssid,dbus-path,category device wifi list ifname " + wname; } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f4b3dd26..c1419938 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -467,6 +467,8 @@ void MainWindow::initNetwork() lwname = iface->wname; lcardname = iface->lname; llname = iface->lname; + confForm->lcard = lcardname; + confForm->wcard = wcardname; mwBandWidth = bt->execChkLanWidth(lcardname); @@ -537,6 +539,11 @@ void MainWindow::initNetwork() } } 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(); objKyDBus->getConnectNetIp(actWifiUuid); objKyDBus->getWifiIp(actWifiUuid); + confForm->actWifiIpv6Addr = objKyDBus->dbusActiveWifiIpv6; if (oldWifiIpv4Method == "") { oldWifiIpv4Method = objKyDBus-> dbusWifiIpv4Method; } @@ -1556,6 +1564,7 @@ void MainWindow::getLanListDone(QStringList slist) ifLanConnected = true; objKyDBus->getConnectNetIp(nuuid); + confForm->actLanIpv6Addr = objKyDBus->dbusActiveLanIpv6; if (mwBandWidth == "Unknown!") { getLanBandWidth(); } //QString strLanName = TranslateLanName(nname); //进行中英文系统环境下有线网络名称的汉化 diff --git a/translations/kylin-nm_zh_CN.qm b/translations/kylin-nm_zh_CN.qm index 26d5c8c8c467a3904d2a3ac290de7687308ba027..e7afcc8a6523f9b30508d1cd0fe57f69d69280af 100644 GIT binary patch delta 2641 zcmX}td34NI6bJA-YcjvtvW-MCi6pX363IwrvJ0|LB9l;JD@8@ol!QYymY?IKDiy>* z?3!Alh*GhfRxL#k(jICnwN^NFIJTe&IlYr_j=w&?dA~XDz5Cw1_gAq`@_e79+CzLz zq!>;lUjkD~V83xh{hNraE+nt{fkKFGanW>lVZUZ-T*JSs*yLmhZMJXgPB<*JPRV~ zwVcd`*}VBzFl!>r+eWsEbwqg=XzY`AB1tWk-u|2YgPL*;B$D%xjtA0Dg&qyi#}oQz z!_d!QkBzWrD~uOl(sWqxhOQmCN~FC5-256RS^{CAJpy~YfiXESek4pf15-LJ z%$1wPu|yeDnJ?+{225;j@TjqZN6< zU-FSz6#Z)WYWkj56rJUq(3U9! z``Ag)ULev%LiZBbO%6l+VdMZOlQ&mOS96CV1qWatVxd!d>QRo^?6f=W4VPOabP0fl z(a@(6`nSR`1B|l6n6)r|H%$Hr_VRPOpsXNDKIOdqZVR7ay+f{lw?`Q0`V{)jhrzYb zd<-UK!jzS;!0g=cgv-}@QDqJ12{T(%R?A#Y;uMwD>Tr@Ox9Mv>k&V#(AJ}aM45?v7 z{zK0&48*Bac|2kKRG+oSl1cByKOPl>#@vd`FCsuR+3E>nZ5DV^_F_c?Um0liCM zw=@{?2{gZe1*ZhB%FW!6?84|a3$H`MXwmUtYZr?1I0B~`P`w7a4uhWc(D)X1&w$~+ zFggv!zJ`fIVRkvRU4V9#Fl|{PCvCGZ_xTQ9Z<8Q)Jg7SdT&wWH^Ct9-fZeCVa661H zgO(7O_zle7B2--Fi8=2Z_wv<5_z1uM)`v(c6CPE|xh1!%UEi(Y&U#)QYx$M~pC+mk z&hX!5ht!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jB6E!{h_%vym;FB`4IsC-V-L zEY}G7b3Cz57@&sXJD}w&7=K-34dHAF>KRs|n08deTQvDu$9cs)n$Pq8i1g8H9GY@OdsT+tgs(kid9pH%;dgc80e;XCSD`9v9w4_6O zB~1GTW{!vDJw69-aQeFDXtb^BEgdFrWa22r&E- zwEPS0YvAN6A!tQ2QQkG7YRJj4wpFN-yamr@p=J`VK;sWZC-fbJqYI(=Js5QvTH9da zCFpn;y6?cEKuQKI-pR3E3=T5^T1K%s<_rHWjWFymj9Ch8zr&<^(Af(!n)Ii- zcx8$e`rcKm`C=;7|F^h-CtMFBe}-efGMJjak86kXze;Mj#vL(@m9do@q=rWvK<$cV4G<<7Z!3$DAzmqU*HjM7~ z%K4wP6BW*BhMr@bcBQurzb)CoX;Nf(c*V(XHR=XCV^;ziN53^EX;W=Z` zfog7l3cB5JLOm>;Wqj_V7>@pp#-D6!_`WDI{-GC|`E1&rBdVx7=r5$nEkWd=is|<0 jIa3bQz4=JD>Td1eGf#W#eE86ae;ty=Q*rQu&RqUKtGB~w diff --git a/translations/kylin-nm_zh_CN.ts b/translations/kylin-nm_zh_CN.ts index 711dad5a..423efe48 100644 --- a/translations/kylin-nm_zh_CN.ts +++ b/translations/kylin-nm_zh_CN.ts @@ -112,9 +112,14 @@ 即将检测IP地址冲突 - - IP address conflict, Please change IP - IP地址冲突,请更换IP + + IPV4 address conflict, Please change IP + IPV4地址冲突,请更换IP + + + + IPV6 address conflict, Please change IP + IPV6地址冲突,请更换IP