}
/**
+ * @brief Check if hostname is already an IPv4 address.
+ * Will insert it into #ResolvedHostAddressList.
+ *
+ * @param host_dns_address
+ * @return bool True if already an ip, false if not
+ **/
+bool DnsResolver::handle_ip_address()
+{
+ struct in_addr dummy_conversion;
+
+ // Convert string to IP address
+ // Note: IPv4 only
+ if (inet_aton(HostDnsAddress.c_str(), &dummy_conversion) != 0)
+ {
+ std::list<HostAddress> new_host_list;
+
+ HostAddress ip_host( HostDnsAddress, 86400 * 365); // set fake TTL to one year
+ new_host_list.push_back( ip_host );
+
+ // Activate new host list
+ ResolvedHostAddressList.swap(new_host_list);
+
+ GlobalLogger.info() << "host is already an IP: " << HostDnsAddress << endl;
+
+ return true;
+ }
+
+ return false;
+}
+
+/**
* Resolve the IPs from this DNS and build a list of these IPs.
*
* @return true if the host address could be resolved, or false otherwise.
BOOST_ASSERT( !HostDnsAddress.empty() );
BOOST_ASSERT( !NameServer.empty() );
+ // Handle IP addresses in HostDnsAddress
+ if (handle_ip_address())
+ return true;
+
GlobalLogger.info() << "Resolved IP(s) for host : "
<< HostDnsAddress << endl;