Largely unrelated, so just leaving this here for follow-up. I think this can be cleaned up quite a bit:
<details>
<summary>git diff</summary>
diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index 49c2a85e1..46d095633 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -311,17 +311,17 @@ static bool HTTPBindAddresses(struct evhttp* http)
}
// Bind addresses
- for (std::vector<std::pair<std::string, uint16_t> >::iterator i = endpoints.begin(); i != endpoints.end(); ++i) {
- LogPrintf("Binding RPC on address %s port %i\n", i->first, i->second);
- evhttp_bound_socket *bind_handle = evhttp_bind_socket_with_handle(http, i->first.empty() ? nullptr : i->first.c_str(), i->second);
+ for (const auto& [raw_addr, port] : endpoints) {
+ LogPrintf("Binding RPC on address %s port %i\n", raw_addr, port);
+ evhttp_bound_socket *bind_handle = evhttp_bind_socket_with_handle(http, raw_addr.empty() ? nullptr : raw_addr.c_str(), port);
if (bind_handle) {
- const std::optional<CNetAddr> addr{LookupHost(i->first, false)};
- if (i->first.empty() || (addr.has_value() && addr->IsBindAny())) {
+ const std::optional<CNetAddr> addr{LookupHost(raw_addr, false)};
+ if (raw_addr.empty() || (addr.has_value() && addr->IsBindAny())) {
LogPrintf("WARNING: the RPC server is not safe to expose to untrusted networks such as the public internet\n");
}
boundSockets.push_back(bind_handle);
} else {
- LogPrintf("Binding RPC on address %s port %i failed.\n", i->first, i->second);
+ LogPrintf("Binding RPC on address %s port %i failed.\n", raw_addr, port);
}
}
return !boundSockets.empty();
</details>