mirror of
https://github.com/darkk/redsocks.git
synced 2025-08-27 04:05:31 +00:00
fix issue: EOF from client in http relay
This commit is contained in:
parent
d95c791e8b
commit
a1e65e4ccb
@ -412,6 +412,8 @@ static int httpr_toss_http_firstline(redsocks_client *client)
|
||||
if (httpr_buffer_append(&nbuff, "\x0d\x0a", 2) != 0)
|
||||
goto addition_fail;
|
||||
|
||||
free_null(httpr->firstline);
|
||||
|
||||
httpr->firstline = calloc(nbuff.len + 1, 1);
|
||||
strcpy(httpr->firstline, nbuff.buff);
|
||||
httpr_buffer_fini(&nbuff);
|
||||
@ -460,6 +462,12 @@ static void httpr_client_read_content(struct bufferevent *buffev, redsocks_clien
|
||||
}
|
||||
}
|
||||
|
||||
static void httpr_client_eof(redsocks_client *client)
|
||||
{
|
||||
client->state = httpr_recv_request;
|
||||
redsocks_connect_relay(client);
|
||||
}
|
||||
|
||||
static void httpr_client_read_cb(struct bufferevent *buffev, void *_arg)
|
||||
{
|
||||
redsocks_client *client = _arg;
|
||||
@ -575,6 +583,7 @@ relay_subsys http_relay_subsys =
|
||||
.connect_relay = httpr_connect_relay,
|
||||
.readcb = httpr_relay_read_cb,
|
||||
.writecb = httpr_relay_write_cb,
|
||||
.client_eof = httpr_client_eof,
|
||||
};
|
||||
|
||||
/* vim:set tabstop=4 softtabstop=4 shiftwidth=4: */
|
||||
|
@ -412,7 +412,10 @@ static void redsocks_event_error(struct bufferevent *buffev, short what, void *_
|
||||
|
||||
redsocks_shutdown(client, buffev, SHUT_RD);
|
||||
|
||||
if (EVBUFFER_LENGTH(antiev->output) == 0)
|
||||
if (buffev == client->client && antiev == NULL) {
|
||||
if (client->instance->relay_ss->client_eof)
|
||||
client->instance->relay_ss->client_eof(client);
|
||||
} else if (EVBUFFER_LENGTH(antiev->output) == 0)
|
||||
redsocks_shutdown(client, antiev, SHUT_WR);
|
||||
}
|
||||
else {
|
||||
|
@ -25,6 +25,8 @@ typedef struct relay_subsys_t {
|
||||
void (*fini)(struct redsocks_client_t *client);
|
||||
// connect_relay (if any) is called instead of redsocks_connect_relay after client connection acceptance
|
||||
void (*connect_relay)(struct redsocks_client_t *client);
|
||||
// client_eof is called while relay is not set up but EOF from client is received
|
||||
void (*client_eof)(struct redsocks_client_t *client);
|
||||
} relay_subsys;
|
||||
|
||||
typedef struct redsocks_config_t {
|
||||
|
Loading…
Reference in New Issue
Block a user