83 lines
1.9 KiB
Diff
83 lines
1.9 KiB
Diff
From 4c3b0b188670a873795f720eaaf68edfc29b461a Mon Sep 17 00:00:00 2001
|
|
From: Zenithal <i@zenithal.me>
|
|
Date: Sat, 17 Oct 2020 23:03:51 +0800
|
|
Subject: [PATCH] Add display of destination with resolved addr under curses
|
|
mode
|
|
|
|
---
|
|
ui/curses.c | 2 +-
|
|
ui/net.c | 11 +++++++++++
|
|
ui/net.h | 2 ++
|
|
3 files changed, 14 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/ui/curses.c b/ui/curses.c
|
|
index 34bf30d..a7ee718 100644
|
|
--- a/ui/curses.c
|
|
+++ b/ui/curses.c
|
|
@@ -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, "%s", iso_time(&t));
|
|
printw("\n");
|
|
diff --git a/ui/net.c b/ui/net.c
|
|
index f684b3e..e4752b7 100644
|
|
--- 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;
|
|
}
|
|
|
|
diff --git a/ui/net.h b/ui/net.h
|
|
index 8a0d775..d5262bd 100644
|
|
--- 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);
|
|
--
|
|
2.27.0
|
|
|