mtr icon indicating copy to clipboard operation
mtr copied to clipboard

mtr with unspecified destination

Open yvs2014 opened this issue 1 year ago • 2 comments

Hello,

accidentally spotted in current version

% sudo ./mtr 0
<many lines with localhost>

non-gtk part probably can be fixed with

diff --git a/ui/net.c b/ui/net.c
index efeb782..2ba94cc 100644
--- a/ui/net.c
+++ b/ui/net.c
@@ -746,13 +746,14 @@ int net_open(
         return err;
     }
 
-    net_reopen(ctl, res);
+    if (net_reopen(ctl, res) != 0)
+      return -1; /* fail */
 
     return 0;
 }
 
 
-void net_reopen(
+int net_reopen(
     struct mtr_ctl *ctl,
     struct addrinfo *res)
 {
@@ -767,6 +768,8 @@ void net_reopen(
     ctl->af = remotesockaddr->sa_family = sourcesockaddr->sa_family = res->ai_family;
     remoteaddress = sockaddr_addr_offset(remotesockaddr);
     memcpy(remoteaddress, sockaddr_addr_offset(res->ai_addr), sockaddr_addr_size(remotesockaddr));
+    if (addrcmp(remoteaddress, &ctl->unspec_addr, ctl->af) == 0)
+        return -1; /* fail */
     inet_ntop(remotesockaddr->sa_family, remoteaddress, remoteaddr, sizeof(remoteaddr));
 
     sourceaddress = sockaddr_addr_offset(sourcesockaddr);
@@ -780,7 +783,7 @@ void net_reopen(
     } else {
         net_find_local_address();
     }
-
+    return 0; /* norm */
 }
 
 
diff --git a/ui/net.h b/ui/net.h
index 354c998..2488d13 100644
--- a/ui/net.h
+++ b/ui/net.h
@@ -34,7 +34,7 @@
 extern int net_open(
     struct mtr_ctl *ctl,
     struct addrinfo *res);
-extern void net_reopen(
+extern int net_reopen(
     struct mtr_ctl *ctl,
     struct addrinfo *res);
 extern void net_reset(

yvs2014 avatar Apr 25 '23 12:04 yvs2014

Agreed. Can you create a pull request for me?

rewolff avatar Apr 25 '23 12:04 rewolff

Done, but I cannot create the second fork of the same repo. On copied branch it looks like below https://github.com/traviscross/mtr/compare/master...yvs2014:mtr085:mtr20230425-unspecaddr

yvs2014 avatar Apr 25 '23 14:04 yvs2014