mirror of
https://github.com/badaix/snapcast.git
synced 2025-08-01 15:49:56 +02:00
zeroconf works with IPv6
This commit is contained in:
parent
e9ff66e78b
commit
b34f8a6e00
5 changed files with 57 additions and 38 deletions
|
@ -226,33 +226,33 @@ bool BrowseBonjour::browse(const string& serviceName, mDNSResult& result, int ti
|
|||
{
|
||||
resultCollection[i].port_ = resolve.port;
|
||||
CHECKED(DNSServiceGetAddrInfo(service.get(), kDNSServiceFlagsLongLivedQuery, 0, kDNSServiceProtocol_IPv4, resolve.fullName.c_str(),
|
||||
[](DNSServiceRef service,
|
||||
DNSServiceFlags flags,
|
||||
uint32_t interfaceIndex,
|
||||
DNSServiceErrorType errorCode,
|
||||
const char* hostname,
|
||||
const sockaddr* address,
|
||||
uint32_t ttl,
|
||||
void* context)
|
||||
{
|
||||
auto result = static_cast<mDNSResult*>(context);
|
||||
[](DNSServiceRef service,
|
||||
DNSServiceFlags flags,
|
||||
uint32_t interfaceIndex,
|
||||
DNSServiceErrorType errorCode,
|
||||
const char* hostname,
|
||||
const sockaddr* address,
|
||||
uint32_t ttl,
|
||||
void* context)
|
||||
{
|
||||
auto result = static_cast<mDNSResult*>(context);
|
||||
|
||||
result->host_ = string(hostname);
|
||||
result->proto_ = address->sa_family;
|
||||
result->host = string(hostname);
|
||||
result->ip_version = (address->sa_family == AF_INET)?(IPVersion::IPv4):(IPVersion::IPv6);
|
||||
result->iface_idx = static_cast<int>(interfaceIndex);
|
||||
|
||||
char hostIP[NI_MAXHOST];
|
||||
char hostService[NI_MAXSERV];
|
||||
if (getnameinfo(address, sizeof(*address),
|
||||
hostIP, sizeof(hostIP),
|
||||
hostService, sizeof(hostService),
|
||||
NI_NUMERICHOST|NI_NUMERICSERV) == 0)
|
||||
result->ip_ = string(hostIP);
|
||||
else
|
||||
return;
|
||||
result->valid_ = true;
|
||||
}, &resultCollection[i++]));
|
||||
char hostIP[NI_MAXHOST];
|
||||
char hostService[NI_MAXSERV];
|
||||
if (getnameinfo(address, sizeof(*address),
|
||||
hostIP, sizeof(hostIP),
|
||||
hostService, sizeof(hostService),
|
||||
NI_NUMERICHOST|NI_NUMERICSERV) == 0)
|
||||
result->ip_ = string(hostIP);
|
||||
else
|
||||
return;
|
||||
result->valid_ = true;
|
||||
}, &resultCollection[i++]));
|
||||
}
|
||||
|
||||
runService(service);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue