fn format_address(
        addr: &IpAddr,
        freq: usize,
        hop: &Hop,
        dns: &DnsResolver,
        address_mode: AddressMode,
        lookup_as_info: bool,
    ) -> String {
        let addr_fmt = match address_mode {
            AddressMode::IP => addr.to_string(),
            AddressMode::Host => {
                if lookup_as_info {
                    let entry = dns.reverse_lookup_with_asinfo(*addr);
                    format_dns_entry(entry, true)
                } else {
                    let entry = dns.reverse_lookup(*addr);
                    format_dns_entry(entry, false)
                }
            }
            AddressMode::Both => {
                let hostname = if lookup_as_info {
                    let entry = dns.reverse_lookup_with_asinfo(*addr);
                    format_dns_entry(entry, true)
                } else {
                    let entry = dns.reverse_lookup(*addr);
                    format_dns_entry(entry, false)
                };
                format!("{} ({})", hostname, addr)
            }
        };

        if hop.addr_count() > 1 {
            format!(
                "{} [{:.1}%]",
                addr_fmt,
                (freq as f64 / hop.total_recv() as f64) * 100_f64
            )
        } else {
            addr_fmt
        }
    }
/// Perform a reverse DNS lookup for an address and format the result.
Perform a reverse DNS lookup for an address and format the result.
Perform a reverse DNS lookup for an address and format the result .
fn format_address(
        addr: &IpAddr,
        freq: usize,
        hop: &Hop,
        dns: &DnsResolver,
        address_mode: AddressMode,
        lookup_as_info: bool,
    ) -> String {
        let addr_fmt = match address_mode {
            AddressMode::IP => addr.to_string(),
            AddressMode::Host => {
                if lookup_as_info {
                    let entry = dns.reverse_lookup_with_asinfo(*addr);
                    format_dns_entry(entry, true)
                } else {
                    let entry = dns.reverse_lookup(*addr);
                    format_dns_entry(entry, false)
                }
            }
            AddressMode::Both => {
                let hostname = if lookup_as_info {
                    let entry = dns.reverse_lookup_with_asinfo(*addr);
                    format_dns_entry(entry, true)
                } else {
                    let entry = dns.reverse_lookup(*addr);
                    format_dns_entry(entry, false)
                };
                format!("{} ({})", hostname, addr)
            }
        };
        if hop.addr_count() > 1 {
            format!(
                "{} [{:.1}%]",
                addr_fmt,
                (freq as f64 / hop.total_recv() as f64) * 100_f64
            )
        } else {
            addr_fmt
        }
    }
fn format_address ( addr : & IpAddr , freq : usize , hop : & Hop , dns : & DnsResolver , address_mode : AddressMode , lookup_as_info : bool , ) -> String { let addr_fmt = match address_mode { AddressMode :: IP => addr . to_string ( ) , AddressMode :: Host => { if lookup_as_info { let entry = dns . reverse_lookup_with_asinfo ( * addr ) ; format_dns_entry ( entry , true ) } else { let entry = dns . reverse_lookup ( * addr ) ; format_dns_entry ( entry , false ) } } AddressMode :: Both => { let hostname = if lookup_as_info { let entry = dns . reverse_lookup_with_asinfo ( * addr ) ; format_dns_entry ( entry , true ) } else { let entry = dns . reverse_lookup ( * addr ) ; format_dns_entry ( entry , false ) } ; format ! ( " " hostname addr ) } } ; if hop . addr_count ( ) > 1 { format ! ( " " addr_fmt ( freq as f64 hop total_recv ( ) as f64 ) 100_f64 ) } else { addr_fmt } }
Perform a reverse DNS lookup for an address and format the result.
Perform a reverse DNS lookup for an address and format the result .
addr
&IpAddr
freq
usize
hop
&Hop
dns
&DnsResolver
address_mode
AddressMode
lookup_as_info
bool