]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
Add display of destination with resolved addr under curses mode 373/head
authorZenithal <i@zenithal.me>
Sat, 17 Oct 2020 15:03:51 +0000 (23:03 +0800)
committerZenithal <i@zenithal.me>
Sat, 17 Oct 2020 15:03:51 +0000 (23:03 +0800)
ui/curses.c
ui/net.c
ui/net.h

index 34bf30d638400dacd6f26ddf1e85c67327a79c79..a7ee718321c8b9c11e8fd8359ae7e51deb5be2dd 100644 (file)
@@ -698,7 +698,7 @@ void mtr_curses_redraw(
     pwcenter(buf);
     attroff(A_BOLD);
 
-    mvprintw(1, 0, "%s (%s) -> %s", ctl->LocalHostname, net_localaddr(), ctl->Hostname);
+    mvprintw(1, 0, "%s (%s) -> %s (%s)", ctl->LocalHostname, net_localaddr(), ctl->Hostname, net_remoteaddr());
     t = time(NULL);
     mvprintw(1, maxx - 25, iso_time(&t));
     printw("\n");
index f684b3e9ca13935d8f08a458e79654117658f72b..e4752b730359ccd2ed250f70ffc614821c5587a8 100644 (file)
--- a/ui/net.c
+++ b/ui/net.c
@@ -97,11 +97,13 @@ static ip_t *remoteaddress;
 
 #ifdef ENABLE_IPV6
 static char localaddr[INET6_ADDRSTRLEN];
+static char remoteaddr[INET6_ADDRSTRLEN];
 #else
 #ifndef INET_ADDRSTRLEN
 #define INET_ADDRSTRLEN 16
 #endif
 static char localaddr[INET_ADDRSTRLEN];
+static char remoteaddr[INET_ADDRSTRLEN];
 #endif
 
 static int batch_at = 0;
@@ -523,6 +525,13 @@ char *net_localaddr(
 }
 
 
+char *net_remoteaddr(
+    void)
+{
+    return remoteaddr;
+}
+
+
 void net_end_transit(
     void)
 {
@@ -756,6 +765,8 @@ int net_open(
         net_find_local_address();
     }
 
+    inet_ntop(remotesockaddr->sa_family, sockaddr_addr_offset(remotesockaddr), remoteaddr, sizeof(remoteaddr));
+
     return 0;
 }
 
index 8a0d7751e2de6facbe9069db31f9eb1b60259d6a..d5262bdb8ec6a48cc3f450c215e37e548b1f5afc 100644 (file)
--- a/ui/net.h
+++ b/ui/net.h
@@ -90,6 +90,8 @@ extern ip_t *net_addrs(
     int i);
 extern char *net_localaddr(
     void);
+extern char *net_remoteaddr(
+    void);
 
 extern int net_send_batch(
     struct mtr_ctl *ctl);