mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-09-30 15:20:36 +00:00
stratum: ipset function to block botnets
can be (manually) used, if needed, in client_authorize
This commit is contained in:
parent
f95177cc14
commit
a8e98c1839
2 changed files with 9 additions and 2 deletions
|
@ -122,6 +122,7 @@ void get_random_key(char *key);
|
||||||
|
|
||||||
void client_sort();
|
void client_sort();
|
||||||
void client_block_ip(YAAMP_CLIENT *client, const char *reason);
|
void client_block_ip(YAAMP_CLIENT *client, const char *reason);
|
||||||
|
void client_block_ipset(YAAMP_CLIENT *client, const char *ipset_name);
|
||||||
|
|
||||||
bool client_reset_multialgo(YAAMP_CLIENT *client, bool first);
|
bool client_reset_multialgo(YAAMP_CLIENT *client, bool first);
|
||||||
bool client_initialize_multialgo(YAAMP_CLIENT *client);
|
bool client_initialize_multialgo(YAAMP_CLIENT *client);
|
||||||
|
|
|
@ -125,11 +125,17 @@ int client_ask(YAAMP_CLIENT *client, const char *method, const char *format, ...
|
||||||
void client_block_ip(YAAMP_CLIENT *client, const char *reason)
|
void client_block_ip(YAAMP_CLIENT *client, const char *reason)
|
||||||
{
|
{
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
|
|
||||||
sprintf(buffer, "iptables -A INPUT -s %s -p tcp --dport %d -j REJECT", client->sock->ip, g_tcp_port);
|
sprintf(buffer, "iptables -A INPUT -s %s -p tcp --dport %d -j REJECT", client->sock->ip, g_tcp_port);
|
||||||
int s = system(buffer);
|
int s = system(buffer);
|
||||||
|
stratumlog("%s: %s blocked (%s)\n", g_stratum_algo, client->sock->ip, reason);
|
||||||
|
}
|
||||||
|
|
||||||
stratumlog("%s %s blocked (%s)\n", client->sock->ip, client->username, reason);
|
void client_block_ipset(YAAMP_CLIENT *client, const char *ipset_name)
|
||||||
|
{
|
||||||
|
char buffer[1024];
|
||||||
|
sprintf(buffer, "ipset -q -A %s %s", ipset_name, client->sock->ip);
|
||||||
|
int s = system(buffer);
|
||||||
|
stratumlog("%s: %s blocked via ipset %s\n", g_stratum_algo, client->sock->ip, ipset_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool client_reset_multialgo(YAAMP_CLIENT *client, bool first)
|
bool client_reset_multialgo(YAAMP_CLIENT *client, bool first)
|
||||||
|
|
Loading…
Add table
Reference in a new issue