Browse Source

Reconstruct src addr for P2P usage

pull/1887/merge
Max Lv 6 years ago
parent
commit
c11e70aa8a
1 changed files with 7 additions and 1 deletions
  1. 8
      src/udprelay.c

8
src/udprelay.c

@ -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);

Loading…
Cancel
Save