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-03-20 21:00:32 +03:00
parent 96473f15f9
commit 76042d9ea8
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)