| 51 | { |
| 52 | QString firstHostFound; |
| 53 | foreach (const QNetworkInterface &inter, QNetworkInterface::allInterfaces()) { |
| 54 | if (!(inter.flags() & QNetworkInterface::IsUp) |
| 55 | || !(inter.flags() & QNetworkInterface::IsRunning) |
| 56 | || (inter.flags() & QNetworkInterface::IsLoopBack)) |
| 57 | continue; |
| 58 | |
| 59 | foreach (const QNetworkAddressEntry &addrEntry, inter.addressEntries()) { |
| 60 | const QHostAddress addr = addrEntry.ip(); |
| 61 | |
| 62 | // Return the ip according to the listening server protocol. |
| 63 | if (addr.protocol() != m_server->serverAddress().protocol() |
| 64 | || !addr.scopeId().isEmpty()) |
| 65 | continue; |
| 66 | |
| 67 | // If its our desired IP (e.g. from --listen) return early |
| 68 | if (addr == address) |
| 69 | return addr.toString(); |
| 70 | if (firstHostFound.isEmpty()) |
| 71 | firstHostFound = addr.toString(); |
| 72 | } |
| 73 | } |
| 74 | return firstHostFound; |
| 75 | } |
| 76 |
nothing calls this directly
no test coverage detected