Merge branch 'mxhess:main' into main

This commit is contained in:
tiamak
2025-11-16 19:00:03 +01:00
committed by GitHub
4 changed files with 25 additions and 2 deletions

View File

@@ -165,7 +165,7 @@ typedef struct cmd {
cmdfunc *func;
} cmd;
static cmdfunc do_help, do_status, do_loglevel, do_addpeers, do_droppeers, do_showpeers, do_showworkers, do_showbans, do_showhosts, do_nexthost, do_outpeers, do_inpeers, do_donatetime, do_exit, do_version;
static cmdfunc do_help, do_status, do_loglevel, do_addpeers, do_droppeers, do_showpeers, do_showworkers, do_showbans, do_unban, do_showhosts, do_nexthost, do_outpeers, do_inpeers, do_donatetime, do_exit, do_version;
#ifdef WITH_RANDOMX
static cmdfunc do_start_mining, do_stop_mining;
@@ -180,6 +180,7 @@ static cmd cmds[] = {
{ STRCONST("peers"), "", "show all peers", do_showpeers },
{ STRCONST("workers"), "", "show all connected workers", do_showworkers },
{ STRCONST("bans"), "", "show all banned IPs", do_showbans },
{ STRCONST("unban"), "[IP]", "unban peer (or all if no IP given)", do_unban },
{ STRCONST("hosts"), "", "show Monero hosts", do_showhosts },
{ STRCONST("next_host"), "", "switch to the next Monero host", do_nexthost },
{ STRCONST("outpeers"), "<N>", "set maximum number of outgoing connections", do_outpeers },
@@ -349,6 +350,16 @@ static void do_showbans(p2pool* m_pool, const char* /* args */)
}
}
static void do_unban(p2pool* m_pool, const char* /* args */)
{
if (m_pool->stratum_server()) {
m_pool->stratum_server()->clear_bans();
}
if (m_pool->p2p_server()) {
m_pool->p2p_server()->clear_bans();
}
}
// cppcheck-suppress constParameterCallback
static void do_showhosts(p2pool* m_pool, const char* /* args */)
{
@@ -516,3 +527,4 @@ ConsoleCommands::~ConsoleCommands()
}
} // namespace p2pool

View File

@@ -56,6 +56,7 @@ static constexpr std::array<const char*, 2> seed_nodes_nano{ "seed01.whiskymine.
static constexpr int DEFAULT_BACKLOG = 16;
static constexpr uint64_t DEFAULT_BAN_TIME = 600;
static constexpr uint64_t PEER_REQUEST_DELAY = 60;
static constexpr uint8_t TX_VERSION = 60;
namespace p2pool {
@@ -3182,7 +3183,8 @@ bool P2PServer::P2PClient::on_monero_block_broadcast(const uint8_t* buf, uint32_
return false;
}
if (buf[data.header_size] != TX_VERSION) {
uint8_t tx_ver = buf[data.header_size];
if (tx_ver != 4 && tx_ver != TX_VERSION) {
LOGWARN(3, "Invalid MONERO_BLOCK_BROADCAST: TX_VERSION byte not found");
return false;
}

View File

@@ -571,6 +571,14 @@ void TCPServer::print_bans()
}
}
void TCPServer::clear_bans()
{
MutexLock lock(m_bansLock);
size_t count = m_bans.size();
m_bans.clear();
LOGINFO(0, "cleared " << count << " banned IPs");
}
bool TCPServer::send_internal(Client* client, const Callback<size_t, uint8_t*, size_t>::Base& callback, bool raw)
{
check_event_loop_thread(__func__);

View File

@@ -41,6 +41,7 @@ public:
void drop_connections_async() { if (m_finished.load() == 0) { uv_async_send(&m_dropConnectionsAsync); } }
void shutdown_tcp();
virtual void print_status();
virtual void clear_bans();
[[nodiscard]] uv_loop_t* get_loop() { return &m_loop; }