Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Masking entries on the IPs/Hostnames list (curses interface) #269

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ confinc
confmf
conftest.*
stamp-h1*
tags
cscope.out

/build-aux/compile
/build-aux/depcomp
Expand Down
49 changes: 41 additions & 8 deletions ui/curses.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,25 @@ int mtr_curses_keyaction(
return ActionNone;
ctl->maxTTL = i;

return ActionNone;
case '0':
mvprintw(2, 0, "Mask : %d\n\n", ctl->fstMASK);
move(2, 7);
refresh();
while ((c = getch()) != '\n' && i < MAXFLD) {
attron(A_BOLD);
printw("%c", c);
attroff(A_BOLD);
refresh();
buf[i++] = c; /* need more checking on 'c' */
}
buf[i] = '\0';
i = atoi(buf);

if (i > (MaxHost - 1))
return ActionNone;
ctl->fstMASK = i;

return ActionNone;
/* fields to display & their ordering */
case 'o':
Expand Down Expand Up @@ -369,6 +388,8 @@ int mtr_curses_keyaction(
printw(" y switching IP info\n");
printw(" z toggle ASN info on/off\n");
#endif
printw
(" 0 <n> masks first #n IPs in the TTL list (0 = masking off)\n");
printw("\n");
printw(" press any key to go back...");
getch(); /* read and ignore 'any key' */
Expand Down Expand Up @@ -435,13 +456,17 @@ static void mtr_curses_hosts(
if (is_printii(ctl))
printw(fmt_ipinfo(ctl, addr));
#endif
if (name != NULL) {
if (ctl->show_ips)
printw("%s (%s)", name, strlongip(ctl, addr));
else
printw("%s", name);
if ( at < ctl->fstMASK ) {
printw("___ip_masked___");
} else {
printw("%s", strlongip(ctl, addr));
if (name != NULL) {
if (ctl->show_ips)
printw("%s (%s)", name, strlongip(ctl, addr));
else
printw("%s", name);
} else {
printw("%s", strlongip(ctl, addr));
}
}
attroff(A_BOLD);

Expand Down Expand Up @@ -656,7 +681,11 @@ static void mtr_curses_graph(
printw(fmt_ipinfo(ctl, addr));
#endif
name = dns_lookup(ctl, addr);
printw("%s", name ? name : strlongip(ctl, addr));
if ( at < ctl->fstMASK ) {
printw("___ip_masked___");
} else {
printw("%s", name ? name : strlongip(ctl, addr));
}
} else {
attron(A_BOLD);
printw("(%s)", host_error_to_string(err));
Expand Down Expand Up @@ -701,7 +730,11 @@ void mtr_curses_redraw(
pwcenter(buf);
attroff(A_BOLD);

mvprintw(1, 0, "%s (%s)", ctl->LocalHostname, net_localaddr());
if (ctl->fstMASK == 0) {
mvprintw(1, 0, "%s (%s)", ctl->LocalHostname, net_localaddr());
} else {
mvprintw(1, 0, "hostname masked (ip masked)", ctl->LocalHostname, net_localaddr());
}
t = time(NULL);
mvprintw(1, maxx - 25, iso_time(&t));
printw("\n");
Expand Down
1 change: 1 addition & 0 deletions ui/mtr.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ int main(
ctl.probe_timeout = 10 * 1000000;
ctl.ipinfo_no = -1;
ctl.ipinfo_max = -1;
ctl.fstMASK = 0;
xstrncpy(ctl.fld_active, "LS NABWV", 2 * MAXFLD);

/*
Expand Down
1 change: 1 addition & 0 deletions ui/mtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ struct mtr_ctl {
use_dns:1,
show_ips:1,
enablempls:1, dns:1, reportwide:1, Interactive:1, DisplayMode:5;
int fstMASK; /* initial hub(ttl) without masking IP address/DNS name */
};

/* dynamic field drawing */
Expand Down