From c71a09616816fa8ecbf929525ddaf9120b0ee7a5 Mon Sep 17 00:00:00 2001 From: ruti <> Date: Sun, 6 Oct 2024 18:59:48 +0300 Subject: [PATCH] Check IPv6 support #175 #169 --- main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/main.c b/main.c index baf56df..77f84ad 100644 --- a/main.c +++ b/main.c @@ -361,6 +361,17 @@ int get_default_ttl() } +bool ipv6_support() +{ + int fd = socket(AF_INET6, SOCK_STREAM, 0); + if (fd < 0) { + return 0; + } + close(fd); + return 1; +} + + int parse_offset(struct part *part, const char *str) { char *end = 0; @@ -879,6 +890,9 @@ int main(int argc, char **argv) } } + if (!ipv6_support()) { + params.baddr.sin6_family = AF_INET; + } if (params.baddr.sin6_family != AF_INET6) { params.ipv6 = 0; }