completed partial IPv6 compatibility in DNS; does retrieve and Cache IPv6 IPs
[pingcheck] / src / dns / dnscache.h
index 9268c77..e1ed495 100644 (file)
 #include <boost/archive/xml_iarchive.hpp>
 
 #include "host/pinger.h"    // for IoserviceItem
+#include "dns/dnsipprotocol.h"
 #include "dns/hostaddress.h"
 #include "dns/cname.h"
 
 typedef std::vector<HostAddress> HostAddressVec;
-typedef std::map<std::string, HostAddressVec> ip_map_type;
-typedef std::map<std::string, Cname> cname_map_type;
+typedef std::pair<std::string, DnsIpProtocol> ip_map_key_type;
+typedef std::map<ip_map_key_type, HostAddressVec> ip_map_type;
+typedef std::string cname_map_key_type;
+typedef std::map<cname_map_key_type, Cname> cname_map_type;
 
 // -----------------------------------------------------------------------------
 // DnsCache
@@ -56,15 +59,20 @@ public:
     ~DnsCache();
 
     // accessed from ResolverBase subclasses
-    void update(const std::string &hostname, const HostAddressVec &new_ips);
-    void update(const std::string &hostname, const Cname &cname);
+    void update(const std::string &hostname,
+                const DnsIpProtocol &protocol,
+                const HostAddressVec &new_ips);
+    void update(const std::string &hostname,
+                const Cname &cname);
 
     // retrieval
     HostAddressVec get_ips(const std::string &hostname,
+                           const DnsIpProtocol &protocol,
                            const bool check_up_to_date=false);
     Cname get_cname(const std::string &hostname,
-                     const bool check_up_to_date=false);
+                    const bool check_up_to_date=false);
     HostAddressVec get_ips_recursive(const std::string &hostname,
+                                     const DnsIpProtocol &protocol,
                                      const bool check_up_to_date=false);
     std::string get_first_outdated_cname(const std::string &hostname,
                                          const uint32_t ttl_thresh);
@@ -83,7 +91,9 @@ private:
     void schedule_save(const boost::system::error_code &error);
     void save_to_cachefile();
     void load_from_cachefile();
-    std::string key_for_hostname(const std::string &hostname) const;
+    ip_map_key_type key_for_ips(const std::string &hostname,
+                                const DnsIpProtocol &protocol) const;
+    cname_map_key_type key_for_cname(const std::string &hostname) const;
 
 };