|
|
@ -486,7 +486,6 @@ static void remote_recv_cb (EV_P_ ev_io *w, int revents) |
|
|
|
|
|
|
|
struct sockaddr src_addr; |
|
|
|
socklen_t src_addr_len = sizeof(src_addr); |
|
|
|
unsigned int addr_header_len = remote_ctx->addr_header_len; |
|
|
|
char *buf = malloc(BUF_SIZE); |
|
|
|
|
|
|
|
// recv |
|
|
@ -515,16 +514,19 @@ static void remote_recv_cb (EV_P_ ev_io *w, int revents) |
|
|
|
} |
|
|
|
|
|
|
|
int len = parse_udprealy_header(buf, buf_len, NULL, NULL); |
|
|
|
if (len == 0 || len != addr_header_len) |
|
|
|
if (len == 0) |
|
|
|
{ |
|
|
|
LOGD("[udp] Error in parse header"); |
|
|
|
// error in parse header |
|
|
|
goto CLEAN_UP; |
|
|
|
} |
|
|
|
// server may return using a different address type other than the type we |
|
|
|
// have used during sending |
|
|
|
|
|
|
|
#ifdef UDPRELAY_TUNNEL |
|
|
|
// Construct packet |
|
|
|
buf_len -= addr_header_len; |
|
|
|
memmove(buf, buf + addr_header_len, buf_len); |
|
|
|
buf_len -= len; |
|
|
|
memmove(buf, buf + len, buf_len); |
|
|
|
#else |
|
|
|
// Construct packet |
|
|
|
char *tmpbuf = malloc(buf_len + 3); |
|
|
@ -537,6 +539,9 @@ static void remote_recv_cb (EV_P_ ev_io *w, int revents) |
|
|
|
#endif |
|
|
|
|
|
|
|
#ifdef UDPRELAY_REMOTE |
|
|
|
|
|
|
|
unsigned int addr_header_len = remote_ctx->addr_header_len; |
|
|
|
|
|
|
|
// Construct packet |
|
|
|
char *tmpbuf = malloc(buf_len + addr_header_len); |
|
|
|
memcpy(tmpbuf, remote_ctx->addr_header, addr_header_len); |
|
|
|