diff --git a/src/udprelay.c b/src/udprelay.c index f9b6ac30..e298f1d8 100644 --- a/src/udprelay.c +++ b/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);