Skip to content

Commit

Permalink
Fix: IPv6 can not get dest address
Browse files Browse the repository at this point in the history
Not verified
  • Loading branch information
semigodking committed Feb 27, 2020
1 parent c23af86 commit 986229a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion base.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,12 @@ static int getdestaddr_iptables(
socklen_t socklen = sizeof(*destaddr);
int error;

error = getsockopt(fd, SOL_IP, SO_ORIGINAL_DST, destaddr, &socklen);
#ifdef SOL_IPV6
int sol = (client->ss_family == AF_INET6) ? SOL_IPV6 : SOL_IP;
#else
int sol = SOL_IP;
#endif
error = getsockopt(fd, sol, SO_ORIGINAL_DST, destaddr, &socklen);
if (error) {
log_errno(LOG_WARNING, "getsockopt");
return -1;
Expand Down

0 comments on commit 986229a

Please sign in to comment.