mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-25 10:13:44 +00:00
Reconstruct src addr for P2P usage
This commit is contained in:
+7
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user