diff --git a/src/meta_plugin/hostname.rs b/src/meta_plugin/hostname.rs index a52c476..feb1236 100644 --- a/src/meta_plugin/hostname.rs +++ b/src/meta_plugin/hostname.rs @@ -56,13 +56,16 @@ impl HostnameMetaPlugin { // First try DNS resolution for both IPv4 and IPv6 addresses // lookup_host should handle both A and AAAA records - if let Ok(addrs) = dns_lookup::lookup_host(&short_hostname) { + if let Ok(addrs_iter) = dns_lookup::lookup_host(&short_hostname) { + // Collect addresses into a Vec to be able to use first() + let addrs: Vec = addrs_iter.collect(); + // Try each address (both IPv4 and IPv6) - for addr in addrs { + for addr in &addrs { // Convert to IpAddr for lookup_addr let ip_addr = match addr { - std::net::IpAddr::V4(ipv4) => std::net::IpAddr::V4(ipv4), - std::net::IpAddr::V6(ipv6) => std::net::IpAddr::V6(ipv6), + std::net::IpAddr::V4(ipv4) => std::net::IpAddr::V4(*ipv4), + std::net::IpAddr::V6(ipv6) => std::net::IpAddr::V6(*ipv6), }; // Perform reverse lookup for each address match dns_lookup::lookup_addr(&ip_addr) { @@ -238,4 +241,3 @@ impl MetaPlugin for HostnameMetaPlugin { Ok(()) } } -use gethostname::gethostname;