From 4de6a9b800e14c0612a283ac3b4823136a0220a8 Mon Sep 17 00:00:00 2001 From: Bjoern Sikora Date: Mon, 7 Jun 2010 17:31:09 +0200 Subject: [PATCH] Renamed all header to end with hpp instead of h. --- src/CMakeLists.txt | 40 +++--- src/config.cpp | 18 ++-- src/config.h | 111 ---------------- src/httphelper.cpp | 6 +- src/httphelper.h | 59 -------- src/httphelper.hpp | 59 ++++++++ src/ip_addr_helper.cpp | 2 +- src/ip_addr_helper.h | 74 ---------- src/ip_addr_helper.hpp | 74 ++++++++++ src/ip_service.h | 36 ----- src/ip_service.hpp | 36 +++++ src/logger.cpp | 2 +- src/logger.h | 264 ------------------------------------- src/logger.hpp | 264 +++++++++++++++++++++++++++++++++++++ src/main.cpp | 2 +- src/net_helper.cpp | 4 +- src/net_helper.h | 47 ------- src/net_helper.hpp | 47 +++++++ src/serializeservicecontainer.cpp | 2 +- src/serializeservicecontainer.h | 62 --------- src/serializeservicecontainer.hpp | 62 +++++++++ src/service.cpp | 2 +- src/service.h | 109 --------------- src/service.hpp | 109 +++++++++++++++ src/service_dhs.cpp | 2 +- src/service_dhs.h | 54 -------- src/service_dhs.hpp | 54 ++++++++ src/service_dyndns.cpp | 2 +- src/service_dyndns.h | 53 -------- src/service_dyndns.hpp | 53 ++++++++ src/service_dyns.cpp | 4 +- src/service_dyns.h | 52 ------- src/service_dyns.hpp | 52 +++++++ src/service_easydns.cpp | 4 +- src/service_easydns.h | 57 -------- src/service_easydns.hpp | 57 ++++++++ src/service_gnudip.cpp | 4 +- src/service_gnudip.h | 57 -------- src/service_gnudip.hpp | 57 ++++++++ src/service_ods.cpp | 6 +- src/service_ods.h | 48 ------- src/service_ods.hpp | 48 +++++++ src/service_tzo.cpp | 4 +- src/service_tzo.h | 52 ------- src/service_tzo.hpp | 52 +++++++ src/service_zoneedit.cpp | 4 +- src/service_zoneedit.h | 52 ------- src/service_zoneedit.hpp | 52 +++++++ src/serviceholder.cpp | 2 +- src/serviceholder.h | 59 -------- src/serviceholder.hpp | 59 ++++++++ src/tcp_service.cpp | 2 +- src/tcp_service.h | 49 ------- src/tcp_service.hpp | 49 +++++++ src/updater.cpp | 8 +- src/updater.h | 66 --------- src/updater.hpp | 66 +++++++++ src/util.cpp | 2 +- src/util.h | 25 ---- src/util.hpp | 25 ++++ 60 files changed, 1336 insertions(+), 1447 deletions(-) delete mode 100644 src/config.h delete mode 100644 src/httphelper.h create mode 100644 src/httphelper.hpp delete mode 100644 src/ip_addr_helper.h create mode 100644 src/ip_addr_helper.hpp delete mode 100644 src/ip_service.h create mode 100644 src/ip_service.hpp delete mode 100644 src/logger.h create mode 100644 src/logger.hpp delete mode 100644 src/net_helper.h create mode 100644 src/net_helper.hpp delete mode 100644 src/serializeservicecontainer.h create mode 100644 src/serializeservicecontainer.hpp delete mode 100644 src/service.h create mode 100644 src/service.hpp delete mode 100644 src/service_dhs.h create mode 100644 src/service_dhs.hpp delete mode 100644 src/service_dyndns.h create mode 100644 src/service_dyndns.hpp delete mode 100644 src/service_dyns.h create mode 100644 src/service_dyns.hpp delete mode 100644 src/service_easydns.h create mode 100644 src/service_easydns.hpp delete mode 100644 src/service_gnudip.h create mode 100644 src/service_gnudip.hpp delete mode 100644 src/service_ods.h create mode 100644 src/service_ods.hpp delete mode 100644 src/service_tzo.h create mode 100644 src/service_tzo.hpp delete mode 100644 src/service_zoneedit.h create mode 100644 src/service_zoneedit.hpp delete mode 100644 src/serviceholder.h create mode 100644 src/serviceholder.hpp delete mode 100644 src/tcp_service.h create mode 100644 src/tcp_service.hpp delete mode 100644 src/updater.h create mode 100644 src/updater.hpp delete mode 100644 src/util.h create mode 100644 src/util.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 45cd5e6..195469e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -39,26 +39,26 @@ set(cpp_sources # C++ headers set(cpp_headers - config.h - httphelper.h - ip_addr_helper.h - ip_service.h - logger.h - net_helper.h - serializeservicecontainer.h - service_dhs.h - service_dyndns.h - service_dyns.h - service_easydns.h - service_gnudip.h - service.h - serviceholder.h - service_ods.h - service_tzo.h - service_zoneedit.h - tcp_service.h - updater.h - util.h + config.hpp + httphelper.hpp + ip_addr_helper.hpp + ip_service.hpp + logger.hpp + net_helper.hpp + serializeservicecontainer.hpp + service_dhs.hpp + service_dyndns.hpp + service_dyns.hpp + service_easydns.hpp + service_gnudip.hpp + service.hpp + serviceholder.hpp + service_ods.hpp + service_tzo.hpp + service_zoneedit.hpp + tcp_service.hpp + updater.hpp + util.hpp ) add_executable(bpdyndnsd ${cpp_sources} ${cpp_headers}) diff --git a/src/config.cpp b/src/config.cpp index 440c75e..77d86dc 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -7,16 +7,16 @@ * @license GPLv2 */ -#include "config.h" - -#include "service_dhs.h" -#include "service_ods.h" -#include "service_dyndns.h" -#include "service_dyns.h" -#include "service_easydns.h" -#include "service_tzo.h" -#include "service_zoneedit.h" -#include "service_gnudip.h" +#include "config.hpp" + +#include "service_dhs.hpp" +#include "service_ods.hpp" +#include "service_dyndns.hpp" +#include "service_dyns.hpp" +#include "service_easydns.hpp" +#include "service_tzo.hpp" +#include "service_zoneedit.hpp" +#include "service_gnudip.hpp" #include #include diff --git a/src/config.h b/src/config.h deleted file mode 100644 index 3b90b84..0000000 --- a/src/config.h +++ /dev/null @@ -1,111 +0,0 @@ -/** @file - * @brief Config class header. This class represents the actual configuration. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef CONFIG_H -#define CONFIG_H - -#include - -#include "logger.h" -#include "serviceholder.h" -#include "httphelper.h" -#include "service.h" - -#include -#include - - -class Config -{ - -private: - - boost::shared_ptr OptDescCmd; - boost::shared_ptr OptDescConfMain; - boost::shared_ptr OptDescConfService; - boost::program_options::variables_map VariablesMap; - - Logger::Ptr Log; - Serviceholder::Ptr ServiceHolder; - - bool DaemonMode; - bool Syslog; - bool EnableIPv6; - int Loglevel; - std::string ConfigPath; - std::string WebcheckIpUrl; - std::string WebcheckIpUrlAlt; - int WebcheckInterval; - std::string Proxy; - int ProxyPort; - std::string ExternalWarningLog; - int ExternalWarningLevel; - bool StartOffline; - bool WebcheckEnabled; - bool ExternalLogOnlyOnce; - - Service::Ptr create_service(const std::string& protocol, const std::string& server, 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); - int load_main_config_file(const std::string& full_filename); - int load_service_config_file(const std::string& full_filename); - -public: - - typedef boost::shared_ptr Ptr; - - Config(); - - Config(Logger::Ptr _log, Serviceholder::Ptr _serviceholder); - - ~Config(); - - int parse_cmd_line(int argc, char *argv[]); - - int load_config_from_files(); - - boost::shared_ptr get_opt_desc_cmd() const; - - boost::shared_ptr get_opt_desc_conf_main() const; - - boost::shared_ptr get_opt_desc_conf_service() const; - - bool get_daemon_mode() const; - - int get_loglevel() const; - - bool get_syslog() const; - - bool get_enable_ipv6() const; - - std::string get_proxy() const; - - int get_proxy_port() const; - - bool get_webcheck_enabled() const; - - void set_webcheck_enabled( bool webcheck_enabled ); - - std::string get_webcheck_ip_url() const; - - std::string get_webcheck_ip_url_alt() const; - - int get_webcheck_interval() const; - - void delete_variables_map(); - - int get_external_warning_level() const; - - std::string get_external_warning_log() const; - - bool get_start_offline() const; - - bool get_external_log_only_once() const; - -}; - -#endif diff --git a/src/httphelper.cpp b/src/httphelper.cpp index 5e0c998..59e16e1 100644 --- a/src/httphelper.cpp +++ b/src/httphelper.cpp @@ -7,7 +7,7 @@ * @license GPLv2 */ -#include "httphelper.h" +#include "httphelper.hpp" using namespace std; @@ -26,7 +26,7 @@ HTTPHelper::HTTPHelper() /** * Constructor. Use this constructor if HTTP AUTH should be used. Username and password will then be set as HTTP auth options. - * @param _log Logger Object + * @param _log Logger Object * @param _proxy Proxy to use * @param _proxy_port Proxy Port * @param _username Username @@ -52,7 +52,7 @@ HTTPHelper::HTTPHelper(Logger::Ptr _log, const string& _proxy, const int _proxy_ /** * Constructor. Use this constructor if you have to encode the username and password into the url - * @param _log Logger Object + * @param _log Logger Object * @param _proxy Proxy to use * @param _proxy_port Proxy Port */ diff --git a/src/httphelper.h b/src/httphelper.h deleted file mode 100644 index 026cfec..0000000 --- a/src/httphelper.h +++ /dev/null @@ -1,59 +0,0 @@ -/** @file - * @brief HTTPHelper class header. This class represents a Helper to perform HTTP operations easily. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef HTTPHELPER_H -#define HTTPHELPER_H - -#include "logger.h" - -#include -#include - - -class HTTPHelper -{ - -private: - - Logger::Ptr Log; - std::string Proxy; - int ProxyPort; - CURLcode CurlError; - CURL* CurlEasyHandle; - std::string CurlWritedataBuff; - std::string ReceivedCurlData; - char CurlErrBuff[CURL_ERROR_SIZE]; - - CURLcode set_curl_url(const std::string& url); - CURLcode set_curl_auth(const std::string& username, const std::string& password); - CURL* init_curl(std::string& curl_writedata_buff, char* curl_err_buff); - -public: - - typedef boost::shared_ptr Ptr; - - HTTPHelper(); - - HTTPHelper(Logger::Ptr _log, const std::string& _proxy, const int _proxy_port, const std::string& _username, const std::string& _password); - - HTTPHelper(Logger::Ptr _log, const std::string& _proxy, const int _proxy_port); - - ~HTTPHelper(); - - long http_get(const std::string& ip); - - std::string get_curl_data() const; - - bool is_initialized() const; - - // libcurl is a C library, so we have to make the callback member function static :-( - static size_t http_receive(const char *inBuffer, size_t size, size_t nmemb, std::string *outBuffer); -}; - -#endif diff --git a/src/httphelper.hpp b/src/httphelper.hpp new file mode 100644 index 0000000..bbf3daa --- /dev/null +++ b/src/httphelper.hpp @@ -0,0 +1,59 @@ +/** @file + * @brief HTTPHelper class header. This class represents a Helper to perform HTTP operations easily. + * + * + * + * @copyright Intra2net AG + * @license GPLv2 +*/ + +#ifndef HTTPHELPER_H +#define HTTPHELPER_H + +#include "logger.hpp" + +#include +#include + + +class HTTPHelper +{ + +private: + + Logger::Ptr Log; + std::string Proxy; + int ProxyPort; + CURLcode CurlError; + CURL* CurlEasyHandle; + std::string CurlWritedataBuff; + std::string ReceivedCurlData; + char CurlErrBuff[CURL_ERROR_SIZE]; + + CURLcode set_curl_url(const std::string& url); + CURLcode set_curl_auth(const std::string& username, const std::string& password); + CURL* init_curl(std::string& curl_writedata_buff, char* curl_err_buff); + +public: + + typedef boost::shared_ptr Ptr; + + HTTPHelper(); + + HTTPHelper(Logger::Ptr _log, const std::string& _proxy, const int _proxy_port, const std::string& _username, const std::string& _password); + + HTTPHelper(Logger::Ptr _log, const std::string& _proxy, const int _proxy_port); + + ~HTTPHelper(); + + long http_get(const std::string& ip); + + std::string get_curl_data() const; + + bool is_initialized() const; + + // libcurl is a C library, so we have to make the callback member function static :-( + static size_t http_receive(const char *inBuffer, size_t size, size_t nmemb, std::string *outBuffer); +}; + +#endif diff --git a/src/ip_addr_helper.cpp b/src/ip_addr_helper.cpp index cdfc164..1d88a57 100644 --- a/src/ip_addr_helper.cpp +++ b/src/ip_addr_helper.cpp @@ -7,7 +7,7 @@ * @license GPLv2 */ -#include "ip_addr_helper.h" +#include "ip_addr_helper.hpp" #include #include #include diff --git a/src/ip_addr_helper.h b/src/ip_addr_helper.h deleted file mode 100644 index 72eb1fe..0000000 --- a/src/ip_addr_helper.h +++ /dev/null @@ -1,74 +0,0 @@ -/** @file - * @brief IPHelper class header. This class represents a Helper to get the actual IP. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef IPADDRHELPER_H -#define IPADDRHELPER_H - -#include "logger.h" - -#include -#include - -#include -#include - - -class IPAddrHelper -{ - -private: - - friend class boost::serialization::access; - template - void serialize(Archive & ar, const unsigned int version) - { - ar & LastWebcheck; - } - - Logger::Ptr Log; - std::string WebcheckIpUrl; - std::string WebcheckIpUrlAlt; - int WebcheckInterval; - time_t LastWebcheck; - std::string Proxy; - int ProxyPort; - bool UseIPv6; - std::string Hostname; - - bool is_local_ipv4(const std::string ip) const; - 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, const char* curl_err_buff, const std::string& actual_url) const; - std::string parse_ipv4(const std::string& data) const; - CURLcode set_curl_url(CURL * curl_easy_handle, const std::string& url) const; - -public: - - typedef boost::shared_ptr Ptr; - - IPAddrHelper(); - - IPAddrHelper(const Logger::Ptr _log, const std::string& _webcheck_url, const std::string& _webcheck_url_alt, const int _webcheck_interval, const time_t _last_webcheck, const bool _use_ipv6, const std::string& _proxy, const int _proxy_port); - - ~IPAddrHelper(); - - std::string dns_query(const std::string& _hostname) const; - - std::string get_actual_ip( bool use_webcheck ); - - std::string get_local_wan_nic_ip() const; - - // libcurl is a C library, so we have to make the callback member function static :-( - static size_t http_receive(const char *inBuffer, size_t size, size_t nmemb, std::string *outBuffer); - - time_t get_last_webcheck() const; -}; - -#endif diff --git a/src/ip_addr_helper.hpp b/src/ip_addr_helper.hpp new file mode 100644 index 0000000..d1439a6 --- /dev/null +++ b/src/ip_addr_helper.hpp @@ -0,0 +1,74 @@ +/** @file + * @brief IPHelper class header. This class represents a Helper to get the actual IP. + * + * + * + * @copyright Intra2net AG + * @license GPLv2 +*/ + +#ifndef IPADDRHELPER_H +#define IPADDRHELPER_H + +#include "logger.hpp" + +#include +#include + +#include +#include + + +class IPAddrHelper +{ + +private: + + friend class boost::serialization::access; + template + void serialize(Archive & ar, const unsigned int version) + { + ar & LastWebcheck; + } + + Logger::Ptr Log; + std::string WebcheckIpUrl; + std::string WebcheckIpUrlAlt; + int WebcheckInterval; + time_t LastWebcheck; + std::string Proxy; + int ProxyPort; + bool UseIPv6; + std::string Hostname; + + bool is_local_ipv4(const std::string ip) const; + 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, const char* curl_err_buff, const std::string& actual_url) const; + std::string parse_ipv4(const std::string& data) const; + CURLcode set_curl_url(CURL * curl_easy_handle, const std::string& url) const; + +public: + + typedef boost::shared_ptr Ptr; + + IPAddrHelper(); + + IPAddrHelper(const Logger::Ptr _log, const std::string& _webcheck_url, const std::string& _webcheck_url_alt, const int _webcheck_interval, const time_t _last_webcheck, const bool _use_ipv6, const std::string& _proxy, const int _proxy_port); + + ~IPAddrHelper(); + + std::string dns_query(const std::string& _hostname) const; + + std::string get_actual_ip( bool use_webcheck ); + + std::string get_local_wan_nic_ip() const; + + // libcurl is a C library, so we have to make the callback member function static :-( + static size_t http_receive(const char *inBuffer, size_t size, size_t nmemb, std::string *outBuffer); + + time_t get_last_webcheck() const; +}; + +#endif diff --git a/src/ip_service.h b/src/ip_service.h deleted file mode 100644 index 6ed211c..0000000 --- a/src/ip_service.h +++ /dev/null @@ -1,36 +0,0 @@ -/** @file - * @brief The abstract IPService interface. This class represents all IP services. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef IPSERVICE_H -#define IPSERVICE_H - -#include - -#include - - -class IPService -{ - -public: - - typedef boost::shared_ptr Ptr; - - virtual ~IPService() {}; - - virtual void connect(const std::string& _hostname, const std::string& _port) = 0; - - virtual std::string read_from_socket() = 0; - - virtual void write_to_socket(const std::string& data) = 0; - - virtual void close() = 0; -}; - -#endif diff --git a/src/ip_service.hpp b/src/ip_service.hpp new file mode 100644 index 0000000..6ed211c --- /dev/null +++ b/src/ip_service.hpp @@ -0,0 +1,36 @@ +/** @file + * @brief The abstract IPService interface. This class represents all IP services. + * + * + * + * @copyright Intra2net AG + * @license GPLv2 +*/ + +#ifndef IPSERVICE_H +#define IPSERVICE_H + +#include + +#include + + +class IPService +{ + +public: + + typedef boost::shared_ptr Ptr; + + virtual ~IPService() {}; + + virtual void connect(const std::string& _hostname, const std::string& _port) = 0; + + virtual std::string read_from_socket() = 0; + + virtual void write_to_socket(const std::string& data) = 0; + + virtual void close() = 0; +}; + +#endif diff --git a/src/logger.cpp b/src/logger.cpp index 1c8e6fe..7b4fd58 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -8,7 +8,7 @@ */ -#include "logger.h" +#include "logger.hpp" #include #include diff --git a/src/logger.h b/src/logger.h deleted file mode 100644 index d5ae694..0000000 --- a/src/logger.h +++ /dev/null @@ -1,264 +0,0 @@ -/** @file - * @brief Logger class header. This class represents the Logging facility. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef LOGGER_H -#define LOGGER_H - -#include -#include - -#include -#include - -#include - -class Logger -{ - -private: - - int Loglevel; - bool Syslog; - std::string ExternalWarningLog; - int ExternalWarningLevel; - std::set ExternalSendMessages; - bool ExternalLogOnlyOnce; - -public: - - typedef boost::shared_ptr Ptr; - - Logger(); - - ~Logger(); - - void set_external_log_only_once( const bool _external_log_only_once ); - - void clear_external_send_messages(); - - void log_notice(const std::string& msg) const; - - void log_warning(const std::string& msg, int loglevel); - - void log_error(const std::string& msg) const; - - void set_loglevel(const int _loglevel); - - int get_loglevel() const; - - void set_syslog(const bool _syslog); - - bool get_syslog() const; - - void set_log_facility(const int _loglevel, const bool _syslog, const std::string& _external_error_log, const int _external_error_level, const bool _external_log_only_once ); - - bool is_allowed_to_send( const std::string& msg ) const; - - // Start log messages. - - void print_usage(const boost::shared_ptr opt_desc) const; - - void print_version() const; - - void print_cmd_parsed() const; - - void print_conf_files_parsed() const; - - void print_destructor_call(const std::string& _class) const; - - void print_constructor_call(const std::string& _class) const; - - void print_update_service(const std::string& service) const; - - void print_unknown_cmd_option(const std::string& unknown_option) const; - - void print_unknown_protocol(const std::string& protocol) const; - - void print_load_service_conf(const std::string& filename) const; - - void print_load_main_conf(const std::string& filename) const; - - void print_unknown_service_conf_option(const std::string& service_conf_file, const std::string& unknown_option) const; - - void print_unknown_main_conf_option(const std::string& unknown_option) const; - - void print_error_opening_r(const std::string& filename) const; - - void print_error_opening_rw(const std::string& filename) const; - - void print_error_config_path(const std::string& config_path) const; - - void print_conf_loaded(const std::string& config_path) const; - - void print_conf_not_loaded(const std::string& config_path) const; - - void print_missing_cmd_service_option() const; - - void print_missing_service_conf_option(const std::string& service_conf_file) const; - - void print_runnig_as_daemon(const int pid) const; - - void print_daemon_mode(const bool daemon_mode) const; - - void print_error_fork() const; - - void print_pid_found(const int pid) const; - - void print_process_already_running(const int pid) const; - - void print_caught_sigterm() const; - - void print_caught_siguser1() const; - - void print_caught_sighup() const; - - void print_caught_siguser2() const; - - void print_caught_sigrtmin() const; - - void print_error_setting_signal(const std::string& signal) const; - - void print_init_log_facility() const; - - void print_offline_mode() const; - - void print_serialized_objects_success() const; - - void print_deserialized_objects_success() const; - - 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 lastupdated) const; - - void print_exception_serialize(const std::string& errMsg) const; - - void print_exception_deserialize(const std::string& errMsg) const; - - void print_error_kill_child(const int pid) const; - - void print_child_killed(const int pid) const; - - void print_no_object_file(const std::string& object_file); - - void print_hostname(const std::string& hostname) const; - - void print_own_ipv4(const std::string& ip_addr_v4, const std::string& hostname) const; - - void print_own_ipv6(const std::string& ip_addr_v6, 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; - - void print_webcheck_no_ip(); - - void print_no_wan_ip() const; - - void print_webcheck_url_connection_problem(const char * curl_err_buff, const std::string& url); - - void print_webcheck_error(const char * curl_err_buff, const std::string& url) const; - - void print_received_curl_data(const std::string& curl_data) const; - - void print_regex_found_ip(const std::string& ip) const; - - void print_regex_ip_not_found(const std::string& data); - - void print_multiple_cmd_option(const std::string& message) const; - - void print_multiple_service_conf_option(const std::string& service_conf_file, const std::string& message) const; - - void print_multiple_main_conf_option(const std::string& main_conf_file, const std::string& message) const; - - void print_update_not_allowed(const time_t current_time, const time_t old_time, const int MaxUpdatesWithinInterval, const std::string& service); - - void print_update_service_failure(const std::string& service); - - void print_starting_shutdown() const; - - void print_shutdown_succeeded() const; - - void print_shutdown_parent_succeeded() const; - - void print_starting_shutdown_parent() const; - - void print_recheck_dns_entry(const std::string& hostname, const int lastupdated, const int dns_cache_ttl, const int current_time) const; - - void print_missing_cmd_proxy_option() const; - - void print_missing_conf_proxy_option(const std::string& main_conf_filename) const; - - void print_no_domain_part(const std::string& hostname) const; - - void print_curl_error_init(const std::string& err_msg, const CURLcode curl_err_code) const; - - void print_curl_error(const std::string& url, const CURLcode curl_err_code) const; - - void print_curl_error(const std::string& url, const CURLcode curl_err_code, const char * curl_err_buff) const; - - void print_curl_data(const std::string& curl_writedata_buff) const; - - void print_service_not_authorized(const std::string& service, const std::string& username, const std::string& password) const; - - void print_httphelper_not_initialized() const; - - void print_http_status_code(const std::string& url, const long http_code) const; - - void print_update_failure(const std::string& url, const std::string& curl_data) const; - - void print_update_failure(const std::string& url, const long http_status_code) const; - - void print_invalid_hostname(const std::string& hostname); - - void print_ip_is_local(const std::string& ip); - - void print_regex_match(const std::string& regex, const std::string& matching_string) const; - - void print_no_regex_match(const std::string& regex, const std::string& not_matching_string); - - void print_could_not_parse_received_data(const std::string& curl_data) const; - - void print_could_not_get_initial_gnudip_data() const; - - void print_gnudip_requires_servername(); - - void print_exception_md5_sum(const std::string& what) const; - - void print_network_error(const std::string& what) const; - - void print_undefined_protocol_error(const std::string& protocol, const std::string& error) const; - - void print_error_external_logging(const std::string& external_prog) const; - - void print_error_parsing_config_file(const std::string& filename, const std::string& error) const; - - void print_error_parsing_cmd(const std::string& error) const; - - void print_webcheck_exceed_interval( const time_t last_webcheck, const int webcheck_interval, const time_t current_time ) const; - - void print_check_service_update(const std::string& hostname, const time_t current_time, const time_t lastupdated) const; - - void print_cached_dns_entry(const std::string& hostname, const std::string& ip_dns_recheck, const std::string& ip_last_update, const std::string& ip_host) const; - - void print_update_service_firttime(const std::string& hostname, const std::string& ip_dns_recheck, const std::string& ip_host) const; - - void print_update_service(const std::string& hostname, const std::string& ip_dns_recheck, const std::string& ip_last_update, const std::string& ip_host, const time_t lastupdated) const; - - void print_update_service_ttl_expired(const std::string& hostname, const std::string& ip_dns_recheck, const std::string& ip_last_update, const std::string& ip_host, const time_t lastupdated, const int dns_cache_ttl, const time_t current_time) const; - - void print_update_service_ttl_not_expired(const std::string& hostname, const std::string& ip_dns_recheck, const std::string& ip_last_update, const std::string& ip_host, const time_t lastupdated, const int dns_cache_ttl, const time_t current_time) const; - - void print_no_update_needed(const std::string& hostname, const std::string& ip_dns_recheck, const std::string& ip_last_update, const std::string& ip_host, const time_t lastupdated) const; - - void print_error_getting_local_wan_ip(const std::string& system_call, const std::string& error) const; - - void print_invalid_service_config() const; - - void print_msg( const std::string& msg ) const; -}; - -#endif diff --git a/src/logger.hpp b/src/logger.hpp new file mode 100644 index 0000000..d5ae694 --- /dev/null +++ b/src/logger.hpp @@ -0,0 +1,264 @@ +/** @file + * @brief Logger class header. This class represents the Logging facility. + * + * + * + * @copyright Intra2net AG + * @license GPLv2 +*/ + +#ifndef LOGGER_H +#define LOGGER_H + +#include +#include + +#include +#include + +#include + +class Logger +{ + +private: + + int Loglevel; + bool Syslog; + std::string ExternalWarningLog; + int ExternalWarningLevel; + std::set ExternalSendMessages; + bool ExternalLogOnlyOnce; + +public: + + typedef boost::shared_ptr Ptr; + + Logger(); + + ~Logger(); + + void set_external_log_only_once( const bool _external_log_only_once ); + + void clear_external_send_messages(); + + void log_notice(const std::string& msg) const; + + void log_warning(const std::string& msg, int loglevel); + + void log_error(const std::string& msg) const; + + void set_loglevel(const int _loglevel); + + int get_loglevel() const; + + void set_syslog(const bool _syslog); + + bool get_syslog() const; + + void set_log_facility(const int _loglevel, const bool _syslog, const std::string& _external_error_log, const int _external_error_level, const bool _external_log_only_once ); + + bool is_allowed_to_send( const std::string& msg ) const; + + // Start log messages. + + void print_usage(const boost::shared_ptr opt_desc) const; + + void print_version() const; + + void print_cmd_parsed() const; + + void print_conf_files_parsed() const; + + void print_destructor_call(const std::string& _class) const; + + void print_constructor_call(const std::string& _class) const; + + void print_update_service(const std::string& service) const; + + void print_unknown_cmd_option(const std::string& unknown_option) const; + + void print_unknown_protocol(const std::string& protocol) const; + + void print_load_service_conf(const std::string& filename) const; + + void print_load_main_conf(const std::string& filename) const; + + void print_unknown_service_conf_option(const std::string& service_conf_file, const std::string& unknown_option) const; + + void print_unknown_main_conf_option(const std::string& unknown_option) const; + + void print_error_opening_r(const std::string& filename) const; + + void print_error_opening_rw(const std::string& filename) const; + + void print_error_config_path(const std::string& config_path) const; + + void print_conf_loaded(const std::string& config_path) const; + + void print_conf_not_loaded(const std::string& config_path) const; + + void print_missing_cmd_service_option() const; + + void print_missing_service_conf_option(const std::string& service_conf_file) const; + + void print_runnig_as_daemon(const int pid) const; + + void print_daemon_mode(const bool daemon_mode) const; + + void print_error_fork() const; + + void print_pid_found(const int pid) const; + + void print_process_already_running(const int pid) const; + + void print_caught_sigterm() const; + + void print_caught_siguser1() const; + + void print_caught_sighup() const; + + void print_caught_siguser2() const; + + void print_caught_sigrtmin() const; + + void print_error_setting_signal(const std::string& signal) const; + + void print_init_log_facility() const; + + void print_offline_mode() const; + + void print_serialized_objects_success() const; + + void print_deserialized_objects_success() const; + + 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 lastupdated) const; + + void print_exception_serialize(const std::string& errMsg) const; + + void print_exception_deserialize(const std::string& errMsg) const; + + void print_error_kill_child(const int pid) const; + + void print_child_killed(const int pid) const; + + void print_no_object_file(const std::string& object_file); + + void print_hostname(const std::string& hostname) const; + + void print_own_ipv4(const std::string& ip_addr_v4, const std::string& hostname) const; + + void print_own_ipv6(const std::string& ip_addr_v6, 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; + + void print_webcheck_no_ip(); + + void print_no_wan_ip() const; + + void print_webcheck_url_connection_problem(const char * curl_err_buff, const std::string& url); + + void print_webcheck_error(const char * curl_err_buff, const std::string& url) const; + + void print_received_curl_data(const std::string& curl_data) const; + + void print_regex_found_ip(const std::string& ip) const; + + void print_regex_ip_not_found(const std::string& data); + + void print_multiple_cmd_option(const std::string& message) const; + + void print_multiple_service_conf_option(const std::string& service_conf_file, const std::string& message) const; + + void print_multiple_main_conf_option(const std::string& main_conf_file, const std::string& message) const; + + void print_update_not_allowed(const time_t current_time, const time_t old_time, const int MaxUpdatesWithinInterval, const std::string& service); + + void print_update_service_failure(const std::string& service); + + void print_starting_shutdown() const; + + void print_shutdown_succeeded() const; + + void print_shutdown_parent_succeeded() const; + + void print_starting_shutdown_parent() const; + + void print_recheck_dns_entry(const std::string& hostname, const int lastupdated, const int dns_cache_ttl, const int current_time) const; + + void print_missing_cmd_proxy_option() const; + + void print_missing_conf_proxy_option(const std::string& main_conf_filename) const; + + void print_no_domain_part(const std::string& hostname) const; + + void print_curl_error_init(const std::string& err_msg, const CURLcode curl_err_code) const; + + void print_curl_error(const std::string& url, const CURLcode curl_err_code) const; + + void print_curl_error(const std::string& url, const CURLcode curl_err_code, const char * curl_err_buff) const; + + void print_curl_data(const std::string& curl_writedata_buff) const; + + void print_service_not_authorized(const std::string& service, const std::string& username, const std::string& password) const; + + void print_httphelper_not_initialized() const; + + void print_http_status_code(const std::string& url, const long http_code) const; + + void print_update_failure(const std::string& url, const std::string& curl_data) const; + + void print_update_failure(const std::string& url, const long http_status_code) const; + + void print_invalid_hostname(const std::string& hostname); + + void print_ip_is_local(const std::string& ip); + + void print_regex_match(const std::string& regex, const std::string& matching_string) const; + + void print_no_regex_match(const std::string& regex, const std::string& not_matching_string); + + void print_could_not_parse_received_data(const std::string& curl_data) const; + + void print_could_not_get_initial_gnudip_data() const; + + void print_gnudip_requires_servername(); + + void print_exception_md5_sum(const std::string& what) const; + + void print_network_error(const std::string& what) const; + + void print_undefined_protocol_error(const std::string& protocol, const std::string& error) const; + + void print_error_external_logging(const std::string& external_prog) const; + + void print_error_parsing_config_file(const std::string& filename, const std::string& error) const; + + void print_error_parsing_cmd(const std::string& error) const; + + void print_webcheck_exceed_interval( const time_t last_webcheck, const int webcheck_interval, const time_t current_time ) const; + + void print_check_service_update(const std::string& hostname, const time_t current_time, const time_t lastupdated) const; + + void print_cached_dns_entry(const std::string& hostname, const std::string& ip_dns_recheck, const std::string& ip_last_update, const std::string& ip_host) const; + + void print_update_service_firttime(const std::string& hostname, const std::string& ip_dns_recheck, const std::string& ip_host) const; + + void print_update_service(const std::string& hostname, const std::string& ip_dns_recheck, const std::string& ip_last_update, const std::string& ip_host, const time_t lastupdated) const; + + void print_update_service_ttl_expired(const std::string& hostname, const std::string& ip_dns_recheck, const std::string& ip_last_update, const std::string& ip_host, const time_t lastupdated, const int dns_cache_ttl, const time_t current_time) const; + + void print_update_service_ttl_not_expired(const std::string& hostname, const std::string& ip_dns_recheck, const std::string& ip_last_update, const std::string& ip_host, const time_t lastupdated, const int dns_cache_ttl, const time_t current_time) const; + + void print_no_update_needed(const std::string& hostname, const std::string& ip_dns_recheck, const std::string& ip_last_update, const std::string& ip_host, const time_t lastupdated) const; + + void print_error_getting_local_wan_ip(const std::string& system_call, const std::string& error) const; + + void print_invalid_service_config() const; + + void print_msg( const std::string& msg ) const; +}; + +#endif diff --git a/src/main.cpp b/src/main.cpp index 03a2554..8b038e0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,7 +21,7 @@ #include #include -#include "updater.h" +#include "updater.hpp" using namespace std; diff --git a/src/net_helper.cpp b/src/net_helper.cpp index 0063ca4..75e823e 100644 --- a/src/net_helper.cpp +++ b/src/net_helper.cpp @@ -7,8 +7,8 @@ * @license GPLv2 */ -#include "net_helper.h" -#include "tcp_service.h" +#include "net_helper.hpp" +#include "tcp_service.hpp" using namespace std; diff --git a/src/net_helper.h b/src/net_helper.h deleted file mode 100644 index 5d62439..0000000 --- a/src/net_helper.h +++ /dev/null @@ -1,47 +0,0 @@ -/** @file - * @brief NetHelper class header. This class represents a Helper to easily perform tcp/ip operations. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef NETHELPER_H -#define NETHELPER_H - -#include "logger.h" -#include "ip_service.h" - -#include - - -class NetHelper -{ - -private: - - Logger::Ptr Log; - IPService::Ptr IPServicePtr; - -public: - - typedef boost::shared_ptr Ptr; - - NetHelper(); - - NetHelper(const Logger::Ptr _log); - - ~NetHelper(); - - int open_connection(const std::string& _host, const std::string& _port) const; - - int send_data(const std::string& data) const; - - std::string receive_data() const; - - int close_connection() const; - -}; - -#endif diff --git a/src/net_helper.hpp b/src/net_helper.hpp new file mode 100644 index 0000000..4c9ae9b --- /dev/null +++ b/src/net_helper.hpp @@ -0,0 +1,47 @@ +/** @file + * @brief NetHelper class header. This class represents a Helper to easily perform tcp/ip operations. + * + * + * + * @copyright Intra2net AG + * @license GPLv2 +*/ + +#ifndef NETHELPER_H +#define NETHELPER_H + +#include "logger.hpp" +#include "ip_service.hpp" + +#include + + +class NetHelper +{ + +private: + + Logger::Ptr Log; + IPService::Ptr IPServicePtr; + +public: + + typedef boost::shared_ptr Ptr; + + NetHelper(); + + NetHelper(const Logger::Ptr _log); + + ~NetHelper(); + + int open_connection(const std::string& _host, const std::string& _port) const; + + int send_data(const std::string& data) const; + + std::string receive_data() const; + + int close_connection() const; + +}; + +#endif diff --git a/src/serializeservicecontainer.cpp b/src/serializeservicecontainer.cpp index 7547d08..6291c0a 100644 --- a/src/serializeservicecontainer.cpp +++ b/src/serializeservicecontainer.cpp @@ -7,7 +7,7 @@ * @license GPLv2 */ -#include "serializeservicecontainer.h" +#include "serializeservicecontainer.hpp" // Following boost macros are needed for serialization of derived classes through a base class pointer (Service *). BOOST_CLASS_EXPORT_GUID(ServiceOds, "ServiceOds") diff --git a/src/serializeservicecontainer.h b/src/serializeservicecontainer.h deleted file mode 100644 index f5a4984..0000000 --- a/src/serializeservicecontainer.h +++ /dev/null @@ -1,62 +0,0 @@ -/** @file - * @brief SerializeServiceContainer class header. This class holds Service objects in a list for serialization. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef SERIALIZESERVICECONTAINER_H -#define SERIALIZESERVICECONTAINER_H - -#include "service.h" -#include "logger.h" - -#include -#include -#include -#include - -#include -#include - -#include "service_dhs.h" -#include "service_ods.h" -#include "service_dyndns.h" -#include "service_dyns.h" -#include "service_easydns.h" -#include "service_tzo.h" -#include "service_zoneedit.h" -#include "service_gnudip.h" - - -class SerializeServiceContainer -{ - -private: - - std::list ContainingServices; - - friend class boost::serialization::access; - template - void serialize(Archive & ar, const unsigned int version) - { - ar & ContainingServices; - } - -public: - - typedef boost::shared_ptr Ptr; - - SerializeServiceContainer(); - - ~SerializeServiceContainer(); - - void add_service(Service::Ptr service); - - std::list get_containing_services() const; - -}; - -#endif diff --git a/src/serializeservicecontainer.hpp b/src/serializeservicecontainer.hpp new file mode 100644 index 0000000..a80eb08 --- /dev/null +++ b/src/serializeservicecontainer.hpp @@ -0,0 +1,62 @@ +/** @file + * @brief SerializeServiceContainer class header. This class holds Service objects in a list for serialization. + * + * + * + * @copyright Intra2net AG + * @license GPLv2 +*/ + +#ifndef SERIALIZESERVICECONTAINER_H +#define SERIALIZESERVICECONTAINER_H + +#include "service.hpp" +#include "logger.hpp" + +#include +#include +#include +#include + +#include +#include + +#include "service_dhs.hpp" +#include "service_ods.hpp" +#include "service_dyndns.hpp" +#include "service_dyns.hpp" +#include "service_easydns.hpp" +#include "service_tzo.hpp" +#include "service_zoneedit.hpp" +#include "service_gnudip.hpp" + + +class SerializeServiceContainer +{ + +private: + + std::list ContainingServices; + + friend class boost::serialization::access; + template + void serialize(Archive & ar, const unsigned int version) + { + ar & ContainingServices; + } + +public: + + typedef boost::shared_ptr Ptr; + + SerializeServiceContainer(); + + ~SerializeServiceContainer(); + + void add_service(Service::Ptr service); + + std::list get_containing_services() const; + +}; + +#endif diff --git a/src/service.cpp b/src/service.cpp index 0d0c590..0a6a29e 100644 --- a/src/service.cpp +++ b/src/service.cpp @@ -7,7 +7,7 @@ * @license GPLv2 */ -#include "service.h" +#include "service.hpp" #include using namespace std; diff --git a/src/service.h b/src/service.h deleted file mode 100644 index 850ddb9..0000000 --- a/src/service.h +++ /dev/null @@ -1,109 +0,0 @@ -/** @file - * @brief The abstract service class. This class represents all services. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef SERVICE_H -#define SERVICE_H - -#include "logger.h" - -#include -#include - -#include -#include -#include - - -class Service -{ - -private: - - std::string Protocol; - std::string Hostname; - - std::string Login; - std::string Password; - - std::string ActualIP; - - int UpdateInterval; - int MaxUpdatesWithinInterval; - int DNSCacheTTL; - - std::list LastUpdates; - - friend class boost::serialization::access; - template - void serialize(Archive & ar, const unsigned int version) - { - // protocol and hostname are the unique identifier for each service. - ar & Protocol; - ar & Hostname; - // lastupdated and actual_ip must also be serialized, cause these are essential infos of each service. - ar & LastUpdates; - ar & ActualIP; - ar & UpdateInterval; - ar & MaxUpdatesWithinInterval; - ar & DNSCacheTTL; - } - - Logger::Ptr Log; - -public: - - typedef boost::shared_ptr Ptr; - - Service(); - - virtual ~Service(); - - virtual int perform_update(const std::string& ip) = 0; - - void update(const std::string& ip, const time_t current_time); - - bool update_allowed(const time_t current_time); - - int get_update_interval()const; - void set_update_interval(const int _update_interval); - - int get_max_updates_within_interval() const; - void set_max_updates_within_interval(const int _max_updates_within_interval); - - int get_dns_cache_ttl() const; - void set_dns_cache_ttl(const int _dns_cache_ttl); - - void set_protocol(const std::string& _protocol); - std::string get_protocol() const; - - void set_hostname(const std::string& _hostname); - std::string get_hostname() const; - - void set_login(const std::string& _login); - std::string get_login() const; - - void set_password(const std::string& _password); - std::string get_password() const; - - void set_last_updates(std::list _last_updates); - const std::list get_last_updates() const; - - void set_actual_ip(const std::string& _actual_ip); - std::string get_actual_ip() const; - - void set_logger(const Logger::Ptr& _log); - Logger::Ptr get_logger() const; - - std::string get_service_name() const; - - bool operator== (const Service& other) const; - bool operator!= (const Service& other) const; -}; - -#endif diff --git a/src/service.hpp b/src/service.hpp new file mode 100644 index 0000000..dcec4b9 --- /dev/null +++ b/src/service.hpp @@ -0,0 +1,109 @@ +/** @file + * @brief The abstract service class. This class represents all services. + * + * + * + * @copyright Intra2net AG + * @license GPLv2 +*/ + +#ifndef SERVICE_H +#define SERVICE_H + +#include "logger.hpp" + +#include +#include + +#include +#include +#include + + +class Service +{ + +private: + + std::string Protocol; + std::string Hostname; + + std::string Login; + std::string Password; + + std::string ActualIP; + + int UpdateInterval; + int MaxUpdatesWithinInterval; + int DNSCacheTTL; + + std::list LastUpdates; + + friend class boost::serialization::access; + template + void serialize(Archive & ar, const unsigned int version) + { + // protocol and hostname are the unique identifier for each service. + ar & Protocol; + ar & Hostname; + // lastupdated and actual_ip must also be serialized, cause these are essential infos of each service. + ar & LastUpdates; + ar & ActualIP; + ar & UpdateInterval; + ar & MaxUpdatesWithinInterval; + ar & DNSCacheTTL; + } + + Logger::Ptr Log; + +public: + + typedef boost::shared_ptr Ptr; + + Service(); + + virtual ~Service(); + + virtual int perform_update(const std::string& ip) = 0; + + void update(const std::string& ip, const time_t current_time); + + bool update_allowed(const time_t current_time); + + int get_update_interval()const; + void set_update_interval(const int _update_interval); + + int get_max_updates_within_interval() const; + void set_max_updates_within_interval(const int _max_updates_within_interval); + + int get_dns_cache_ttl() const; + void set_dns_cache_ttl(const int _dns_cache_ttl); + + void set_protocol(const std::string& _protocol); + std::string get_protocol() const; + + void set_hostname(const std::string& _hostname); + std::string get_hostname() const; + + void set_login(const std::string& _login); + std::string get_login() const; + + void set_password(const std::string& _password); + std::string get_password() const; + + void set_last_updates(std::list _last_updates); + const std::list get_last_updates() const; + + void set_actual_ip(const std::string& _actual_ip); + std::string get_actual_ip() const; + + void set_logger(const Logger::Ptr& _log); + Logger::Ptr get_logger() const; + + std::string get_service_name() const; + + bool operator== (const Service& other) const; + bool operator!= (const Service& other) const; +}; + +#endif diff --git a/src/service_dhs.cpp b/src/service_dhs.cpp index 39c2295..314d987 100644 --- a/src/service_dhs.cpp +++ b/src/service_dhs.cpp @@ -7,7 +7,7 @@ * @license GPLv2 */ -#include "service_dhs.h" +#include "service_dhs.hpp" #include #include diff --git a/src/service_dhs.h b/src/service_dhs.h deleted file mode 100644 index 283c8af..0000000 --- a/src/service_dhs.h +++ /dev/null @@ -1,54 +0,0 @@ -/** @file - * @brief DHS Service class header. This class represents the DHS service. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef ServiceDhs_H -#define ServiceDhs_H - -#include "service.h" -#include "logger.h" -#include "httphelper.h" - -#include -#include -#include - - -class ServiceDhs : public Service -{ - -private: - - friend class boost::serialization::access; - template - void serialize(Archive & ar, const unsigned int version) - { - ar & boost::serialization::base_object(*this); - } - - std::string BaseUrl; - - HTTPHelper::Ptr HTTPHelp; - - std::list separate_domain_and_host_part(const std::string& str) const; - std::string assemble_base_url(const std::string& hostname, const std::string& domain_part) const; - -public: - - typedef boost::shared_ptr Ptr; - - ServiceDhs(); - - ServiceDhs(const std::string& _protocol, const std::string& _hostname, const std::string& _login, const std::string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int dns_cache_ttl, const std::string& proxy, const int proxy_port); - - ~ServiceDhs(); - - int perform_update(const std::string& ip); -}; - -#endif diff --git a/src/service_dhs.hpp b/src/service_dhs.hpp new file mode 100644 index 0000000..1cb8ec5 --- /dev/null +++ b/src/service_dhs.hpp @@ -0,0 +1,54 @@ +/** @file + * @brief DHS Service class header. This class represents the DHS service. + * + * + * + * @copyright Intra2net AG + * @license GPLv2 +*/ + +#ifndef ServiceDhs_H +#define ServiceDhs_H + +#include "service.hpp" +#include "logger.hpp" +#include "httphelper.hpp" + +#include +#include +#include + + +class ServiceDhs : public Service +{ + +private: + + friend class boost::serialization::access; + template + void serialize(Archive & ar, const unsigned int version) + { + ar & boost::serialization::base_object(*this); + } + + std::string BaseUrl; + + HTTPHelper::Ptr HTTPHelp; + + std::list separate_domain_and_host_part(const std::string& str) const; + std::string assemble_base_url(const std::string& hostname, const std::string& domain_part) const; + +public: + + typedef boost::shared_ptr Ptr; + + ServiceDhs(); + + ServiceDhs(const std::string& _protocol, const std::string& _hostname, const std::string& _login, const std::string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int dns_cache_ttl, const std::string& proxy, const int proxy_port); + + ~ServiceDhs(); + + int perform_update(const std::string& ip); +}; + +#endif diff --git a/src/service_dyndns.cpp b/src/service_dyndns.cpp index abd1d4a..0d15974 100644 --- a/src/service_dyndns.cpp +++ b/src/service_dyndns.cpp @@ -7,7 +7,7 @@ * @license GPLv2 */ -#include "service_dyndns.h" +#include "service_dyndns.hpp" #include diff --git a/src/service_dyndns.h b/src/service_dyndns.h deleted file mode 100644 index 1e18db7..0000000 --- a/src/service_dyndns.h +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * @brief DYNDNS Service class header. This class represents the DYNDNS service. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef ServiceDyndns_H -#define ServiceDyndns_H - -#include "service.h" -#include "logger.h" -#include "httphelper.h" - -#include -#include - - -class ServiceDyndns : public Service -{ - -private: - - friend class boost::serialization::access; - template - void serialize(Archive & ar, const unsigned int version) - { - ar & boost::serialization::base_object(*this); - } - - std::string BaseUrl; - - HTTPHelper::Ptr HTTPHelp; - - std::string assemble_base_url(const std::string& fqhn) const; - -public: - - typedef boost::shared_ptr Ptr; - - ServiceDyndns(); - - ServiceDyndns(const std::string& _protocol, const std::string& _hostname, const std::string& _login, const std::string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int dns_cache_ttl, const std::string& proxy, const int proxy_port); - - ~ServiceDyndns(); - - int perform_update(const std::string& ip); - -}; - -#endif diff --git a/src/service_dyndns.hpp b/src/service_dyndns.hpp new file mode 100644 index 0000000..4be4e12 --- /dev/null +++ b/src/service_dyndns.hpp @@ -0,0 +1,53 @@ +/** @file + * @brief DYNDNS Service class header. This class represents the DYNDNS service. + * + * + * + * @copyright Intra2net AG + * @license GPLv2 +*/ + +#ifndef ServiceDyndns_H +#define ServiceDyndns_H + +#include "service.hpp" +#include "logger.hpp" +#include "httphelper.hpp" + +#include +#include + + +class ServiceDyndns : public Service +{ + +private: + + friend class boost::serialization::access; + template + void serialize(Archive & ar, const unsigned int version) + { + ar & boost::serialization::base_object(*this); + } + + std::string BaseUrl; + + HTTPHelper::Ptr HTTPHelp; + + std::string assemble_base_url(const std::string& fqhn) const; + +public: + + typedef boost::shared_ptr Ptr; + + ServiceDyndns(); + + ServiceDyndns(const std::string& _protocol, const std::string& _hostname, const std::string& _login, const std::string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int dns_cache_ttl, const std::string& proxy, const int proxy_port); + + ~ServiceDyndns(); + + int perform_update(const std::string& ip); + +}; + +#endif diff --git a/src/service_dyns.cpp b/src/service_dyns.cpp index 10d4398..3855271 100644 --- a/src/service_dyns.cpp +++ b/src/service_dyns.cpp @@ -7,8 +7,8 @@ * @license GPLv2 */ -#include "service_dyns.h" -#include "util.h" +#include "service_dyns.hpp" +#include "util.hpp" #include #include diff --git a/src/service_dyns.h b/src/service_dyns.h deleted file mode 100644 index 14caf3d..0000000 --- a/src/service_dyns.h +++ /dev/null @@ -1,52 +0,0 @@ -/** @file - * @brief DYNS Service class header. This class represents the DYNS service. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef ServiceDyns_H -#define ServiceDyns_H - -#include "service.h" -#include "logger.h" -#include "httphelper.h" - -#include -#include - - -class ServiceDyns : public Service -{ - -private: - - friend class boost::serialization::access; - template - void serialize(Archive & ar, const unsigned int version) - { - ar & boost::serialization::base_object(*this); - } - - std::string BaseUrl; - - HTTPHelper::Ptr HTTPHelp; - - std::string assemble_base_url(const std::string& fqhn, const std::string& username, const std::string& password) const; - -public: - - typedef boost::shared_ptr Ptr; - - ServiceDyns(); - - ServiceDyns(const std::string& _protocol, const std::string& _hostname, const std::string& _login, const std::string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int dns_cache_ttl, const std::string& proxy, const int proxy_port); - - ~ServiceDyns(); - - int perform_update(const std::string& ip); -}; - -#endif diff --git a/src/service_dyns.hpp b/src/service_dyns.hpp new file mode 100644 index 0000000..2b57139 --- /dev/null +++ b/src/service_dyns.hpp @@ -0,0 +1,52 @@ +/** @file + * @brief DYNS Service class header. This class represents the DYNS service. + * + * + * + * @copyright Intra2net AG + * @license GPLv2 +*/ + +#ifndef ServiceDyns_H +#define ServiceDyns_H + +#include "service.hpp" +#include "logger.hpp" +#include "httphelper.hpp" + +#include +#include + + +class ServiceDyns : public Service +{ + +private: + + friend class boost::serialization::access; + template + void serialize(Archive & ar, const unsigned int version) + { + ar & boost::serialization::base_object(*this); + } + + std::string BaseUrl; + + HTTPHelper::Ptr HTTPHelp; + + std::string assemble_base_url(const std::string& fqhn, const std::string& username, const std::string& password) const; + +public: + + typedef boost::shared_ptr Ptr; + + ServiceDyns(); + + ServiceDyns(const std::string& _protocol, const std::string& _hostname, const std::string& _login, const std::string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int dns_cache_ttl, const std::string& proxy, const int proxy_port); + + ~ServiceDyns(); + + int perform_update(const std::string& ip); +}; + +#endif diff --git a/src/service_easydns.cpp b/src/service_easydns.cpp index b90894e..ad6bcfb 100644 --- a/src/service_easydns.cpp +++ b/src/service_easydns.cpp @@ -7,8 +7,8 @@ * @license GPLv2 */ -#include "service_easydns.h" -#include "util.h" +#include "service_easydns.hpp" +#include "util.hpp" #include #include diff --git a/src/service_easydns.h b/src/service_easydns.h deleted file mode 100644 index b018665..0000000 --- a/src/service_easydns.h +++ /dev/null @@ -1,57 +0,0 @@ -/** @file - * @brief EASYDNS Service class header. This class represents the EASYDNS service. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef ServiceEasydns_H -#define ServiceEasydns_H - -#include "service.h" -#include "logger.h" -#include "httphelper.h" - -#include -#include - - -class ServiceEasydns : public Service -{ - -private: - - friend class boost::serialization::access; - template - void serialize(Archive & ar, const unsigned int version) - { - ar & boost::serialization::base_object(*this); - } - - std::string BaseUrl; - - HTTPHelper::Ptr HTTPHelp; - - std::list separate_domain_and_host_part(const std::string& str) const; - - std::string assemble_base_url(const std::string& hostname, const std::string& two_level_tld) const; - - std::string get_two_level_tld(const std::string& domain_part) const; - -public: - - typedef boost::shared_ptr Ptr; - - ServiceEasydns(); - - ServiceEasydns(const std::string& _protocol, const std::string& _hostname, const std::string& _login, const std::string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int dns_cache_ttl, const std::string& proxy, const int proxy_port); - - ~ServiceEasydns(); - - int perform_update(const std::string& ip); - -}; - -#endif diff --git a/src/service_easydns.hpp b/src/service_easydns.hpp new file mode 100644 index 0000000..e3460f6 --- /dev/null +++ b/src/service_easydns.hpp @@ -0,0 +1,57 @@ +/** @file + * @brief EASYDNS Service class header. This class represents the EASYDNS service. + * + * + * + * @copyright Intra2net AG + * @license GPLv2 +*/ + +#ifndef ServiceEasydns_H +#define ServiceEasydns_H + +#include "service.hpp" +#include "logger.hpp" +#include "httphelper.hpp" + +#include +#include + + +class ServiceEasydns : public Service +{ + +private: + + friend class boost::serialization::access; + template + void serialize(Archive & ar, const unsigned int version) + { + ar & boost::serialization::base_object(*this); + } + + std::string BaseUrl; + + HTTPHelper::Ptr HTTPHelp; + + std::list separate_domain_and_host_part(const std::string& str) const; + + std::string assemble_base_url(const std::string& hostname, const std::string& two_level_tld) const; + + std::string get_two_level_tld(const std::string& domain_part) const; + +public: + + typedef boost::shared_ptr Ptr; + + ServiceEasydns(); + + ServiceEasydns(const std::string& _protocol, const std::string& _hostname, const std::string& _login, const std::string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int dns_cache_ttl, const std::string& proxy, const int proxy_port); + + ~ServiceEasydns(); + + int perform_update(const std::string& ip); + +}; + +#endif diff --git a/src/service_gnudip.cpp b/src/service_gnudip.cpp index 2149509..a8f9bd6 100644 --- a/src/service_gnudip.cpp +++ b/src/service_gnudip.cpp @@ -7,8 +7,8 @@ * @license GPLv2 */ -#include "service_gnudip.h" -#include "util.h" +#include "service_gnudip.hpp" +#include "util.hpp" #include #include diff --git a/src/service_gnudip.h b/src/service_gnudip.h deleted file mode 100644 index 5852d58..0000000 --- a/src/service_gnudip.h +++ /dev/null @@ -1,57 +0,0 @@ -/** @file - * @brief GNUDIP Service class header. This class represents the GNUDIP service. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef ServiceGnudip_H -#define ServiceGnudip_H - -#include "service.h" -#include "logger.h" -#include "httphelper.h" - -#include -#include -#include - - -class ServiceGnudip : public Service -{ - -private: - - friend class boost::serialization::access; - template - void serialize(Archive & ar, const unsigned int version) - { - ar & boost::serialization::base_object(*this); - } - - std::string GnudipServer; - std::string BaseUrl; - - HTTPHelper::Ptr HTTPHelp; - - std::string assemble_base_url(const std::string& gnudip_server) const; - std::map parse_initial_request(const std::string& curl_data) const; - std::string assemble_update_url(const std::string& salt, const std::string& curr_time, const std::string& sign, const std::string& secret, const std::string& ip) const; - -public: - - typedef boost::shared_ptr Ptr; - - ServiceGnudip(); - - ServiceGnudip(const std::string& _protocol, const std::string& _gnudip_server ,const std::string& _hostname, const std::string& _login, const std::string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int dns_cache_ttl, const std::string& proxy, const int proxy_port); - - ~ServiceGnudip(); - - int perform_update(const std::string& ip); - -}; - -#endif diff --git a/src/service_gnudip.hpp b/src/service_gnudip.hpp new file mode 100644 index 0000000..3c61aaf --- /dev/null +++ b/src/service_gnudip.hpp @@ -0,0 +1,57 @@ +/** @file + * @brief GNUDIP Service class header. This class represents the GNUDIP service. + * + * + * + * @copyright Intra2net AG + * @license GPLv2 +*/ + +#ifndef ServiceGnudip_H +#define ServiceGnudip_H + +#include "service.hpp" +#include "logger.hpp" +#include "httphelper.hpp" + +#include +#include +#include + + +class ServiceGnudip : public Service +{ + +private: + + friend class boost::serialization::access; + template + void serialize(Archive & ar, const unsigned int version) + { + ar & boost::serialization::base_object(*this); + } + + std::string GnudipServer; + std::string BaseUrl; + + HTTPHelper::Ptr HTTPHelp; + + std::string assemble_base_url(const std::string& gnudip_server) const; + std::map parse_initial_request(const std::string& curl_data) const; + std::string assemble_update_url(const std::string& salt, const std::string& curr_time, const std::string& sign, const std::string& secret, const std::string& ip) const; + +public: + + typedef boost::shared_ptr Ptr; + + ServiceGnudip(); + + ServiceGnudip(const std::string& _protocol, const std::string& _gnudip_server ,const std::string& _hostname, const std::string& _login, const std::string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int dns_cache_ttl, const std::string& proxy, const int proxy_port); + + ~ServiceGnudip(); + + int perform_update(const std::string& ip); + +}; + +#endif diff --git a/src/service_ods.cpp b/src/service_ods.cpp index ea86f5f..8f69f8c 100644 --- a/src/service_ods.cpp +++ b/src/service_ods.cpp @@ -7,9 +7,9 @@ * @license GPLv2 */ -#include "service_ods.h" -#include "net_helper.h" -#include "util.h" +#include "service_ods.hpp" +#include "net_helper.hpp" +#include "util.hpp" using namespace std; diff --git a/src/service_ods.h b/src/service_ods.h deleted file mode 100644 index 5e9ffff..0000000 --- a/src/service_ods.h +++ /dev/null @@ -1,48 +0,0 @@ -/** @file - * @brief ODS Service class header. This class represents the ODS service. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef ServiceOds_H -#define ServiceOds_H - -#include "service.h" -#include "logger.h" - -#include -#include - - -class ServiceOds : public Service -{ - -private: - - friend class boost::serialization::access; - template - void serialize(Archive & ar, const unsigned int version) - { - ar & boost::serialization::base_object(*this); - } - - std::string UpdateServer; - std::string Port; - -public: - - typedef boost::shared_ptr Ptr; - - ServiceOds(); - - ServiceOds(const std::string& _protocol, const std::string& _hostname, const std::string& _login, const std::string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int dns_cache_ttl); - - ~ServiceOds(); - - int perform_update(const std::string& ip); -}; - -#endif diff --git a/src/service_ods.hpp b/src/service_ods.hpp new file mode 100644 index 0000000..9ac6bf3 --- /dev/null +++ b/src/service_ods.hpp @@ -0,0 +1,48 @@ +/** @file + * @brief ODS Service class header. This class represents the ODS service. + * + * + * + * @copyright Intra2net AG + * @license GPLv2 +*/ + +#ifndef ServiceOds_H +#define ServiceOds_H + +#include "service.hpp" +#include "logger.hpp" + +#include +#include + + +class ServiceOds : public Service +{ + +private: + + friend class boost::serialization::access; + template + void serialize(Archive & ar, const unsigned int version) + { + ar & boost::serialization::base_object(*this); + } + + std::string UpdateServer; + std::string Port; + +public: + + typedef boost::shared_ptr Ptr; + + ServiceOds(); + + ServiceOds(const std::string& _protocol, const std::string& _hostname, const std::string& _login, const std::string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int dns_cache_ttl); + + ~ServiceOds(); + + int perform_update(const std::string& ip); +}; + +#endif diff --git a/src/service_tzo.cpp b/src/service_tzo.cpp index 01fa6b0..7a1fa61 100644 --- a/src/service_tzo.cpp +++ b/src/service_tzo.cpp @@ -7,8 +7,8 @@ * @license GPLv2 */ -#include "service_tzo.h" -#include "util.h" +#include "service_tzo.hpp" +#include "util.hpp" #include #include diff --git a/src/service_tzo.h b/src/service_tzo.h deleted file mode 100644 index 0e8da5a..0000000 --- a/src/service_tzo.h +++ /dev/null @@ -1,52 +0,0 @@ -/** @file - * @brief TZO Service class header. This class represents the TZO service. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef ServiceTzo_H -#define ServiceTzo_H - -#include "service.h" -#include "logger.h" -#include "httphelper.h" - -#include -#include - - -class ServiceTzo : public Service -{ - -private: - - friend class boost::serialization::access; - template - void serialize(Archive & ar, const unsigned int version) - { - ar & boost::serialization::base_object(*this); - } - - std::string BaseUrl; - - HTTPHelper::Ptr HTTPHelp; - - std::string assemble_base_url(const std::string& fqhn, const std::string& username, const std::string& password) const; - -public: - - typedef boost::shared_ptr Ptr; - - ServiceTzo(); - - ServiceTzo(const std::string& _protocol, const std::string& _hostname, const std::string& _login, const std::string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int dns_cache_ttl, const std::string& proxy, const int proxy_port); - - ~ServiceTzo(); - - int perform_update(const std::string& ip); -}; - -#endif diff --git a/src/service_tzo.hpp b/src/service_tzo.hpp new file mode 100644 index 0000000..8daf390 --- /dev/null +++ b/src/service_tzo.hpp @@ -0,0 +1,52 @@ +/** @file + * @brief TZO Service class header. This class represents the TZO service. + * + * + * + * @copyright Intra2net AG + * @license GPLv2 +*/ + +#ifndef ServiceTzo_H +#define ServiceTzo_H + +#include "service.hpp" +#include "logger.hpp" +#include "httphelper.hpp" + +#include +#include + + +class ServiceTzo : public Service +{ + +private: + + friend class boost::serialization::access; + template + void serialize(Archive & ar, const unsigned int version) + { + ar & boost::serialization::base_object(*this); + } + + std::string BaseUrl; + + HTTPHelper::Ptr HTTPHelp; + + std::string assemble_base_url(const std::string& fqhn, const std::string& username, const std::string& password) const; + +public: + + typedef boost::shared_ptr Ptr; + + ServiceTzo(); + + ServiceTzo(const std::string& _protocol, const std::string& _hostname, const std::string& _login, const std::string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int dns_cache_ttl, const std::string& proxy, const int proxy_port); + + ~ServiceTzo(); + + int perform_update(const std::string& ip); +}; + +#endif diff --git a/src/service_zoneedit.cpp b/src/service_zoneedit.cpp index f7c069e..db1e941 100644 --- a/src/service_zoneedit.cpp +++ b/src/service_zoneedit.cpp @@ -7,8 +7,8 @@ * @license GPLv2 */ -#include "service_zoneedit.h" -#include "util.h" +#include "service_zoneedit.hpp" +#include "util.hpp" #include #include diff --git a/src/service_zoneedit.h b/src/service_zoneedit.h deleted file mode 100644 index bd58161..0000000 --- a/src/service_zoneedit.h +++ /dev/null @@ -1,52 +0,0 @@ -/** @file - * @brief ZONEEDIT Service class header. This class represents the ZONEEDIT service. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef ServiceZoneedit_H -#define ServiceZoneedit_H - -#include "service.h" -#include "logger.h" -#include "httphelper.h" - -#include -#include - - -class ServiceZoneedit : public Service -{ - -private: - - friend class boost::serialization::access; - template - void serialize(Archive & ar, const unsigned int version) - { - ar & boost::serialization::base_object(*this); - } - - std::string BaseUrl; - - HTTPHelper::Ptr HTTPHelp; - - std::string assemble_base_url(const std::string& fqhn) const; - -public: - - typedef boost::shared_ptr Ptr; - - ServiceZoneedit(); - - ServiceZoneedit(const std::string& _protocol, const std::string& _hostname, const std::string& _login, const std::string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int dns_cache_ttl, const std::string& proxy, const int proxy_port); - - ~ServiceZoneedit(); - - int perform_update(const std::string& ip); -}; - -#endif diff --git a/src/service_zoneedit.hpp b/src/service_zoneedit.hpp new file mode 100644 index 0000000..61c58b7 --- /dev/null +++ b/src/service_zoneedit.hpp @@ -0,0 +1,52 @@ +/** @file + * @brief ZONEEDIT Service class header. This class represents the ZONEEDIT service. + * + * + * + * @copyright Intra2net AG + * @license GPLv2 +*/ + +#ifndef ServiceZoneedit_H +#define ServiceZoneedit_H + +#include "service.hpp" +#include "logger.hpp" +#include "httphelper.hpp" + +#include +#include + + +class ServiceZoneedit : public Service +{ + +private: + + friend class boost::serialization::access; + template + void serialize(Archive & ar, const unsigned int version) + { + ar & boost::serialization::base_object(*this); + } + + std::string BaseUrl; + + HTTPHelper::Ptr HTTPHelp; + + std::string assemble_base_url(const std::string& fqhn) const; + +public: + + typedef boost::shared_ptr Ptr; + + ServiceZoneedit(); + + ServiceZoneedit(const std::string& _protocol, const std::string& _hostname, const std::string& _login, const std::string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int dns_cache_ttl, const std::string& proxy, const int proxy_port); + + ~ServiceZoneedit(); + + int perform_update(const std::string& ip); +}; + +#endif diff --git a/src/serviceholder.cpp b/src/serviceholder.cpp index 7eb64c6..ed4efe0 100644 --- a/src/serviceholder.cpp +++ b/src/serviceholder.cpp @@ -7,7 +7,7 @@ * @license GPLv2 */ -#include "serviceholder.h" +#include "serviceholder.hpp" #include diff --git a/src/serviceholder.h b/src/serviceholder.h deleted file mode 100644 index 5b3c5b7..0000000 --- a/src/serviceholder.h +++ /dev/null @@ -1,59 +0,0 @@ -/** @file - * @brief Serviceholder class header. This class holds Service and OldService lists. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef SERVICEHOLDER_H -#define SERVICEHOLDER_H - -#include "service.h" -#include "serializeservicecontainer.h" -#include "logger.h" -#include "ip_addr_helper.h" - -#include -#include - - -class Serviceholder -{ - -private: - - Logger::Ptr Log; - - std::list OldServices; // Represents all old Services where the timeout isn't expired (in case the same Service is redefined). - std::list Services; // Represents all active Services. - - IPAddrHelper::Ptr IPAddrHelp; - -public: - - typedef boost::shared_ptr Ptr; - - Serviceholder(); - - Serviceholder(Logger::Ptr _log); - - ~Serviceholder(); - - void add_service(Service::Ptr service); - - int deserialize_services(); - - int serialize_services() const; - - void delete_services(); - - void set_ip_addr_helper(IPAddrHelper::Ptr _ip_addr_helper); - - IPAddrHelper::Ptr get_ip_addr_helper() const; - - std::list get_services() const; -}; - -#endif diff --git a/src/serviceholder.hpp b/src/serviceholder.hpp new file mode 100644 index 0000000..044e7a3 --- /dev/null +++ b/src/serviceholder.hpp @@ -0,0 +1,59 @@ +/** @file + * @brief Serviceholder class header. This class holds Service and OldService lists. + * + * + * + * @copyright Intra2net AG + * @license GPLv2 +*/ + +#ifndef SERVICEHOLDER_H +#define SERVICEHOLDER_H + +#include "service.hpp" +#include "serializeservicecontainer.hpp" +#include "logger.hpp" +#include "ip_addr_helper.hpp" + +#include +#include + + +class Serviceholder +{ + +private: + + Logger::Ptr Log; + + std::list OldServices; // Represents all old Services where the timeout isn't expired (in case the same Service is redefined). + std::list Services; // Represents all active Services. + + IPAddrHelper::Ptr IPAddrHelp; + +public: + + typedef boost::shared_ptr Ptr; + + Serviceholder(); + + Serviceholder(Logger::Ptr _log); + + ~Serviceholder(); + + void add_service(Service::Ptr service); + + int deserialize_services(); + + int serialize_services() const; + + void delete_services(); + + void set_ip_addr_helper(IPAddrHelper::Ptr _ip_addr_helper); + + IPAddrHelper::Ptr get_ip_addr_helper() const; + + std::list get_services() const; +}; + +#endif diff --git a/src/tcp_service.cpp b/src/tcp_service.cpp index f1b8ca1..96846b0 100644 --- a/src/tcp_service.cpp +++ b/src/tcp_service.cpp @@ -7,7 +7,7 @@ * @license GPLv2 */ -#include "tcp_service.h" +#include "tcp_service.hpp" typedef boost::shared_ptr SocketPtr; diff --git a/src/tcp_service.h b/src/tcp_service.h deleted file mode 100644 index 70360d6..0000000 --- a/src/tcp_service.h +++ /dev/null @@ -1,49 +0,0 @@ -/** @file - * @brief TCPService class header. This class represents a TCP client. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef TCPSERVICE_H -#define TCPSERVICE_H - -#include "logger.h" -#include "ip_service.h" - -#include -#include -#include - -typedef boost::asio::ssl::stream SSLStream; - -class TCPService : public IPService -{ - -private: - - boost::shared_ptr Socket; - // IOService has to be a member, otherwise the socket.close() operation will throw "mutex: Invalid argument" - // Bug in boost::asio ? Cause no docs found concerning this issue. The socket.close() operation is trying to clean up io_service. - boost::asio::io_service IOService; - -public: - - //typedef boost::shared_ptr Ptr; - - TCPService(); - - ~TCPService(); - - virtual void connect(const std::string& _hostname, const std::string& _port); - - std::string read_from_socket(); - - void write_to_socket(const std::string& data); - - void close(); -}; - -#endif diff --git a/src/tcp_service.hpp b/src/tcp_service.hpp new file mode 100644 index 0000000..811181d --- /dev/null +++ b/src/tcp_service.hpp @@ -0,0 +1,49 @@ +/** @file + * @brief TCPService class header. This class represents a TCP client. + * + * + * + * @copyright Intra2net AG + * @license GPLv2 +*/ + +#ifndef TCPSERVICE_H +#define TCPSERVICE_H + +#include "logger.hpp" +#include "ip_service.hpp" + +#include +#include +#include + +typedef boost::asio::ssl::stream SSLStream; + +class TCPService : public IPService +{ + +private: + + boost::shared_ptr Socket; + // IOService has to be a member, otherwise the socket.close() operation will throw "mutex: Invalid argument" + // Bug in boost::asio ? Cause no docs found concerning this issue. The socket.close() operation is trying to clean up io_service. + boost::asio::io_service IOService; + +public: + + //typedef boost::shared_ptr Ptr; + + TCPService(); + + ~TCPService(); + + virtual void connect(const std::string& _hostname, const std::string& _port); + + std::string read_from_socket(); + + void write_to_socket(const std::string& data); + + void close(); +}; + +#endif diff --git a/src/updater.cpp b/src/updater.cpp index b474264..758bf66 100644 --- a/src/updater.cpp +++ b/src/updater.cpp @@ -7,9 +7,9 @@ * @license GPLv2 */ -#include "updater.h" +#include "updater.hpp" -#include "serviceholder.h" +#include "serviceholder.hpp" #include @@ -121,7 +121,7 @@ int Updater::init_config_from_cmd(int argc, char *argv[]) const /** * Load the main config and the service definition files in config path. - * @return 0 if all is fine, + * @return 0 if all is fine, */ int Updater::init_config_from_files() const { @@ -145,7 +145,7 @@ int Updater::init_config_from_files() const /** * Init all Helper classes - * @return + * @return */ int Updater::init_helper_classes() { diff --git a/src/updater.h b/src/updater.h deleted file mode 100644 index ad2dd99..0000000 --- a/src/updater.h +++ /dev/null @@ -1,66 +0,0 @@ -/** @file - * @brief The updater class header. This class represents the updater logic. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef UPDATER_H -#define UPDATER_H - -#include "config.h" -#include "ip_addr_helper.h" -#include "httphelper.h" -#include "logger.h" -#include "serviceholder.h" - -#include - - -class Updater -{ - -private: - - Config::Ptr Conf; - IPAddrHelper::Ptr IPAddrHelp; - HTTPHelper::Ptr HTTPHelp; - Logger::Ptr Log; - Serviceholder::Ptr ServiceHolder; - -public: - - typedef boost::shared_ptr Ptr; - - Updater(); - - ~Updater(); - - void update_services() const; - - int init_config_from_cmd(int argc, char *argv[]) const; - - int init_config_from_files() const; - - Config::Ptr get_config() const; - - Logger::Ptr get_logger() const; - - Serviceholder::Ptr get_service_holder() const; - - int load_config(int argc, char *argv[]); - - int reload_config(); - - int init_helper_classes(); - - void init_log_facility() const; - - int init_ip_helper(); - - int init_http_helper(); -}; - -#endif diff --git a/src/updater.hpp b/src/updater.hpp new file mode 100644 index 0000000..7d1da06 --- /dev/null +++ b/src/updater.hpp @@ -0,0 +1,66 @@ +/** @file + * @brief The updater class header. This class represents the updater logic. + * + * + * + * @copyright Intra2net AG + * @license GPLv2 +*/ + +#ifndef UPDATER_H +#define UPDATER_H + +#include "config.hpp" +#include "ip_addr_helper.hpp" +#include "httphelper.hpp" +#include "logger.hpp" +#include "serviceholder.hpp" + +#include + + +class Updater +{ + +private: + + Config::Ptr Conf; + IPAddrHelper::Ptr IPAddrHelp; + HTTPHelper::Ptr HTTPHelp; + Logger::Ptr Log; + Serviceholder::Ptr ServiceHolder; + +public: + + typedef boost::shared_ptr Ptr; + + Updater(); + + ~Updater(); + + void update_services() const; + + int init_config_from_cmd(int argc, char *argv[]) const; + + int init_config_from_files() const; + + Config::Ptr get_config() const; + + Logger::Ptr get_logger() const; + + Serviceholder::Ptr get_service_holder() const; + + int load_config(int argc, char *argv[]); + + int reload_config(); + + int init_helper_classes(); + + void init_log_facility() const; + + int init_ip_helper(); + + int init_http_helper(); +}; + +#endif diff --git a/src/util.cpp b/src/util.cpp index 8b795fc..3d5dd39 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -7,7 +7,7 @@ * @license GPLv2 */ -#include "util.h" +#include "util.hpp" #include #include diff --git a/src/util.h b/src/util.h deleted file mode 100644 index 5593ef2..0000000 --- a/src/util.h +++ /dev/null @@ -1,25 +0,0 @@ -/** @file - * @brief Util namespace header. - * - * - * - * @copyright Intra2net AG - * @license GPLv2 -*/ - -#ifndef UTIL_H -#define UTIL_H - -#include -#include -#include - - -namespace Util -{ - std::string compute_md5_digest(std::string data); - std::string parse_status_code(std::string data); - std::string parse_status_code(std::string data, std::string delimiter); -} - -#endif diff --git a/src/util.hpp b/src/util.hpp new file mode 100644 index 0000000..5593ef2 --- /dev/null +++ b/src/util.hpp @@ -0,0 +1,25 @@ +/** @file + * @brief Util namespace header. + * + * + * + * @copyright Intra2net AG + * @license GPLv2 +*/ + +#ifndef UTIL_H +#define UTIL_H + +#include +#include +#include + + +namespace Util +{ + std::string compute_md5_digest(std::string data); + std::string parse_status_code(std::string data); + std::string parse_status_code(std::string data, std::string delimiter); +} + +#endif -- 1.7.1