Added bans console command

This commit is contained in:
SChernykh
2022-02-21 19:59:57 +01:00
parent 9a09d15bea
commit 9593311332
5 changed files with 68 additions and 1 deletions

View File

@@ -320,6 +320,29 @@ NOINLINE void Stream::writeCurrentTime()
m_numberWidth = 1;
}
NOINLINE void put_rawip(const raw_ip& value, Stream* wrapper)
{
const char* addr_str;
char addr_str_buf[64];
static constexpr uint8_t ipv4_prefix[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255 };
const bool is_v6 = (memcmp(value.data, ipv4_prefix, 12) != 0);
if (is_v6) {
addr_str = inet_ntop(AF_INET6, value.data, addr_str_buf, sizeof(addr_str_buf));
}
else {
addr_str = inet_ntop(AF_INET, value.data + 12, addr_str_buf, sizeof(addr_str_buf));
}
if (addr_str) {
*wrapper << addr_str;
}
else {
*wrapper << "N/A";
}
}
} // namespace log
} // namespace p2pool