mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 08:12:37 +01:00
ircd::net: Add loghead() similar to client::loghead().
This commit is contained in:
parent
d7da57e073
commit
e97742ef39
2 changed files with 23 additions and 0 deletions
|
@ -55,6 +55,8 @@ namespace ircd::net
|
|||
ipport remote_ipport(const socket &) noexcept;
|
||||
std::pair<size_t, size_t> bytes(const socket &) noexcept; // <in, out>
|
||||
std::pair<size_t, size_t> calls(const socket &) noexcept; // <in, out>
|
||||
string_view loghead(const mutable_buffer &out, const socket &);
|
||||
string_view loghead(const socket &);
|
||||
|
||||
const_buffer peer_cert_der(const mutable_buffer &, const socket &);
|
||||
const_buffer peer_cert_der_sha256(const mutable_buffer &, const socket &);
|
||||
|
|
21
ircd/net.cc
21
ircd/net.cc
|
@ -123,6 +123,27 @@ noexcept
|
|||
};
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::net::loghead(const socket &socket)
|
||||
{
|
||||
thread_local char buf[512];
|
||||
return loghead(buf, socket);
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::net::loghead(const mutable_buffer &out,
|
||||
const socket &socket)
|
||||
{
|
||||
thread_local char buf[2][128];
|
||||
return fmt::sprintf
|
||||
{
|
||||
out, "socket:%lu local[%s] remote[%s]",
|
||||
id(*socket),
|
||||
string(buf[0], local_ipport(socket)),
|
||||
string(buf[1], remote_ipport(socket)),
|
||||
};
|
||||
}
|
||||
|
||||
ircd::net::ipport
|
||||
ircd::net::remote_ipport(const socket &socket)
|
||||
noexcept try
|
||||
|
|
Loading…
Reference in a new issue