83{
84 const std::vector<std::string> prefixes{ "Creality", "creality" };
85
86 BOOST_LOG_TRIVIAL(info)
87 << "CrealityHostDiscovery: starting DNS-SD discovery (prefixes: Creality, creality)";
88
89 auto raw = cxnet::syncDiscoveryService(prefixes);
90
91 BOOST_LOG_TRIVIAL(info)
92 << "CrealityHostDiscovery: mDNS returned " << raw.size() << " match(es)";
93
94 std::vector<CrealityHost> hosts;
95 hosts.reserve(raw.size());
96
97
98
99 std::vector<std::string> seen_ips;
100 for (const auto& m : raw) {
101 if (m.machineIp.empty()) continue;
102 if (std::find(seen_ips.begin(), seen_ips.end(), m.machineIp) != seen_ips.end())
103 continue;
104 seen_ips.push_back(m.machineIp);
105
106 CrealityHost h;
107 h.ip = m.machineIp;
108 h.service_name = m.answer;
110
111 if (probe) {
113 }
114
115 hosts.push_back(std::move(h));
116 }
117
118 BOOST_LOG_TRIVIAL(info)
119 << "CrealityHostDiscovery: " << hosts.size() << " unique host(s) after dedup";
120
121 return hosts;
122}
std::string hostname_from_service(const std::string &service_name)
Definition CrealityHostDiscovery.cpp:34
void probe_info(CrealityHost &host)
Definition CrealityHostDiscovery.cpp:49