Fix 'occurred' typo
[bpdyndnsd] / src / updater.cpp
index 5d32d10..7c3b021 100644 (file)
@@ -215,6 +215,8 @@ void Updater::init_log_facility() const
 {
     Log->set_log_facility(Conf->get_loglevel(),Conf->get_syslog(),Conf->get_external_warning_log(),Conf->get_external_warning_level(),Conf->get_external_log_only_once());
     Log->print_init_log_facility();
+
+    Log->set_log_passwords(Conf->get_log_passwords());
 }
 
 
@@ -242,12 +244,10 @@ void Updater::update_services(bool changed_to_online) const
     {
         string ip_last_update = service->get_actual_ip();
         string hostname = service->get_hostname();
-        time_t lastupdated = 0;
         time_t current_time = time(NULL);
 
-        // Try to get the lastupdated time of the actual service if there is one.
-        if ( !service->get_last_updates().empty() )
-            lastupdated = service->get_last_updates().front(); /*lint !e1793 */
+        // Get the last update time of the service.
+        time_t lastupdated = service->get_last_update_time();
 
         Log->print_check_service_update(hostname, current_time, lastupdated);
 
@@ -257,7 +257,8 @@ void Updater::update_services(bool changed_to_online) const
         Log->print_cached_dns_entry(hostname, ip_dns_recheck, ip_last_update, ip_host);
 
         // Test if the DNS-Record could not be found.
-        if ( ip_dns_recheck.empty() )
+        // If DNS-Record was not found but service was not activated, the hostname could be deactivated, offline or not existent. In this case try a ordinary update.
+        if ( ip_dns_recheck.empty() && service->get_activated() )
         {
             Log->print_dns_lookup_failed(changed_to_online, hostname);
             continue;
@@ -275,7 +276,16 @@ void Updater::update_services(bool changed_to_online) const
         if ( ip_last_update != ip_host )
         {
             // Update
-            Log->print_update_service(hostname, ip_dns_recheck, ip_last_update, ip_host, lastupdated);
+            if ( !ip_dns_recheck.empty() )
+            {
+                Log->print_update_service(hostname, ip_dns_recheck, ip_last_update, ip_host, lastupdated);
+            }
+            else
+            {
+                // Service gets updated the first time and no DNS-Record was found. This is either a initial update or the hostname is really not available.
+                Log->print_update_service(hostname, "<NO IP SET>", ip_last_update, ip_host, lastupdated);
+            }
+
             service->update(ip_host, current_time, changed_to_online);
         }
         else