|
@ -25,10 +25,6 @@ |
|
|
#include "config.h" |
|
|
#include "config.h" |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#ifndef MSG_NOSIGNAL |
|
|
|
|
|
#define MSG_NOSIGNAL SO_NOSIGPIPE |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifndef EAGAIN |
|
|
#ifndef EAGAIN |
|
|
#define EAGAIN EWOULDBLOCK |
|
|
#define EAGAIN EWOULDBLOCK |
|
|
#endif |
|
|
#endif |
|
@ -170,7 +166,7 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) { |
|
|
response.ver = SVERSION; |
|
|
response.ver = SVERSION; |
|
|
response.method = 0; |
|
|
response.method = 0; |
|
|
char *send_buf = (char *)&response; |
|
|
char *send_buf = (char *)&response; |
|
|
send(server->fd, send_buf, sizeof(response), MSG_NOSIGNAL); |
|
|
|
|
|
|
|
|
send(server->fd, send_buf, sizeof(response), 0); |
|
|
server->stage = 1; |
|
|
server->stage = 1; |
|
|
return; |
|
|
return; |
|
|
} else if (server->stage == 1) { |
|
|
} else if (server->stage == 1) { |
|
@ -184,7 +180,7 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) { |
|
|
response.rsv = 0; |
|
|
response.rsv = 0; |
|
|
response.atyp = 1; |
|
|
response.atyp = 1; |
|
|
char *send_buf = (char *)&response; |
|
|
char *send_buf = (char *)&response; |
|
|
send(server->fd, send_buf, 4, MSG_NOSIGNAL); |
|
|
|
|
|
|
|
|
send(server->fd, send_buf, 4, 0); |
|
|
close_and_free_remote(EV_A_ remote); |
|
|
close_and_free_remote(EV_A_ remote); |
|
|
close_and_free_server(EV_A_ server); |
|
|
close_and_free_server(EV_A_ server); |
|
|
return; |
|
|
return; |
|
@ -238,7 +234,7 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) { |
|
|
= (unsigned short) htons(atoi(_remote_port)); |
|
|
= (unsigned short) htons(atoi(_remote_port)); |
|
|
|
|
|
|
|
|
int reply_size = 4 + sizeof(struct in_addr) + sizeof(unsigned short); |
|
|
int reply_size = 4 + sizeof(struct in_addr) + sizeof(unsigned short); |
|
|
int r = send(server->fd, server->buf, reply_size, MSG_NOSIGNAL); |
|
|
|
|
|
|
|
|
int r = send(server->fd, server->buf, reply_size, 0); |
|
|
if (r < reply_size) { |
|
|
if (r < reply_size) { |
|
|
LOGE("header not complete sent\n"); |
|
|
LOGE("header not complete sent\n"); |
|
|
close_and_free_remote(EV_A_ remote); |
|
|
close_and_free_remote(EV_A_ remote); |
|
@ -346,7 +342,7 @@ static void remote_recv_cb (EV_P_ ev_io *w, int revents) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
decrypt_ctx(server->buf, r, server->d_ctx); |
|
|
decrypt_ctx(server->buf, r, server->d_ctx); |
|
|
int w = send(server->fd, server->buf, r, MSG_NOSIGNAL); |
|
|
|
|
|
|
|
|
int w = send(server->fd, server->buf, r, 0); |
|
|
if(w == -1) { |
|
|
if(w == -1) { |
|
|
if (errno == EAGAIN || errno == EWOULDBLOCK) { |
|
|
if (errno == EAGAIN || errno == EWOULDBLOCK) { |
|
|
// no data, wait for send |
|
|
// no data, wait for send |
|
@ -693,6 +689,8 @@ int main (int argc, char **argv) |
|
|
close(STDERR_FILENO); |
|
|
close(STDERR_FILENO); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
signal(SIGPIPE, SIG_IGN); |
|
|
|
|
|
|
|
|
// init global variables |
|
|
// init global variables |
|
|
_server = strdup(server); |
|
|
_server = strdup(server); |
|
|
_remote_port = strdup(remote_port); |
|
|
_remote_port = strdup(remote_port); |
|
|