Reconstruct src addr for P2P usage

This commit is contained in:
Max Lv
2018-01-12 22:00:43 +08:00
parent 2bf7ecc787
commit c11e70aa8a
+7 -1
View File
@@ -192,7 +192,7 @@ hash_key(const int af, const struct sockaddr_storage *addr)
return key;
}
#if defined(MODULE_REDIR)
#if defined(MODULE_REDIR) || defined(MODULE_REMOTE)
static int
construct_udprelay_header(const struct sockaddr_storage *in_addr,
char *addr_header)
@@ -767,6 +767,12 @@ remote_recv_cb(EV_P_ ev_io *w, int revents)
char *addr_header = remote_ctx->addr_header;
int addr_header_len = remote_ctx->addr_header_len;
char addr_header_buf[512];
if (remote_ctx->af == AF_INET || remote_ctx->af == AF_INET6) {
addr_header_len = construct_udprelay_header(&src_addr, addr_header_buf);
addr_header = addr_header_buf;
}
// Construct packet
brealloc(buf, buf->len + addr_header_len, buf_size);
memmove(buf->data + addr_header_len, buf->data, buf->len);