talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit ced9ff28116dfd044da62552a1c9e8326e365770
parent a7399bf5cb41ad8ea54030f922c19fae0c73b9b4
Author: Oliver Lowe <o@olowe.co>
Date:   Mon, 11 Aug 2025 21:32:07 +1000

Unconditionally support IPv6

Barely any code is actually v4 specific anyway. And it's 2025 ;)

Diffstat:
Mconfigure.ac | 37-------------------------------------
Msrc/common/socket.c | 51++++++++++++++++++---------------------------------
Msrc/common/utils.c | 2+-
Msrc/crash.c | 3---
Msrc/gtk/about.c | 10----------
Msrc/main.c | 6------
6 files changed, 19 insertions(+), 90 deletions(-)

diff --git a/configure.ac b/configure.ac @@ -233,10 +233,6 @@ AC_ARG_ENABLE(manual, [ --disable-manual Do not build user manual], [enable_manual=$enableval], [enable_manual=yes]) -AC_ARG_ENABLE(ipv6, - [ --disable-ipv6 Do not build IPv6 support], - [enable_ipv6=$enableval], [enable_ipv6=yes]) - AC_ARG_ENABLE(gnutls, [ --disable-gnutls Do not build GnuTLS support for TLS], [enable_gnutls=$enableval], [enable_gnutls=yes]) @@ -373,38 +369,6 @@ AC_SUBST(GLIB_LIBS) PKG_CHECK_MODULES(GDK_PIXBUF, [gdk-pixbuf-2.0 >= 2.26]) -dnl check for IPv6 option -dnl automated checks for IPv6 support. -AC_MSG_CHECKING([whether to use IPv6]) -if test x"$enable_ipv6" = xyes; then - AC_MSG_RESULT(yes) - AC_MSG_CHECKING([for IPv6 support]) - if test x"$platform_win32" = xyes; then - AC_CACHE_VAL(ac_cv_ipv6,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #include <ws2tcpip.h> - ]], [[struct in6_addr a;]])],[ac_cv_ipv6=yes],[ac_cv_ipv6=no]) - ]) - else - AC_CACHE_VAL(ac_cv_ipv6,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #define INET6 - #include <sys/types.h> - #include <netinet/in.h> - ]], [[int x = IPPROTO_IPV6; struct in6_addr a;]])],[ac_cv_ipv6=yes],[ac_cv_ipv6=no]) - ]) - fi - AC_MSG_RESULT($ac_cv_ipv6) - if test $ac_cv_ipv6 = yes; then - AC_DEFINE(INET6, 1, Define if you want IPv6 support.) - else - AC_MSG_WARN(*** IPv6 will not be supported ***) - enable_ipv6=no - fi -else - AC_MSG_RESULT(no) -fi - dnl GNUTLS AC_MSG_CHECKING([whether to use GnuTLS]) AC_MSG_RESULT($enable_gnutls) @@ -920,7 +884,6 @@ echo "" echo "gnuTLS : $enable_gnutls" echo "OAuth2 : $enable_oauth2" echo "iconv : $am_cv_func_iconv" -echo "IPv6 : $enable_ipv6" echo "enchant : $enable_enchant" echo "IMAP4 (libetpan) : $enable_libetpan" echo "NNTP (libetpan) : $enable_libetpan" diff --git a/src/common/socket.c b/src/common/socket.c @@ -242,7 +242,7 @@ static int fd_is_w32_socket(gint fd) { gint optval; gint retval = sizeof(optval); - + return !getsockopt(fd, SOL_SOCKET, SO_TYPE, (char*)&optval, &retval); } #endif @@ -377,7 +377,7 @@ gint fd_open_unix(const gchar *path) perror(buf); g_free(buf); close(sock); - return -1; + return -1; } return sock; @@ -463,7 +463,7 @@ static gboolean ssl_sock_check(GSource *source) struct timeval timeout = {0, 0}; fd_set fds; GIOCondition condition = 0; - + if (!sock || !sock->sock) return FALSE; @@ -582,7 +582,7 @@ static gint sock_connect_with_timeout(gint sock, gint ret, saved_errno; #ifdef G_OS_UNIX void (*prev_handler)(gint); - + alarm(0); prev_handler = signal(SIGALRM, timeout_handler); if (sigsetjmp(jmpenv, 1)) { @@ -621,13 +621,7 @@ static gint sock_connect_by_getaddrinfo(const gchar *hostname, gushort port) memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_ADDRCONFIG; - -#ifdef INET6 hints.ai_family = AF_UNSPEC; -#else - hints.ai_family = AF_INET; -#endif - hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; @@ -641,11 +635,6 @@ static gint sock_connect_by_getaddrinfo(const gchar *hostname, gushort port) } for (ai = res; ai != NULL; ai = ai->ai_next) { -#ifndef INET6 - if (ai->ai_family == AF_INET6) - continue; -#endif - sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); if (sock < 0 ) continue; @@ -908,7 +897,7 @@ static gboolean sock_get_address_info_async_cb(GIOChannel *source, gchar *canonical_name = NULL; gchar len = 0; GError *err = NULL; - + g_io_channel_set_encoding(source, NULL, &err); if (err) { g_warning("can't unset encoding: %s", err->message); @@ -922,7 +911,7 @@ static gboolean sock_get_address_info_async_cb(GIOChannel *source, g_warning("g_io_channel_read_chars: %s", err->message); g_error_free(err); return FALSE; - } + } if (bytes_read == sizeof(len) && len > 0) { gchar *cur = NULL; gint todo = len; @@ -950,18 +939,18 @@ static gboolean sock_get_address_info_async_cb(GIOChannel *source, break; } } - } + } } for (;;) { if (g_io_channel_read_chars(source, (gchar *)ai_member, - sizeof(ai_member), &bytes_read, &err) + sizeof(ai_member), &bytes_read, &err) != G_IO_STATUS_NORMAL) { if (err != NULL) { g_warning("g_io_channel_read_chars: addr len %s", err->message); g_error_free(err); err = NULL; break; - } + } } if (bytes_read == 0 || bytes_read != sizeof(ai_member)) @@ -976,7 +965,7 @@ static gboolean sock_get_address_info_async_cb(GIOChannel *source, addr = g_malloc(ai_member[3]); if (g_io_channel_read_chars(source, (gchar *)addr, ai_member[3], - &bytes_read, &err) + &bytes_read, &err) != G_IO_STATUS_NORMAL) { if (err != NULL) { g_warning("g_io_channel_read_chars: addr data read %s", err->message); @@ -984,7 +973,7 @@ static gboolean sock_get_address_info_async_cb(GIOChannel *source, err = NULL; g_free(addr); break; - } + } } if (bytes_read != ai_member[3]) { @@ -1046,11 +1035,7 @@ static void address_info_async_child(void *opaque) memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_CANONNAME | AI_ADDRCONFIG; -#ifdef INET6 hints.ai_family = AF_UNSPEC; -#else - hints.ai_family = AF_INET; -#endif hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; @@ -1082,7 +1067,7 @@ static void address_info_async_child(void *opaque) fd_write_all(parm->pipe_fds[1], &len, sizeof(len)); fd_write_all(parm->pipe_fds[1], res->ai_canonname, - len); + len); } else { gchar len = 0; fd_write_all(parm->pipe_fds[1], &len, @@ -1125,7 +1110,7 @@ static SockLookupData *sock_get_address_info_async(const gchar *hostname, gpointer data) { SockLookupData *lookup_data = NULL; - + refresh_resolvers(); lookup_data = g_new0(SockLookupData, 1); @@ -1163,7 +1148,7 @@ static SockLookupData *sock_get_address_info_async(const gchar *hostname, close(lookup_data->pipe_fds[1]); lookup_data->pipe_fds[1] = -1; #endif /*!G_OS_WIN32 */ - + #ifndef G_OS_WIN32 lookup_data->channel = g_io_channel_unix_new(lookup_data->pipe_fds[0]); #else @@ -1298,7 +1283,7 @@ gint sock_read(SockInfo *sock, gchar *buf, gint len) else #endif ret = fd_read(sock->sock, buf, len); - + if (ret < 0) sock->state = CONN_DISCONNECTED; return ret; @@ -1447,13 +1432,13 @@ gint fd_gets(gint fd, gchar *buf, gint len) do { /* XXX:tm try nonblock -MSKB Article ID: Q147714 +MSKB Article ID: Q147714 Windows Sockets 2 Service Provider Interface Limitations -Polling with recv(MSG_PEEK) to determine when a complete message +Polling with recv(MSG_PEEK) to determine when a complete message has arrived. Reason and Workaround not available. -Single-byte send() and recv(). +Single-byte send() and recv(). Reason: Couple one-byte sends with Nagle disabled. Workaround: Send modest amounts and receive as much as possible. (still unused) diff --git a/src/common/utils.c b/src/common/utils.c @@ -1930,7 +1930,7 @@ const gchar *get_domain_name(void) } /* Tells whether the given host address string is a valid representation of a - * numerical IP (v4 or, if supported, v6) address. + * numerical IP address. */ gboolean is_numeric_host_address(const gchar *hostaddress) { diff --git a/src/crash.c b/src/crash.c @@ -415,9 +415,6 @@ static void crash_debug(unsigned long crash_pid, static gchar *get_compiled_in_features(void) { return g_strdup_printf("%s", -#if INET6 - " IPv6" -#endif #if HAVE_ICONV " iconv" #endif diff --git a/src/gtk/about.c b/src/gtk/about.c @@ -447,16 +447,6 @@ static GtkWidget *about_create_child_page_features(void) gtk_text_buffer_insert(buffer, &iter, (gchar *)C_("iconv", "allows converting to and from different character sets\n"), -1); -#if INET6 - gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf); -#else - gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf); -#endif - gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" IPv6 "), -1, - "bold", NULL); - gtk_text_buffer_insert(buffer, &iter, - (gchar *)C_("IPv6", "adds support for IPv6 addresses\n"), -1); - #if HAVE_LIBETPAN gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf); #else diff --git a/src/main.c b/src/main.c @@ -624,12 +624,6 @@ static void main_dump_features_list(gboolean show_debug_only) else g_print(" GnuTLS\n"); #endif -#if INET6 - if (show_debug_only) - debug_print(" IPv6\n"); - else - g_print(" IPv6\n"); -#endif #if HAVE_ICONV if (show_debug_only) debug_print(" iconv\n");