fix: resolve iterator first() error and remove unused import

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-26 21:47:23 -03:00
parent fbffd010be
commit 379c45b556

View File

@@ -56,13 +56,16 @@ impl HostnameMetaPlugin {
// First try DNS resolution for both IPv4 and IPv6 addresses // First try DNS resolution for both IPv4 and IPv6 addresses
// lookup_host should handle both A and AAAA records // 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<std::net::IpAddr> = addrs_iter.collect();
// Try each address (both IPv4 and IPv6) // Try each address (both IPv4 and IPv6)
for addr in addrs { for addr in &addrs {
// Convert to IpAddr for lookup_addr // Convert to IpAddr for lookup_addr
let ip_addr = match addr { let ip_addr = match addr {
std::net::IpAddr::V4(ipv4) => std::net::IpAddr::V4(ipv4), std::net::IpAddr::V4(ipv4) => std::net::IpAddr::V4(*ipv4),
std::net::IpAddr::V6(ipv6) => std::net::IpAddr::V6(ipv6), std::net::IpAddr::V6(ipv6) => std::net::IpAddr::V6(*ipv6),
}; };
// Perform reverse lookup for each address // Perform reverse lookup for each address
match dns_lookup::lookup_addr(&ip_addr) { match dns_lookup::lookup_addr(&ip_addr) {
@@ -238,4 +241,3 @@ impl MetaPlugin for HostnameMetaPlugin {
Ok(()) Ok(())
} }
} }
use gethostname::gethostname;