MCPcopy Create free account
hub / github.com/YACReader/yacreader / getIpAddresses

Function getIpAddresses

YACReaderLibrary/ip_config_helper.cpp:10–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8// IPs are sorted using natoral sorting
9
10QList<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}

Callers 2

printServerInfoFunction · 0.85
generateQRMethod · 0.85

Calls 2

naturalSortLessThanCIFunction · 0.85
toStringMethod · 0.80

Tested by

no test coverage detected