continue implementation; first tests with recursion returned IPs but then added cance...
[pingcheck] / src / dns / dnsresolver.h
index 7069610..15d2a28 100644 (file)
@@ -38,6 +38,7 @@
 
 
 typedef std::pair<std::string, std::string> string_pair;
+typedef std::pair<std::string, HostAddress> host_addr_pair;
 
 
 class DnsResolver : public ResolverBase
@@ -50,6 +51,10 @@ public:
     friend ResolverItem& DnsMaster::get_resolver_for(
                                                  const std::string &hostname,
                                                  const DnsIpProtocol &protocol);
+    friend ResolverItem DnsMaster::get_recursor_for(
+                                   const std::string &hostname,
+                                   const DnsIpProtocol &protocol,
+                                   const boost::asio::ip::address &name_server);
 private:
     DnsResolver(IoServiceItem &io_serv,
                 const std::string &hostname,
@@ -62,6 +67,8 @@ public:
     HostAddress get_next_ip();
     bool have_up_to_date_ip();
     int get_resolved_ip_count();
+    void cancel_resolve();
+    bool is_resolving();
 
 // implementation of ResolverBase::async_resolve
 protected:
@@ -73,11 +80,10 @@ private:
     void handle_dns_result(const boost::system::error_code &error,
                            const std::size_t bytes_transferred);
     void handle_unavailable();
-    void handle_ips(const HostAddressVec &ips);
-    void handle_cname(const std::string &canonical_name);
+    void handle_ips(const std::vector<host_addr_pair> &result_ips);
+    void handle_cname(const std::vector<string_pair> &result_cnames);
     void handle_recurse(const HostAddress &name_server);
-    void cname_resolve_callback(const std::string &canonical_name,
-                                const bool was_success,
+    void cname_resolve_callback(const bool was_success,
                                 const int recursion_count);
     void recursive_resolve_callback(const uint32_t min_ttl,
                                     const bool was_success,
@@ -86,7 +92,7 @@ private:
     void stop_trying();
     void wait_timer_timeout_handler(const boost::system::error_code &error);
     void gather_results( const boost::net::dns::rr_list_t *answers,
-                         HostAddressVec *result_ips,
+                         std::vector<host_addr_pair> *result_ips,
                          std::vector<string_pair> *result_cnames,
                          std::vector<string_pair> *result_nameservers ) const;
 
@@ -107,6 +113,7 @@ private:
     boost::uuids::random_generator RandomIdGenerator;
     uint16_t RequestId;
     ResolverItem Recursor;
+    bool OperationCancelled;
 };
 
 #endif