mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 17:37:25 +00:00
stratum: reduce client algo & socket struct size
to reduce a bit the memory usage... require a make clean! + prevent null/local ips from bans.
This commit is contained in:
parent
ba7873e9f2
commit
39d123a071
5 changed files with 14 additions and 6 deletions
|
@ -442,7 +442,7 @@ bool client_auth_by_workers(YAAMP_CLIENT *client)
|
|||
// source = new YAAMP_SOURCE;
|
||||
// memset(source, 0, sizeof(YAAMP_SOURCE));
|
||||
//
|
||||
// strncpy(source->ip, client->sock->ip, 1024);
|
||||
// strncpy(source->ip, client->sock->ip, 64);
|
||||
// source->speed = 1;
|
||||
//
|
||||
// g_list_source.AddTail(source);
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
// int count;
|
||||
// double speed;
|
||||
//
|
||||
// char ip[1024];
|
||||
// char ip[64];
|
||||
//};
|
||||
|
||||
struct YAAMP_ALGO
|
||||
{
|
||||
char name[1024];
|
||||
char name[64];
|
||||
YAAMP_HASH_FUNCTION hash_function;
|
||||
|
||||
double diff_multiplier;
|
||||
|
|
|
@ -126,6 +126,10 @@ void client_block_ip(YAAMP_CLIENT *client, const char *reason)
|
|||
{
|
||||
char buffer[1024];
|
||||
sprintf(buffer, "iptables -A INPUT -s %s -p tcp --dport %d -j REJECT", client->sock->ip, g_tcp_port);
|
||||
if(strcmp("0.0.0.0", client->sock->ip) == 0) return;
|
||||
if(strstr(client->sock->ip, "192.168.")) return;
|
||||
if(strstr(client->sock->ip, "127.0.0.")) return;
|
||||
|
||||
int s = system(buffer);
|
||||
stratumlog("%s: %s blocked (%s)\n", g_stratum_algo, client->sock->ip, reason);
|
||||
}
|
||||
|
@ -134,8 +138,12 @@ 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);
|
||||
if(strcmp("0.0.0.0", client->sock->ip) == 0) return;
|
||||
if(strstr(client->sock->ip, "192.168.")) return;
|
||||
if(strstr(client->sock->ip, "127.0.0.")) return;
|
||||
|
||||
int s = system(buffer);
|
||||
stratumlog("%s: %s blocked via ipset %s\n", g_stratum_algo, client->sock->ip, ipset_name);
|
||||
stratumlog("%s: %s blocked via ipset %s %s\n", g_stratum_algo, client->sock->ip, ipset_name, client->username);
|
||||
}
|
||||
|
||||
bool client_reset_multialgo(YAAMP_CLIENT *client, bool first)
|
||||
|
|
|
@ -24,7 +24,7 @@ YAAMP_SOCKET *socket_initialize(int sock)
|
|||
memset(&name, 0, len);
|
||||
|
||||
int res = getpeername(s->sock, (struct sockaddr *)&name, &len);
|
||||
inet_ntop(AF_INET, &name.sin_addr, s->ip, 1024);
|
||||
inet_ntop(AF_INET, &name.sin_addr, s->ip, 64);
|
||||
|
||||
res = getsockname(s->sock, (struct sockaddr *)&name, &len);
|
||||
s->port = ntohs(name.sin_port);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
struct YAAMP_SOCKET
|
||||
{
|
||||
char ip[1024];
|
||||
char ip[64];
|
||||
int port;
|
||||
|
||||
// pthread_mutex_t mutex;
|
||||
|
|
Loading…
Add table
Reference in a new issue