Next steps in fine tuning.
authorBjoern Sikora <bjoern.sikora@intra2net.com>
Wed, 12 May 2010 14:36:17 +0000 (16:36 +0200)
committerBjoern Sikora <bjoern.sikora@intra2net.com>
Wed, 12 May 2010 14:36:17 +0000 (16:36 +0200)
12 files changed:
src/httphelper.cpp
src/httphelper.h
src/ip_addr_helper.cpp
src/ip_addr_helper.h
src/logger.cpp
src/logger.h
src/service_dyndns.cpp
src/service_dyns.cpp
src/service_easydns.cpp
src/service_gnudip.cpp
src/service_tzo.cpp
src/service_zoneedit.cpp

index 645a99d..8b8369f 100644 (file)
@@ -174,7 +174,7 @@ CURL* HTTPHelper::init_curl(string& curl_writedata_buff,char* curl_err_buff)
     {
         // Some options could not be set, so destroy the CURL handle.
         Log->print_curl_error_init("Could not set CURL options properly.",CurlError);
-        curl_easy_cleanup(CurlEasyHandle);
+        curl_easy_cleanup(curl_easy_handle);
         curl_easy_handle = NULL;
     }
 
@@ -232,7 +232,7 @@ void HTTPHelper::set_curl_auth(const string& username, const string& password)
  * @param outBuffer Pointer to output stream.
  * @return The size received.
  */
-int HTTPHelper::http_receive( char *inBuffer, size_t size, size_t nmemb, string *outBuffer )
+size_t HTTPHelper::http_receive( const char *inBuffer, size_t size, size_t nmemb, string *outBuffer )
 {
     outBuffer->append(inBuffer);
     return (size*nmemb);
index 6436ac8..dd08dd4 100644 (file)
@@ -53,7 +53,7 @@ public:
     bool is_initialized();
 
     // libcurl is a C library, so we have to make the callback member function static :-(
-    static int http_receive(char *inBuffer, size_t size, size_t nmemb, std::string *outBuffer);
+    static size_t http_receive(const char *inBuffer, size_t size, size_t nmemb, std::string *outBuffer);
 };
 
 #endif
index 3f9365f..5a02737 100644 (file)
@@ -198,10 +198,11 @@ string IPAddrHelper::get_actual_ip()
  * Get the IP address of the local wan interface if there is one.
  * @return The IP address of the wan interface or an empty string if something went wrong.
  */
-string IPAddrHelper::get_local_wan_nic_ip()
+string IPAddrHelper::get_local_wan_nic_ip() const
 {
     struct ifaddrs *if_addr_struct, *ifa;
-    int address_family, ret_val;
+    unsigned short address_family;
+    int ret_val;
     char ip_addr_buff[NI_MAXHOST];
     list<string> external_ipv4_addresses;
     list<string> external_ipv6_addresses;
@@ -244,7 +245,7 @@ string IPAddrHelper::get_local_wan_nic_ip()
                 Log->print_ip_is_local(ipv4_addr);
         }
         // If it is an IPv6 address and IPv6 is enabled then process further.
-        else if ( (address_family == AF_INET6) && (UseIPv6 == true) )
+        else if ( (address_family == AF_INET6) && (UseIPv6) )
         {
             // Translate the address to a protocol independent representation (dottet format). Copy address into ip_addr_buff.
             ret_val = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in6), ip_addr_buff, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
@@ -270,7 +271,7 @@ string IPAddrHelper::get_local_wan_nic_ip()
     freeifaddrs(if_addr_struct);
 
     // Return the first element in IPv6 list if IPv6 is enabled, otherwise return first element in IPv4 list.
-    if ( (UseIPv6 == true) && (!external_ipv6_addresses.empty()) )
+    if ( (UseIPv6) && (!external_ipv6_addresses.empty()) )
         return external_ipv6_addresses.front();
     else if ( !external_ipv4_addresses.empty() )
         return external_ipv4_addresses.front();
@@ -329,7 +330,7 @@ string IPAddrHelper::dns_query(const string& _hostname) const
                     Log->print_ip_is_local(ipv4_addr);
             }
             // Test if it is a IPv6 address and if IPv6 is enabled.
-            else if ( (ip.is_v6()) && (UseIPv6 == true) )
+            else if ( (ip.is_v6()) && (UseIPv6) )
             {
                 // Get the string representation.
                 string ipv6_addr = ip.to_string();
@@ -346,14 +347,14 @@ string IPAddrHelper::dns_query(const string& _hostname) const
         }
         io_service.reset();
     }
-    catch(exception& e)
+    catch(const exception& e)
     {
         Log->print_error_hostname_to_ip(e.what(),hostname);
         return "";
     }
 
     // Return the first element in IPv6 list if IPv6 is enabled, otherwise return first element in IPv4 list.
-    if ( (UseIPv6 == true) && (!external_ipv6_addresses.empty()) )
+    if ( (UseIPv6) && (!external_ipv6_addresses.empty()) )
         return external_ipv6_addresses.front();
     else if ( !external_ipv4_addresses.empty() )
         return external_ipv4_addresses.front();
@@ -373,7 +374,7 @@ string IPAddrHelper::webcheck_ip()
     string ip_addr = "";
 
     // Get the current time.
-    int current_time = time(NULL);
+    time_t current_time = time(NULL);
 
     // Test if webcheck is allowed due to webcheck_interval.
     if ( (LastWebcheck + (WebcheckInterval*60)) >= current_time )
@@ -396,6 +397,10 @@ string IPAddrHelper::webcheck_ip()
 
     // Init CURL
     CURL * curl_easy_handle = init_curl(curl_writedata_buff,curl_err_buff);
+    if ( curl_easy_handle == NULL )
+    {
+        return "";
+    }
 
     // If perform_curl_operation returns a connection problem indicating return code, try the next ip webcheck url if there is one.
     while ( (curl_err_code == 1) && (url_list.size() != 0) && (url_list.front() != "") )
@@ -488,10 +493,10 @@ string IPAddrHelper::parse_ipv4(const string& data) const
  * @param actual_url The actual configured URL.
  * @return 0 if all is fine, 1 if an connection problem to the configured url occurs, -1 on other errors.
  */
-int IPAddrHelper::perform_curl_operation(CURL * curl_easy_handle, char* curl_err_buff, const string& actual_url) const
+int IPAddrHelper::perform_curl_operation(CURL * curl_easy_handle, const char* curl_err_buff, const string& actual_url) const
 {
-    int curl_err_code;
-    if ( (curl_err_code = curl_easy_perform(curl_easy_handle) ) != 0 )
+    CURLcode curl_err_code;
+    if ( (curl_err_code = curl_easy_perform(curl_easy_handle) ) != CURLE_OK )
     {
         // CURL error occured
         if ( (curl_err_code == CURLE_COULDNT_CONNECT) || (curl_err_code == CURLE_OPERATION_TIMEOUTED) || (curl_err_code == CURLE_COULDNT_RESOLVE_HOST) )
@@ -531,20 +536,49 @@ void IPAddrHelper::set_curl_url(CURL * curl_easy_handle, const string& url) cons
  */
 CURL * IPAddrHelper::init_curl(string& curl_writedata_buff,char* curl_err_buff) const
 {
+    string user_agent = "Bullet Proof DYNDNS Daemon 0.1.1 - Intra2net AG 2009";
+
     CURL *curl_easy_handle = curl_easy_init();
+    if ( curl_easy_handle == NULL )
+    {
+        // something went wrong.
+        Log->print_curl_error_init("Could not initialize CURL object.",CURLE_FAILED_INIT);
+        return NULL;
+    }
 
-    curl_easy_setopt(curl_easy_handle,CURLOPT_NOPROGRESS,1);
-    curl_easy_setopt(curl_easy_handle,CURLOPT_CONNECTTIMEOUT,5);
-    curl_easy_setopt(curl_easy_handle,CURLOPT_TIMEOUT,10);
-    curl_easy_setopt(curl_easy_handle,CURLOPT_BUFFERSIZE,1024);
-    curl_easy_setopt(curl_easy_handle,CURLOPT_ERRORBUFFER,curl_err_buff);
-    curl_easy_setopt(curl_easy_handle,CURLOPT_WRITEFUNCTION,http_receive);
-    curl_easy_setopt(curl_easy_handle,CURLOPT_WRITEDATA,&curl_writedata_buff);
+    CURLcode curlError = CURLE_OK;
+
+    if ( curlError == CURLE_OK )
+        curlError = curl_easy_setopt(curl_easy_handle,CURLOPT_NOPROGRESS,1);
+    if ( curlError == CURLE_OK)
+        curlError = curl_easy_setopt(curl_easy_handle,CURLOPT_CONNECTTIMEOUT,5);
+    if ( curlError == CURLE_OK)
+        curlError = curl_easy_setopt(curl_easy_handle,CURLOPT_TIMEOUT,10);
+    if ( curlError == CURLE_OK)
+        curlError = curl_easy_setopt(curl_easy_handle,CURLOPT_BUFFERSIZE,1024);
+    if ( curlError == CURLE_OK)
+        curlError = curl_easy_setopt(curl_easy_handle,CURLOPT_ERRORBUFFER,curl_err_buff);
+    if ( curlError == CURLE_OK)
+        curlError = curl_easy_setopt(curl_easy_handle,CURLOPT_WRITEFUNCTION,http_receive);
+    if ( curlError == CURLE_OK)
+        curlError = curl_easy_setopt(curl_easy_handle,CURLOPT_WRITEDATA,&curl_writedata_buff);
+    if ( curlError == CURLE_OK)
+        curlError = curl_easy_setopt(curl_easy_handle,CURLOPT_USERAGENT,&user_agent);
 
     if ( !Proxy.empty() )
     {
-        curl_easy_setopt(curl_easy_handle,CURLOPT_PROXY,Proxy.c_str());
-        curl_easy_setopt(curl_easy_handle,CURLOPT_PROXYPORT,ProxyPort);
+        if ( curlError == CURLE_OK)
+            curlError = curl_easy_setopt(curl_easy_handle,CURLOPT_PROXY,Proxy.c_str());
+        if ( curlError == CURLE_OK)
+            curlError = curl_easy_setopt(curl_easy_handle,CURLOPT_PROXYPORT,ProxyPort);
+    }
+
+    if ( curlError != CURLE_OK )
+    {
+        // Some options could not be set, so destroy the CURL handle.
+        Log->print_curl_error_init("Could not set CURL options properly.",curlError);
+        curl_easy_cleanup(curl_easy_handle);
+        curl_easy_handle = NULL;
     }
 
     return curl_easy_handle;
@@ -559,7 +593,7 @@ CURL * IPAddrHelper::init_curl(string& curl_writedata_buff,char* curl_err_buff)
  * @param outBuffer Pointer to output stream.
  * @return The size received.
  */
-int IPAddrHelper::http_receive( char *inBuffer, size_t size, size_t nmemb, string *outBuffer )
+size_t IPAddrHelper::http_receive( const char *inBuffer, size_t size, size_t nmemb, string *outBuffer )
 {
     outBuffer->append(inBuffer);
     return (size*nmemb);
index 45d970a..f8fcaf1 100644 (file)
@@ -45,7 +45,7 @@ private:
     bool is_local_ipv6(const std::string ip) const;
     std::string webcheck_ip();
     CURL * init_curl(std::string& curl_writedata_buff, char* curl_err_buff) const;
-    int perform_curl_operation(CURL * curl_easy_handle, char* curl_err_buff, const std::string& actual_url) const;
+    int perform_curl_operation(CURL * curl_easy_handle, const char* curl_err_buff, const std::string& actual_url) const;
     std::string parse_ipv4(const std::string& data) const;
 
 public:
@@ -62,10 +62,10 @@ public:
 
     std::string get_actual_ip();
 
-    std::string get_local_wan_nic_ip();
+    std::string get_local_wan_nic_ip() const;
 
     // libcurl is a C library, so we have to make the callback member function static :-(
-    static int http_receive(char *inBuffer, size_t size, size_t nmemb, std::string *outBuffer);
+    static size_t http_receive(const char *inBuffer, size_t size, size_t nmemb, std::string *outBuffer);
 
     void set_curl_url(CURL * curl_easy_handle, const std::string& url) const;
 
index fa3fdf9..a898fd2 100644 (file)
@@ -50,7 +50,7 @@ Logger::~Logger()
  * Decides if Logging through syslog if enabled or through std.
  * @param msg The message to log.
  */
-void Logger::log_notice(const string& msg, int level) const
+void Logger::log_notice(const string& msg) const
 {
     if ( Syslog )
         syslog(LOG_NOTICE,msg.c_str());
@@ -87,7 +87,7 @@ void Logger::log_warning(const string& msg, int level) const
  * Decides if Logging through syslog if enabled or through std.
  * @param msg The message to log.
  */
-void Logger::log_error(const string& msg, int level) const
+void Logger::log_error(const string& msg) const
 {
     if ( Syslog )
         syslog(LOG_ERR,msg.c_str());
@@ -164,7 +164,7 @@ void Logger::print_usage(const Options_descriptionPtr opt_desc) const
         ostringstream msg;
         msg << "Usage: bpdyndnsd [Command line options]" << "\n" << endl;
         msg << *opt_desc << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -180,7 +180,7 @@ void Logger::print_version() const
     {
         ostringstream msg;
         msg << "Bullet proof dynamic dns daemon.\nbpdyndnsd " << VERSION << "." << REVISION << "." << RELEASE << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -193,7 +193,7 @@ void Logger::print_cmd_parsed() const
     int level = 1;
     if ( level <= Loglevel )
     {
-        log_notice("Command line options successfully parsed.",level);
+        log_notice("Command line options successfully parsed.");
     }
 }
 
@@ -203,7 +203,7 @@ void Logger::print_conf_files_parsed() const
     int level = 1;
     if ( level <= Loglevel )
     {
-        log_notice("Config files successfully parsed.",level);
+        log_notice("Config files successfully parsed.");
     }
 }
 
@@ -219,7 +219,7 @@ void Logger::print_conf_loaded(const string& config_path) const
     {
         ostringstream msg;
         msg << "Config files successfully loaded in: " << config_path << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -235,7 +235,7 @@ void Logger::print_conf_not_loaded(const string& config_path) const
     {
         ostringstream msg;
         msg << "Config files couldn't be loaded in: " << config_path << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -251,7 +251,7 @@ void Logger::print_error_opening_r(const string& filename) const
     {
         ostringstream msg;
         msg << "Error opening file for reading: " << filename << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -267,7 +267,7 @@ void Logger::print_error_opening_rw(const string& filename) const
     {
         ostringstream msg;
         msg << "Error opening file for writing: " << filename << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -283,7 +283,7 @@ void Logger::print_destructor_call(const string& _class) const
     {
         ostringstream msg;
         msg << "Destructor call: " << _class << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -299,7 +299,7 @@ void Logger::print_constructor_call(const string& _class) const
     {
         ostringstream msg;
         msg << "Constructor call: " << _class << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -315,7 +315,7 @@ void Logger::print_update_service(const string& service) const
     {
         ostringstream msg;
         msg << "Running update for service: " << service << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -331,7 +331,7 @@ void Logger::print_unknown_cmd_option(const string& unknown_option) const
     {
         ostringstream msg;
         msg << "Unknown option on command line detected: " << unknown_option << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -347,7 +347,7 @@ void Logger::print_unknown_protocol(const string& protocol) const
     {
         ostringstream msg;
         msg << "Unknown protocol defined: " << protocol << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -363,7 +363,7 @@ void Logger::print_load_service_conf(const string& filename) const
     {
         ostringstream msg;
         msg << "Loading service config file: " << filename << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -379,7 +379,7 @@ void Logger::print_load_main_conf(const string& filename) const
     {
         ostringstream msg;
         msg << "Loading main config file: " << filename << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -395,7 +395,7 @@ void Logger::print_unknown_service_conf_option(const string& service_conf_file,
     {
         ostringstream msg;
         msg << "Unknown option in service config file detected: " << service_conf_file << " Unknown option: " << unknown_option << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -411,7 +411,7 @@ void Logger::print_unknown_main_conf_option(const string& unknown_option) const
     {
         ostringstream msg;
         msg << "Unknown option in main config file detected: " << unknown_option << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -427,7 +427,7 @@ void Logger::print_error_config_path(const string& config_path) const
     {
         ostringstream msg;
         msg << "Config path doesn't exists or is not a diretory: " << config_path << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -440,7 +440,7 @@ void Logger::print_missing_cmd_service_option() const
     int level = 0;
     if ( level <= Loglevel )
     {
-        log_error("Missing option to initialize service. Protocol, host, login and password must be specified.",level);
+        log_error("Missing option to initialize service. Protocol, host, login and password must be specified.");
     }
 }
 
@@ -456,7 +456,7 @@ void Logger::print_missing_service_conf_option(const string& service_conf_file)
     {
         ostringstream msg;
         msg << "Missing option in service config file " << service_conf_file << " to initialize service. Protocol, host, login and password must be specified." << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -472,7 +472,7 @@ void Logger::print_runnig_as_daemon(const int pid) const
     {
         ostringstream msg;
         msg << "Runnig as daemon: " << pid << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -491,7 +491,7 @@ void Logger::print_daemon_mode(const bool daemon_mode) const
             mode = "enabled";
         ostringstream msg;
         msg << "Daemon mode is " << mode << "." << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -504,7 +504,7 @@ void Logger::print_error_fork() const
     int level = 0;
     if ( level <= Loglevel )
     {
-        log_error("Error while trying to fork.",level);
+        log_error("Error while trying to fork.");
     }
 }
 
@@ -520,7 +520,7 @@ void Logger::print_pid_found(const int pid) const
     {
         ostringstream msg;
         msg << "Pidfile found: " << pid << ". Checking if process is still runnig..." << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -536,7 +536,7 @@ void Logger::print_process_already_running(const int pid) const
     {
         ostringstream msg;
         msg << "Another bpdyndnsd process with PID " << pid << " is already running!" << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -549,7 +549,7 @@ void Logger::print_caught_sigterm() const
     int level = 0;
     if ( level <= Loglevel )
     {
-        log_notice("Caught SIGTERM. Exiting...",level);
+        log_notice("Caught SIGTERM. Exiting...");
     }
 }
 
@@ -562,7 +562,7 @@ void Logger::print_caught_siguser1() const
     int level = 0;
     if ( level <= Loglevel )
     {
-        log_notice("Caught SIGUSR1. Switching to offline mode...",level);
+        log_notice("Caught SIGUSR1. Switching to offline mode...");
     }
 }
 
@@ -575,7 +575,7 @@ void Logger::print_caught_sighup() const
     int level = 1;
     if ( level <= Loglevel )
     {
-        log_notice("Caught SIGHUP. Reloading config and switching to online mode...",level);
+        log_notice("Caught SIGHUP. Reloading config and switching to online mode...");
     }
 }
 
@@ -590,7 +590,7 @@ void Logger::print_error_setting_signal(const string& signal) const
     {
         ostringstream msg;
         msg << "Error while setting signal handler for: " << signal << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -605,7 +605,7 @@ void Logger::print_init_log_facility() const
     {
         ostringstream msg;
         msg << "Initialized logging facility." << " Loglevel: " << Loglevel << " Syslog: " << Syslog << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -618,7 +618,7 @@ void Logger::print_offline_mode() const
     int level = 0;
     if ( level <= Loglevel )
     {
-        log_notice("Offline mode...",level);
+        log_notice("Offline mode...");
     }
 }
 
@@ -631,7 +631,7 @@ void Logger::print_serialized_objects_success() const
     int level = 1;
     if ( level <= Loglevel )
     {
-        log_notice("Serialized objects successfully.",level);
+        log_notice("Serialized objects successfully.");
     }
 }
 
@@ -644,7 +644,7 @@ void Logger::print_deserialized_objects_success() const
     int level = 1;
     if ( level <= Loglevel )
     {
-        log_notice("De-serialized objects successfully.",level);
+        log_notice("De-serialized objects successfully.");
     }
 }
 
@@ -678,7 +678,7 @@ void Logger::print_service_object(const string& message, const string& protocol,
         {
             msg << "\t" << "Lastupdated:      " << update_time << endl;
         }
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -687,14 +687,14 @@ void Logger::print_service_object(const string& message, const string& protocol,
  * Caught exception while serialize.
  * @param exception Exception message.
  */
-void Logger::print_exception_serialize(const string& exception) const
+void Logger::print_exception_serialize(const string& errMsg) const
 {
     int level = 0;
     if ( level <= Loglevel )
     {
         ostringstream msg;
-        msg << "Error while trying to serialize Serviceholder object: " << exception << endl;
-        log_error(msg.str(),level);
+        msg << "Error while trying to serialize Serviceholder object: " << errMsg << endl;
+        log_error(msg.str());
     }
 }
 
@@ -703,14 +703,14 @@ void Logger::print_exception_serialize(const string& exception) const
  * Caught exception while de-serialize.
  * @param exception Exception message.
  */
-void Logger::print_exception_deserialize(const string& exception) const
+void Logger::print_exception_deserialize(const string& errMsg) const
 {
     int level = 0;
     if ( level <= Loglevel )
     {
         ostringstream msg;
-        msg << "Error while trying to de-serialize Serviceholder object: " << exception << endl;
-        log_error(msg.str(),level);
+        msg << "Error while trying to de-serialize Serviceholder object: " << errMsg << endl;
+        log_error(msg.str());
     }
 }
 
@@ -726,7 +726,7 @@ void Logger::print_error_kill_child(const int pid) const
     {
         ostringstream msg;
         msg << "Could not kill child process with PID: " << pid << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -742,7 +742,7 @@ void Logger::print_child_killed(const int pid) const
     {
         ostringstream msg;
         msg << "Killed child process with PID: " << pid << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -774,7 +774,7 @@ void Logger::print_hostname(const string& hostname) const
     {
         ostringstream msg;
         msg << "Detected following hostname of localhost: " << hostname << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -790,7 +790,7 @@ void Logger::print_own_ipv4(const string& ip_addr_v4, const string& hostname) co
     {
         ostringstream msg;
         msg << "Detected following IPv4-Address of host: " << hostname << " : " << ip_addr_v4 << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -806,7 +806,7 @@ void Logger::print_own_ipv6(const string& ip_addr_v6, const string& hostname) co
     {
         ostringstream msg;
         msg << "Detected following IPv6-Address of host: " << hostname << " : " << ip_addr_v6 << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -816,13 +816,13 @@ void Logger::print_own_ipv6(const string& ip_addr_v6, const string& hostname) co
  * @param exception The exception caught.
  * @param hostname The hostname.
  */
-void Logger::print_error_hostname_to_ip(const string& exception, const string& hostname) const
+void Logger::print_error_hostname_to_ip(const string& errMsg, const string& hostname) const
 {
     int level = 0;
     if ( level <= Loglevel )
     {
         ostringstream msg;
-        msg << "Could not resolve the hostname: " << hostname << " to an IP-Address: " << exception << endl;
+        msg << "Could not resolve the hostname: " << hostname << " to an IP-Address: " << errMsg << endl;
         log_warning(msg.str(),level);
     }
 }
@@ -839,7 +839,7 @@ void Logger::print_update_service_successful(const string& service) const
     {
         ostringstream msg;
         msg << "Updated service successful: " << service << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -886,7 +886,7 @@ void Logger::print_webcheck_error(const char * curl_err_buff, const string& url)
     {
         ostringstream msg;
         msg << "There was an error while trying to connect to following URL: " << url << " CURL error: " << curl_err_buff << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -902,7 +902,7 @@ void Logger::print_received_curl_data(const string& curl_data) const
     {
         ostringstream msg;
         msg << "Received CURL data: " << curl_data << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -918,7 +918,7 @@ void Logger::print_regex_found_ip(const string& ip) const
     {
         ostringstream msg;
         msg << "Found IP-Address via regex: " << ip << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -950,7 +950,7 @@ void Logger::print_multiple_cmd_option(const string& message) const
     {
         ostringstream msg;
         msg << "The same option is only allowed once: " << message << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -998,7 +998,7 @@ void Logger::print_starting_shutdown() const
     int level = 0;
     if ( level <= Loglevel )
     {
-        log_notice("Shutting down ...",level);
+        log_notice("Shutting down ...");
     }
 }
 
@@ -1011,7 +1011,7 @@ void Logger::print_shutdown_succeeded() const
     int level = 0;
     if ( level <= Loglevel )
     {
-        log_notice("Shutting down complete ...",level);
+        log_notice("Shutting down complete ...");
     }
 }
 
@@ -1024,7 +1024,7 @@ void Logger::print_shutdown_parent_succeeded() const
     int level = 0;
     if ( level <= Loglevel )
     {
-        log_notice("Shutting down parent process completed ...",level);
+        log_notice("Shutting down parent process completed ...");
     }
 }
 
@@ -1037,7 +1037,7 @@ void Logger::print_starting_shutdown_parent() const
     int level = 0;
     if ( level <= Loglevel )
     {
-        log_notice("Shutting down parent process ...",level);
+        log_notice("Shutting down parent process ...");
     }
 }
 
@@ -1056,7 +1056,7 @@ void Logger::print_recheck_dns_entry(const string& hostname, const int lastupdat
     {
         ostringstream msg;
         msg << "DNS cache record for host <" << hostname << "> expired or host will be updated for the first time: Lastupdated: " << lastupdated << " DNS cache ttl: " << dns_cache_ttl << " Current time: " << current_time << " Checking current DNS cache status." << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -1069,7 +1069,7 @@ void Logger::print_missing_cmd_proxy_option() const
     int level = 0;
     if ( level <= Loglevel )
     {
-        log_error("Missing option to initialize proxy. http_proxy and http_proxy_port must be specified.",level);
+        log_error("Missing option to initialize proxy. http_proxy and http_proxy_port must be specified.");
     }
 }
 
@@ -1086,7 +1086,7 @@ void Logger::print_multiple_service_conf_option(const string& service_conf_file,
     {
         ostringstream msg;
         msg << "Multiple occurrences of the same option in service config file detected: " << service_conf_file << " " << message << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -1103,7 +1103,7 @@ void Logger::print_multiple_main_conf_option(const string& main_conf_file, const
     {
         ostringstream msg;
         msg << "Multiple occurrences of the same option in main config file detected: " << main_conf_file << " " << message << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -1119,7 +1119,7 @@ void Logger::print_missing_conf_proxy_option(const string& main_conf_filename) c
     {
         ostringstream msg;
         msg << "Missing option to initialize proxy in main config file: " << main_conf_filename << " http_proxy and http_proxy_port must be specified." << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -1135,7 +1135,7 @@ void Logger::print_no_domain_part(const string& hostname) const
     {
         ostringstream msg;
         msg << "There is no domain part in the given hostname: " << hostname << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -1175,7 +1175,7 @@ void Logger::print_curl_error_init(const std::string& msg, const CURLcode curl_e
     {
         ostringstream msg;
         msg << "Curl error: " << msg << " Curl error code: " << curl_err_code << " "<< curl_err << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -1248,7 +1248,7 @@ void Logger::print_curl_data(const string& curl_writedata_buff) const
     {
         ostringstream msg;
         msg << "Data received by curl: " << curl_writedata_buff << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -1283,7 +1283,7 @@ void Logger::print_http_status_code(const string& url, const long http_code) con
     {
         ostringstream msg;
         msg << "Requested URL: " << url << " Received HTTP status code: " << http_code << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -1365,7 +1365,7 @@ void Logger::print_regex_match(const string& regex, const string& matching_strin
     {
         ostringstream msg;
         msg << "Regex: " << regex << " is matching in: " << matching_string << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -1441,7 +1441,7 @@ void Logger::print_exception_md5_sum(const string& what) const
     {
         ostringstream msg;
         msg << "An exception occured while computing a md5 sum: " << what << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -1457,7 +1457,7 @@ void Logger::print_network_error(const string& what) const
     {
         ostringstream msg;
         msg << "An netowrk exception occured: " << what << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -1474,7 +1474,7 @@ void Logger::print_undefined_protocol_error(const string& protocol, const string
     {
         ostringstream msg;
         msg << "An undefined protocol error occured. Protocol: " << protocol << " Error: " << error << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -1489,7 +1489,7 @@ void Logger::print_error_external_logging(const string& external_prog) const
     {
         ostringstream msg;
         msg << "Error while trying to log through external program: " << external_prog << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -1506,7 +1506,7 @@ void Logger::print_error_parsing_config_file(const string& filename, const strin
     {
         ostringstream msg;
         msg << "Error while parsing config file: " << filename << " Error: " << error << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -1522,7 +1522,7 @@ void Logger::print_error_parsing_cmd(const string& error) const
     {
         ostringstream msg;
         msg << "Error while parsing cmd options: " << error << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -1533,14 +1533,14 @@ void Logger::print_error_parsing_cmd(const string& error) const
  * @param webcheck_interval Webcheck interval time.
  * @param current_time Current system time.
  */
-void Logger::print_webcheck_exceed_interval( const int last_webcheck, const int webcheck_interval, const int current_time ) const
+void Logger::print_webcheck_exceed_interval( const int last_webcheck, const int webcheck_interval, const time_t current_time ) const
 {
     int level = 0;
     if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Exceeding webcheck interval: LastWebcheck " << last_webcheck << " + WebcheckInterval(sec) " << webcheck_interval << " >= CurrentTime " << current_time << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -1558,7 +1558,7 @@ void Logger::print_check_service_update(const string& hostname, const int curren
     {
         ostringstream msg;
         msg << "Checking if host: " << hostname << " needs update. Current time: " << current_time << " Last updated: " << lastupdated << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -1577,7 +1577,7 @@ void Logger::print_cached_dns_entry(const string& hostname, const string& ip_dns
     {
         ostringstream msg;
         msg << "Cached DNS record for host <" << hostname << "> : " << ip_dns_recheck << " Last updated IP: " << ip_last_update << " Hosts IP: " << ip_host << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -1595,7 +1595,7 @@ void Logger::print_update_service_firttime(const string& hostname, const string&
     {
         ostringstream msg;
         msg << "Updating service for the first time. Hostname: " << hostname << " DNS-Record: " << ip_dns_recheck << " Hosts IP: " << ip_host << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -1614,7 +1614,7 @@ void Logger::print_update_service(const string& hostname, const string& ip_dns_r
     {
         ostringstream msg;
         msg << "Updating service. Hostname: " << hostname << " DNS-Record: " << ip_dns_recheck << " IP set in last update: " << ip_last_update << " Lastupdated: " << lastupdated << " Hosts IP: " << ip_host << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -1636,7 +1636,7 @@ void Logger::print_update_service_ttl_expired(const string& hostname, const stri
     {
         ostringstream msg;
         msg << "TTL for service expired and still pointing to old IP. Hostname: " << hostname << " DNS-Record: " << ip_dns_recheck << " IP set in last update: " << ip_last_update << " Lastupdated: " << lastupdated << "DNS Cache TTL: " << dns_cache_ttl << " Current Time: " << current_time << " Hosts IP: " << ip_host << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -1658,7 +1658,7 @@ void Logger::print_update_service_ttl_not_expired(const string& hostname, const
     {
         ostringstream msg;
         msg << "Waiting for DNS cache TTL to expire. Hostname: " << hostname << " DNS-Record: " << ip_dns_recheck << " IP set in last update: " << ip_last_update << " Lastupdated: " << lastupdated << "DNS Cache TTL: " << dns_cache_ttl << " Current Time: " << current_time << " Hosts IP: " << ip_host << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -1678,7 +1678,7 @@ void Logger::print_no_update_needed(const string& hostname, const string& ip_dns
     {
         ostringstream msg;
         msg << "No update needed for host: " << hostname << " Cached DNS record: " << ip_dns_recheck << " IP set in last update: " << ip_last_update << " Hosts IP: " << ip_host << " Last updated: " << lastupdated << endl;
-        log_notice(msg.str(),level);
+        log_notice(msg.str());
     }
 }
 
@@ -1695,7 +1695,7 @@ void Logger::print_error_getting_local_wan_ip(const std::string& system_call, co
     {
         ostringstream msg;
         msg << "Error while trying to get local wan interface IP address through '" << system_call << "': " << error << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
 
@@ -1710,6 +1710,6 @@ void Logger::print_no_wan_ip() const
     {
         ostringstream msg;
         msg << "Could not get IP address of local wan interface." << endl;
-        log_error(msg.str(),level);
+        log_error(msg.str());
     }
 }
index 0367832..f0e0ac0 100644 (file)
@@ -36,11 +36,11 @@ public:
 
     ~Logger();
 
-    void log_notice(const std::string& msg, int loglevel) const;
+    void log_notice(const std::string& msg) const;
 
     void log_warning(const std::string& msg, int loglevel) const;
 
-    void log_error(const std::string& msg, int loglevel) const;
+    void log_error(const std::string& msg) const;
 
     void set_loglevel(const int _loglevel);
 
@@ -120,9 +120,9 @@ public:
 
     void print_service_object(const std::string& message, const std::string& protocol, const std::string& hostname, const std::string& login, const std::string& password, const int update_interval, const int max_updates_within_interval, const int dns_cache_ttl , const std::string& actual_ip, std::list<int> lastupdated) const;
 
-    void print_exception_serialize(const std::string& exception) const;
+    void print_exception_serialize(const std::string& errMsg) const;
 
-    void print_exception_deserialize(const std::string& exception) const;
+    void print_exception_deserialize(const std::string& errMsg) const;
 
     void print_error_kill_child(const int pid) const;
 
@@ -136,7 +136,7 @@ public:
 
     void print_own_ipv6(const std::string& ip_addr_v6, const std::string& hostname) const;
 
-    void print_error_hostname_to_ip(const std::string& exception, const std::string& hostname) const;
+    void print_error_hostname_to_ip(const std::string& errMsg, const std::string& hostname) const;
 
     void print_update_service_successful(const std::string& service) const;
 
@@ -224,7 +224,7 @@ public:
 
     void print_error_parsing_cmd(const std::string& error) const;
 
-    void print_webcheck_exceed_interval( const int last_webcheck, const int webcheck_interval, const int current_time ) const;
+    void print_webcheck_exceed_interval( const int last_webcheck, const int webcheck_interval, const time_t current_time ) const;
 
     void print_check_service_update(const std::string& hostname, const int current_time, const int lastupdated) const;
 
index 3905e36..3f68d22 100644 (file)
@@ -53,8 +53,7 @@ ServiceDyndns::ServiceDyndns(const string& _protocol, const string& _hostname, c
     set_logger(_logger);
 
     // create http helper class
-    HTTPHelper::Ptr _http_help(new HTTPHelper(_logger,_proxy,_proxy_port,_login,_password));
-    HTTPHelp.swap(_http_help);
+    HTTPHelp = HTTPHelper::Ptr(new HTTPHelper(_logger,_proxy,_proxy_port,_login,_password));
 
     BaseUrl = assemble_base_url(get_hostname());
 }
index d3d917c..5948e06 100644 (file)
@@ -57,8 +57,7 @@ ServiceDyns::ServiceDyns(const string& _protocol, const string& _hostname, const
     set_logger(_logger);
 
     // create http helper class
-    HTTPHelper::Ptr _http_help(new HTTPHelper(_logger,_proxy,_proxy_port));
-    HTTPHelp.swap(_http_help);
+    HTTPHelp = HTTPHelper::Ptr(new HTTPHelper(_logger,_proxy,_proxy_port));
 
     BaseUrl = assemble_base_url(get_hostname(),get_login(),get_password());
 }
index 776277b..019cf34 100644 (file)
@@ -57,9 +57,7 @@ ServiceEasydns::ServiceEasydns(const string& _protocol, const string& _hostname,
     set_logger(_logger);
 
     // create http helper class
-    HTTPHelper::Ptr _http_help(new HTTPHelper(_logger,_proxy,_proxy_port,_login,_password));
-    HTTPHelp.swap(_http_help);
-    //HTTPHelp = HTTPHelper::Ptr(new HTTPHelper(_logger,_proxy,_proxy_port,_login,_password));
+    HTTPHelp = HTTPHelper::Ptr(new HTTPHelper(_logger,_proxy,_proxy_port,_login,_password));
 
     // extract domain part from hostname
     list<string> host_domain_part = separate_domain_and_host_part(get_hostname());
index 17c24b5..1e14149 100644 (file)
@@ -56,8 +56,7 @@ ServiceGnudip::ServiceGnudip(const string& _protocol, const string& _gnudip_serv
     set_logger(_logger);
 
     // create http helper class
-    HTTPHelper::Ptr _http_help(new HTTPHelper(_logger,_proxy,_proxy_port,_login,_password));
-    HTTPHelp.swap(_http_help);
+    HTTPHelp = HTTPHelper::Ptr(new HTTPHelper(_logger,_proxy,_proxy_port,_login,_password));
 
     BaseUrl = assemble_base_url(get_hostname(),_gnudip_server);
 }
index 27e062f..da8bd75 100644 (file)
@@ -57,8 +57,7 @@ ServiceTzo::ServiceTzo(const string& _protocol, const string& _hostname, const s
     set_logger(_logger);
 
     // create http helper class
-    HTTPHelper::Ptr _http_help(new HTTPHelper(_logger,_proxy,_proxy_port));
-    HTTPHelp.swap(_http_help);
+    HTTPHelp = HTTPHelper::Ptr(new HTTPHelper(_logger,_proxy,_proxy_port));
 
     BaseUrl = assemble_base_url(get_hostname(),get_login(),get_password());
 }
index ccae82b..e1d6d9e 100644 (file)
@@ -57,8 +57,7 @@ ServiceZoneedit::ServiceZoneedit(const string& _protocol, const string& _hostnam
     set_logger(_logger);
 
     // create http helper class
-    HTTPHelper::Ptr _http_help(new HTTPHelper(_logger,_proxy,_proxy_port));
-    HTTPHelp.swap(_http_help);
+    HTTPHelp = HTTPHelper::Ptr(new HTTPHelper(_logger,_proxy,_proxy_port));
 
     BaseUrl = assemble_base_url(get_hostname());
 }