| 8 | // IPs are sorted using natoral sorting |
| 9 | |
| 10 | QList<QString> getIpAddresses() |
| 11 | { |
| 12 | auto ipComparator = [](const QString &ip1, const QString &ip2) { |
| 13 | if (ip1.startsWith("192.168") && ip2.startsWith("192.168")) |
| 14 | return naturalSortLessThanCI(ip1, ip2); |
| 15 | |
| 16 | if (ip1.startsWith("192.168")) |
| 17 | return true; |
| 18 | |
| 19 | if (ip2.startsWith("192.168")) |
| 20 | return false; |
| 21 | |
| 22 | return naturalSortLessThanCI(ip1, ip2); |
| 23 | }; |
| 24 | |
| 25 | QList<QString> addresses; |
| 26 | for (auto add : QNetworkInterface::allAddresses()) { |
| 27 | // Exclude loopback, local, multicast |
| 28 | if (add.isGlobal()) { |
| 29 | addresses.push_back(add.toString()); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | std::sort(addresses.begin(), addresses.end(), ipComparator); |
| 34 | return addresses; |
| 35 | } |
no test coverage detected