fujiapple852 / trippy

A network diagnostic tool
https://trippy.cli.rs
Apache License 2.0
3.8k stars 82 forks source link

Only show hostnames if different from IPs #1363

Closed fujiapple852 closed 1 month ago

fujiapple852 commented 1 month ago

Modify the display of the Target line in the header such that, for both the source and the destination, the hostname is only shown if it differs from the IP address.

For the destination, if the user supplies a target hostname it is resolved to an IP address and and both the IP address and provided hostname are shown. If the user supplies an IP address, a reverse DNS hostname lookup is attempted and, if successful, both the IP address and first resolved hostname are shown, otherwise only the IP address is shown.

For the source, a reverse DNS hostname lookup is attempted and if successful both the IP address and first resolved hostname are shown, otherwise only the IP address is shown.

The following is an example of the old and new Target line (for ICMP and UDP/TCP).

Old (ICMP):

trip news.ycombinator.com:

Target: 192.168.1.21 (192.168.1.21) -> news.ycombinator.com (209.216.230.207)

trip 209.216.230.207:

Target: 192.168.1.21 (192.168.1.21) -> 209.216.230.207 (209.216.230.207)

New (ICMP):

trip news.ycombinator.com:

Target: 192.168.1.21 -> 209.216.230.207 (news.ycombinator.com)

trip 209.216.230.207:

Target: 192.168.1.21 -> 209.216.230.207 (news.ycombinator.com)

Old (UDP/TCP):

trip news.ycombinator.com --udp

Target: 192.168.1.21:8342 (192.168.1.21:8342) -> news.ycombinator.com:* (209.216.230.207:*)

trip 209.216.230.207 --udp:

Target: 192.168.1.21:8342 (192.168.1.21:8342) -> 209.216.230.207:* (209.216.230.207:*)

New (UDP/TCP):

trip news.ycombinator.com --udp

Target: 192.168.1.21:8342 -> 209.216.230.207:* (news.ycombinator.com)

trip 209.216.230.207 --udp:

Target: 192.168.1.21:8342 -> 209.216.230.207:* (news.ycombinator.com)