mirror of
https://git.wownero.com/wownero/wownero-puddle.git
synced 2024-08-15 01:03:20 +00:00
drop bad clients
This commit is contained in:
parent
b6dddb007b
commit
f668ed60f1
1 changed files with 20 additions and 7 deletions
27
src/pool.c
27
src/pool.c
|
@ -2074,10 +2074,14 @@ client_on_read(struct bufferevent *bev, void *ctx)
|
||||||
input = bufferevent_get_input(bev);
|
input = bufferevent_get_input(bev);
|
||||||
output = bufferevent_get_output(bev);
|
output = bufferevent_get_output(bev);
|
||||||
|
|
||||||
if (evbuffer_get_length(input) >= MAX_LINE)
|
size_t len = evbuffer_get_length(input);
|
||||||
|
if (len >= MAX_LINE)
|
||||||
{
|
{
|
||||||
const char *too_long = "Message too long\n";
|
const char *too_long = "Message too long\n";
|
||||||
evbuffer_add(output, too_long, strlen(too_long));
|
evbuffer_add(output, too_long, strlen(too_long));
|
||||||
|
log_info("Removing client. Message too long.");
|
||||||
|
evbuffer_drain(input, len);
|
||||||
|
client_clear(bev);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2090,11 +2094,11 @@ client_on_read(struct bufferevent *bev, void *ctx)
|
||||||
const char unknown[] = "Unknown method";
|
const char unknown[] = "Unknown method";
|
||||||
client->json_id = json_object_get_int(id);
|
client->json_id = json_object_get_int(id);
|
||||||
|
|
||||||
|
bool unknown_message = false;
|
||||||
|
|
||||||
if (method_name == NULL)
|
if (method_name == NULL)
|
||||||
{
|
{
|
||||||
char *body = stratum_new_error_body(client->json_id, unknown);
|
unknown_message = true;
|
||||||
evbuffer_add(output, body, strlen(body));
|
|
||||||
free(body);
|
|
||||||
}
|
}
|
||||||
else if (strcmp(method_name, "login") == 0)
|
else if (strcmp(method_name, "login") == 0)
|
||||||
{
|
{
|
||||||
|
@ -2116,13 +2120,22 @@ client_on_read(struct bufferevent *bev, void *ctx)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *body = stratum_new_error_body(client->json_id, unknown);
|
unknown_message = true;
|
||||||
evbuffer_add(output, body, strlen(body));
|
|
||||||
free(body);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
json_object_put(message);
|
json_object_put(message);
|
||||||
free(line);
|
free(line);
|
||||||
|
|
||||||
|
if (unknown_message)
|
||||||
|
{
|
||||||
|
char *body = stratum_new_error_body(client->json_id, unknown);
|
||||||
|
evbuffer_add(output, body, strlen(body));
|
||||||
|
free(body);
|
||||||
|
log_info("Removing client. Unknown message.");
|
||||||
|
evbuffer_drain(input, len);
|
||||||
|
client_clear(bev);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue