Reordered DnsResolver::handle_ip_address method.
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Sat, 27 Aug 2011 15:10:40 +0000 (12:10 -0300)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Sat, 27 Aug 2011 15:17:52 +0000 (12:17 -0300)
src/dns/dnsresolver.cpp
src/dns/dnsresolver.h

index 332a190..98e6afa 100644 (file)
@@ -68,39 +68,6 @@ DnsResolver::~DnsResolver()
 }
 
 /**
- * @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()
-{
-    BOOST_ASSERT( !HostDnsAddress.empty() );
-
-    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;
-}
-
-/**
  * @brief 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.
@@ -211,6 +178,39 @@ bool DnsResolver::expired_resolved_ip()
     return false;
 }
 
+/**
+ * @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()
+{
+    BOOST_ASSERT( !HostDnsAddress.empty() );
+
+    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;
+}
+
 void DnsResolver::fill_answers_list(
         const string &host_dns_address,
         const string &name_server,
index 11c0b95..d9d011b 100644 (file)
@@ -49,6 +49,8 @@ public:
     bool expired_resolved_ip();
 
 private:
+    bool handle_ip_address();
+
     void fill_answers_list(
             const std::string &host_dns_address,
             const std::string &name_server,
@@ -59,7 +61,6 @@ private:
             std::list<HostAddress> *resolved_host_address_list
     );
 
-    bool handle_ip_address();
 private:
     /// The list of IPs available to the host DNS.
     std::list<HostAddress> ResolvedHostAddressList;