Commit 77da115b by wuyang.zou

fix bug:

        修正对 机器ip 地址的获取筛选条件
parent bbf2981d
......@@ -30,7 +30,8 @@ public:
for (int i = 0; i < interfaces.length(); i++) {
if ( interfaces[i].isValid() ) {
if( interfaces[i].flags().testFlag(QNetworkInterface::IsUp) && interfaces[i].flags().testFlag(QNetworkInterface::IsRunning) &&
!interfaces[i].flags().testFlag(QNetworkInterface::IsLoopBack))
!interfaces[i].flags().testFlag(QNetworkInterface::IsLoopBack)
&& interfaces[i].hardwareAddress() >12 )
{
QLOG_INFO()<<QString("GetMacByAdaptersAddresses:: interfaces[ %1 ] = %2").arg( i+1 ).arg( interfaces[i].hardwareAddress() );
macAddressList.append( interfaces[i].hardwareAddress() );
......@@ -55,8 +56,11 @@ public:
for (int i = 0; i < hostAddresses.length(); i++) {
// if(address.protocol() == QAbstractSocket::IPv4Protocol) { } //1.1.1.1 > length > 7
QHostAddress hadr = hostAddresses[i];
if ( hadr.toString().length() > 7 && !hadr.toString().contains("127.0.0.1") && !hadr.toString().contains("192.168.")
&& !hadr.toString().contains("10.0.75.1") && !hadr.toString().contains("172.") && hadr.toString().contains("10.") )
QLOG_INFO()<<QString("GetMacByAdaptersAddresses:: hostAddresses: %1 ").arg( hadr.toString() );
if ( hadr.protocol() == QAbstractSocket::IPv4Protocol && hadr.toString().length() > 7 && !hadr.toString().contains("127.0.0.1")
&& !hadr.toString().startsWith("192.168.", Qt::CaseInsensitive) // 新增限制
&& !hadr.toString().startsWith("172.", Qt::CaseInsensitive) // 新增限制
)
{
QLOG_INFO()<<QString("GetMacByAdaptersAddresses:: hostAddresses[ %1 ] = %2 , protocol: %3")
.arg( i+1 ).arg( hadr.toString() ).arg( hadr.protocol() );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment