Enhanced update logic to respect not activated hostnames. If a hostname could not...
[bpdyndnsd] / src / service.cpp
index f8279ae..45d833e 100644 (file)
@@ -25,6 +25,7 @@ Service::Service()
     , Password("NOT SERIALIZED")
     , ActualIP("0.0.0.0")
     , ActualIPIsBurnt(false)
+    , Activated(false)
     , UpdateInterval(15)
     , MaxUpdatesWithinInterval(3)
     , MaxEqualUpdatesInSuccession(2)
@@ -297,6 +298,10 @@ void Service::update(const string& ip, const time_t current_time, bool changed_t
 
         UpdateErrorCode update_res = perform_update(ip);
 
+        // If update result is other than Generic or NotAuth, we assume that the hostname is activated.
+        if ( (update_res != GenericError) && (update_res != NotAuth) )
+            set_activated();
+
         if (update_res == UpdateOk)
         {
             // if update was successful, we need to set the Lastupdated and ActualIP base member.
@@ -483,3 +488,23 @@ void Service::set_dns_cache_ttl(const int _dns_cache_ttl)
 {
     DNSCacheTTL = _dns_cache_ttl;
 }
+
+
+/**
+ * Get member Activated
+ * @return Activated
+ */
+bool Service::get_activated() const
+{
+    return Activated;
+}
+
+
+/**
+ * Set member Activated
+ * @param _activated Activated
+ */
+void Service::set_activated()
+{
+    Activated = true;
+}