reolved merge conflict

This commit is contained in:
Jethro Grassie 2019-05-04 13:40:49 -04:00
commit a517714d28
No known key found for this signature in database
GPG key ID: DE8ED755616565BB

View file

@ -2073,10 +2073,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;
} }
@ -2089,11 +2093,14 @@ 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[ERROR_BODY_MAX]; char body[ERROR_BODY_MAX];
stratum_get_error_body(body, client->json_id, unknown); stratum_get_error_body(body, client->json_id, unknown);
evbuffer_add(output, body, strlen(body)); evbuffer_add(output, body, strlen(body));
unknown_message = true;
} }
else if (strcmp(method_name, "login") == 0) else if (strcmp(method_name, "login") == 0)
{ {
@ -2118,10 +2125,22 @@ client_on_read(struct bufferevent *bev, void *ctx)
char body[ERROR_BODY_MAX]; char body[ERROR_BODY_MAX];
stratum_get_error_body(body, client->json_id, unknown); stratum_get_error_body(body, client->json_id, unknown);
evbuffer_add(output, body, strlen(body)); evbuffer_add(output, body, strlen(body));
unknown_message = true;
} }
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;
}
} }
} }