Skip to content

Commit

Permalink
修复无法识别0.0.0.0这个特殊IP
Browse files Browse the repository at this point in the history
  • Loading branch information
sdk250 committed Mar 14, 2024
1 parent 0989e23 commit 22118b0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ void *handle_connection(void *_fd) {
) < 0)
{
perror("getsockopt SO_ORIGINAL_DST failed");
goto exit_label;
// goto exit_label;
}

if ((ntohl(destination_addr.sin_addr.s_addr) & 0xff000000) == 0x0a000000 || // 10.0.0.0/8
if ((ntohl(destination_addr.sin_addr.s_addr) == 0x0) || // 0.0.0.0/0
(ntohl(destination_addr.sin_addr.s_addr) & 0xff000000) == 0x0a000000 || // 10.0.0.0/8
(ntohl(destination_addr.sin_addr.s_addr) & 0xfff00000) == 0xac100000 || // 172.16.0.0/12
(ntohl(destination_addr.sin_addr.s_addr) & 0xffff0000) == 0xc0a80000 || // 192.168.0.0/16
(ntohl(destination_addr.sin_addr.s_addr) & 0xff000000) == 0x7f000000 || // 127.0.0.0/8
Expand Down

0 comments on commit 22118b0

Please sign in to comment.