0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-28 00:14:07 +01:00

ircd::server: Fix peer hostname string discrepancy.

This commit is contained in:
Jason Volk 2018-05-19 18:09:55 -07:00
parent 5a058be4ba
commit 69e9c9bbc6

View file

@ -84,17 +84,24 @@ ircd::server::interrupt_all()
ircd::server::peer & ircd::server::peer &
ircd::server::get(const net::hostport &hostport) ircd::server::get(const net::hostport &hostport)
{ {
auto it(peers.lower_bound(host(hostport))); thread_local char canonbuf[512];
if(it == peers.end() || it->first != host(hostport)) const auto canonized
{
net::canonize(canonbuf, hostport)
};
auto it(peers.lower_bound(canonized));
if(it == peers.end() || it->first != canonized)
{ {
auto peer{create(hostport)}; auto peer{create(hostport)};
log.debug("peer(%p) for %s created; adding...", log.debug("peer(%p) for %s created; adding...",
peer.get(), peer.get(),
string(hostport)); canonized);
const string_view key{peer->hostname}; const string_view key{peer->hostname};
it = peers.emplace_hint(it, key, std::move(peer)); it = peers.emplace_hint(it, key, std::move(peer));
assert(it->second->hostname.data() == it->first.data()); assert(it->second->hostname.data() == it->first.data());
assert(key == canonized);
} }
return *it->second; return *it->second;
@ -112,7 +119,7 @@ ircd::server::create(const net::hostport &hostport)
{ {
peer->remote, net::hostport peer->remote, net::hostport
{ {
peer->hostname, "matrix", port(hostport) peer->hostname, net::canon_service, port(hostport)
} }
}; };