|
|
@ -249,6 +249,13 @@ absl::StatusOr<int> ListenerContainerAddAllLocalAddresses( |
|
|
|
return absl::FailedPreconditionError( |
|
|
|
return absl::FailedPreconditionError( |
|
|
|
absl::StrCat("getifaddrs: ", std::strerror(errno))); |
|
|
|
absl::StrCat("getifaddrs: ", std::strerror(errno))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const bool is_ipv4_available = [] { |
|
|
|
|
|
|
|
const int fd = socket(AF_INET, SOCK_DGRAM, 0); |
|
|
|
|
|
|
|
if (fd >= 0) close(fd); |
|
|
|
|
|
|
|
return fd >= 0; |
|
|
|
|
|
|
|
}(); |
|
|
|
|
|
|
|
|
|
|
|
for (ifa_it = ifa; ifa_it != nullptr; ifa_it = ifa_it->ifa_next) { |
|
|
|
for (ifa_it = ifa; ifa_it != nullptr; ifa_it = ifa_it->ifa_next) { |
|
|
|
ResolvedAddress addr; |
|
|
|
ResolvedAddress addr; |
|
|
|
socklen_t len; |
|
|
|
socklen_t len; |
|
|
@ -256,6 +263,9 @@ absl::StatusOr<int> ListenerContainerAddAllLocalAddresses( |
|
|
|
if (ifa_it->ifa_addr == nullptr) { |
|
|
|
if (ifa_it->ifa_addr == nullptr) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} else if (ifa_it->ifa_addr->sa_family == AF_INET) { |
|
|
|
} else if (ifa_it->ifa_addr->sa_family == AF_INET) { |
|
|
|
|
|
|
|
if (!is_ipv4_available) { |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
len = static_cast<socklen_t>(sizeof(sockaddr_in)); |
|
|
|
len = static_cast<socklen_t>(sizeof(sockaddr_in)); |
|
|
|
} else if (ifa_it->ifa_addr->sa_family == AF_INET6) { |
|
|
|
} else if (ifa_it->ifa_addr->sa_family == AF_INET6) { |
|
|
|
len = static_cast<socklen_t>(sizeof(sockaddr_in6)); |
|
|
|
len = static_cast<socklen_t>(sizeof(sockaddr_in6)); |
|
|
|