]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
net: resolve IDN hostnames with AI_IDN 620/head
authorDarafei Praliaskouski <me@komzpa.net>
Fri, 8 May 2026 12:35:59 +0000 (16:35 +0400)
committerDarafei Praliaskouski <me@komzpa.net>
Fri, 8 May 2026 12:35:59 +0000 (16:35 +0400)
configure.ac
ui/mtr.c

index 444aad65f01c382b60b05becdec7340cab56a534..39091fd11ef6f252610bde30765117ad52380496 100644 (file)
@@ -203,6 +203,13 @@ AC_CHECK_DECLS([errno], [], [], [[
 #include <errno.h>
 #include <sys/errno.h>
   ]])
+AC_CHECK_DECLS([AI_IDN], [], [], [[
+#include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#include <netdb.h>
+  ]])
 
 AC_CHECK_TYPE([socklen_t],
   [AC_DEFINE([HAVE_SOCKLEN_T], [], [Define if your system has socklen_t])], [],
index 29f0432c222f86c3f637194cba2e1ed39544bad9..9529735a9d7e3d7f359dd3672bd39497f1404b7b 100644 (file)
--- a/ui/mtr.c
+++ b/ui/mtr.c
@@ -787,6 +787,9 @@ int get_addrinfo_from_name(
     memset(&hints, 0, sizeof hints);
     hints.ai_family = ctl->af;
     hints.ai_socktype = SOCK_DGRAM;
+#if HAVE_DECL_AI_IDN
+    hints.ai_flags = AI_IDN;
+#endif
     gai_error = getaddrinfo(name, NULL, &hints, res);
     if (gai_error) {
         if (gai_error == EAI_SYSTEM)
@@ -831,6 +834,9 @@ static int validate_report_targets(
         memset(&hints, 0, sizeof hints);
         hints.ai_family = lookup_ctl.af;
         hints.ai_socktype = SOCK_DGRAM;
+#if HAVE_DECL_AI_IDN
+        hints.ai_flags = AI_IDN;
+#endif
         gai_error = getaddrinfo(names->name, NULL, &hints, &res);
         if (gai_error) {
             if (gai_error == EAI_SYSTEM) {