Dyndns: Better handling for nochg and abuse return codes: Log them as unsuccessful...
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 31 Jan 2011 14:35:35 +0000 (15:35 +0100)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 31 Jan 2011 14:35:35 +0000 (15:35 +0100)
src/service.cpp
src/service_dyndns.cpp

index 1bab19b..3eebff0 100644 (file)
@@ -280,7 +280,9 @@ void Service::update(const string& ip, const time_t current_time, bool changed_t
     {
         Log->print_update_service(service_name);
 
-        if ( perform_update(ip) == UpdateOk )
+        UpdateErrorCode update_res = perform_update(ip);
+
+        if (update_res == UpdateOk)
         {
             // if update was successful, we need to set the Lastupdated and ActualIP base member.
             set_last_update(current_time,ip);
@@ -292,6 +294,13 @@ void Service::update(const string& ip, const time_t current_time, bool changed_t
         }
         else
         {
+            if (update_res == NoChange || update_res == Blocked)
+            {
+                // Log update for burnt IP logic and update "ActualIP" of this service
+                set_last_update(current_time,ip);
+                ActualIP = ip;
+            }
+
             // problem while trying to update service
             Log->print_update_service_failure(service_name);
 
index 5d7b8b8..4dc4789 100644 (file)
@@ -134,14 +134,14 @@ Service::UpdateErrorCode ServiceDyndns::perform_update(const std::string& ip)
             // IP didn't change, this might indicate a problem at the
             // dyndns backend or another client is running elsewhere.
             get_logger()->print_update_failure(url, curl_data);
-            return UpdateOk;
+            return NoChange;
         }
         else if (curl_data.compare(0,5,"abuse") == 0 )
         {
             // Account is blocked. Log it as a successful update
             // so the IP address will be "burnt" until it changes.
             get_logger()->print_update_failure(url, curl_data);
-            return UpdateOk;
+            return Blocked;
         }
         else if ( curl_data == "badauth" )
         {