Prefer local etcd addresses and correctly cycle over them even when they need resolving

Seems slightly overcomplicated...
This commit is contained in:
Vitaliy Filippov
2026-04-27 15:24:44 +03:00
parent ae2f570b58
commit 62b29b03c5
5 changed files with 243 additions and 119 deletions
+2 -1
View File
@@ -62,7 +62,8 @@ std::string addr_to_string(const sockaddr_storage &addr)
throw std::runtime_error("Unknown address family "+std::to_string(addr.ss_family));
if (!ok)
throw std::runtime_error(std::string("inet_ntop: ") + strerror(errno));
return std::string(peer_str)+":"+std::to_string(port);
return (addr.ss_family == AF_INET6 ? "[" : "")+std::string(peer_str)+
(addr.ss_family == AF_INET6 ? "]:" : ":")+std::to_string(port);
}
bool cidr_match(const in_addr &addr, const in_addr &net, uint8_t bits)