diff --git a/stratum/client.cpp b/stratum/client.cpp index 4281737..223763c 100644 --- a/stratum/client.cpp +++ b/stratum/client.cpp @@ -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); diff --git a/stratum/client.h b/stratum/client.h index f2d150d..c58260b 100644 --- a/stratum/client.h +++ b/stratum/client.h @@ -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; diff --git a/stratum/client_core.cpp b/stratum/client_core.cpp index c7732a7..08f4098 100644 --- a/stratum/client_core.cpp +++ b/stratum/client_core.cpp @@ -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) diff --git a/stratum/socket.cpp b/stratum/socket.cpp index 107b0ac..b708f96 100644 --- a/stratum/socket.cpp +++ b/stratum/socket.cpp @@ -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); diff --git a/stratum/socket.h b/stratum/socket.h index 75a0421..c169e33 100644 --- a/stratum/socket.h +++ b/stratum/socket.h @@ -3,7 +3,7 @@ struct YAAMP_SOCKET { - char ip[1024]; + char ip[64]; int port; // pthread_mutex_t mutex;