* @param argv[] Pointer to command line argument array given to main.
* @return 0 if all is fine, -1 if not.
*/
-int Config::parse_cmd_line(int argc, char *argv[], HTTPHelper::Ptr http_help)
+int Config::parse_cmd_line(int argc, char *argv[])
{
try
{
if ( VariablesMap.count("dns_cache_ttl") )
dns_cache_ttl = VariablesMap["dns_cache_ttl"].as<int>();
- Service::Ptr service = create_service(protocol,host,login,password,update_interval,max_updates_within_interval,dns_cache_ttl,http_help);
+ Service::Ptr service = create_service(protocol,host,login,password,update_interval,max_updates_within_interval,dns_cache_ttl);
if ( service )
{
ServiceHolder->add_service(service);
* @param password Password.
* @return A pointer to the created Service object.
*/
-Service::Ptr Config::create_service(const string &protocol,const string &hostname, const string &login, const string &password, const int update_interval, const int max_updates_within_interval, const int dns_cache_ttl, const HTTPHelper::Ptr http_help)
+Service::Ptr Config::create_service(const string &protocol,const string &hostname, const string &login, const string &password, const int update_interval, const int max_updates_within_interval, const int dns_cache_ttl)
{
if(protocol == "dhs")
{
- Service::Ptr service_dhs(new DHS(protocol,hostname,login,password,Log,http_help,update_interval,max_updates_within_interval,dns_cache_ttl));
+ Service::Ptr service_dhs(new DHS(protocol,hostname,login,password,Log,update_interval,max_updates_within_interval,dns_cache_ttl,Proxy,ProxyPort));
return service_dhs;
}
else if(protocol == "ods")
* @param full_filename Filename of the service config file to load.
* @return 0 if all is fine, -1 otherwise.
*/
-int Config::load_service_config_file(const string& full_filename, const HTTPHelper::Ptr http_help)
+int Config::load_service_config_file(const string& full_filename)
{
Log->print_load_service_conf(full_filename);
if ( vm.count("dns_cache_ttl") )
dns_cache_ttl = VariablesMap["dns_cache_ttl"].as<int>();
- Service::Ptr service = create_service(protocol,host,login,password,update_interval,max_updates_within_interval,dns_cache_ttl,http_help);
+ Service::Ptr service = create_service(protocol,host,login,password,update_interval,max_updates_within_interval,dns_cache_ttl);
if ( service )
{
ServiceHolder->add_service(service);
* @param config_path The path to the config directory.
* @return 0 if all is fine, -1 otherwise
*/
-int Config::load_config_from_files(const HTTPHelper::Ptr http_help)
+int Config::load_config_from_files()
{
fs::path full_config_path = fs::path(ConfigPath);
else if ( boost::regex_search( actual_file,expr ) )
{
string full_filename = dir_itr->path().string();
- if ( load_service_config_file(full_filename,http_help) != 0 )
+ if ( load_service_config_file(full_filename) != 0 )
return -1;
}
}
std::string ExternalWarningLog;
int ExternalWarningLevel;
- Service::Ptr create_service(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 HTTPHelper::Ptr http_help);
+ Service::Ptr create_service(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);
int load_main_config_file(const std::string& full_filename);
- int load_service_config_file(const std::string& full_filename, const HTTPHelper::Ptr http_help);
+ int load_service_config_file(const std::string& full_filename);
public:
~Config();
- int parse_cmd_line(int argc, char *argv[], const HTTPHelper::Ptr http_help);
+ int parse_cmd_line(int argc, char *argv[]);
- int load_config_from_files(const HTTPHelper::Ptr http_help);
+ int load_config_from_files();
Options_descriptionPtr get_opt_desc_cmd() const;
* @param _login The login name.
* @param _password The corresponding password.
*/
-DHS::DHS(const string& _protocol, const string& _hostname, const string& _login, const string& _password, const Logger::Ptr& _logger, const HTTPHelper::Ptr& _http_help, const int _update_interval, const int _max_updates_within_interval, const int _dns_cache_ttl)
+DHS::DHS(const string& _protocol, const string& _hostname, const string& _login, const string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int _dns_cache_ttl, const string& _proxy, const int _proxy_port)
{
if ( _update_interval == -1 ) // If _update_interval is default po::option_desc (not specified via config)
set_update_interval(0); // use default protocol value
set_password(_password);
set_logger(_logger);
+ // create http helper class
+ HTTPHelper::Ptr _http_help(new HTTPHelper(_logger,_proxy,_proxy_port));
HTTPHelp = _http_help;
+ _http_help.reset();
}
DHS();
- DHS(const std::string& _protocol, const std::string& _hostname, const std::string& _login, const std::string& _password, const Logger::Ptr& _logger, const HTTPHelper::Ptr& _http_help, const int _update_interval, const int _max_updates_within_interval, const int dns_cache_ttl);
+ DHS(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);
~DHS();
int Updater::init_config_from_cmd(int argc, char *argv[])
{
// Load the command line parameters
- if( Conf->parse_cmd_line( argc, argv, HTTPHelp) != 0)
+ if( Conf->parse_cmd_line( argc, argv) != 0)
return -1;
// If we have loaded the cmd options we need to init the log facility immediately in case debugging is enabled from cmd.
int Updater::init_config_from_files()
{
// Load the main and service config files in config path
- if ( Conf->load_config_from_files(HTTPHelp) != 0 )
+ if ( Conf->load_config_from_files() != 0 )
return -1;
// Re-init log facility, perhaps new config file options for logger are set.
if ( init_ip_helper() != 0 )
return -1;
- // Initialize HTTPHelper
- if ( init_http_helper() != 0 )
- return -1;
-
return 0;
}
/**
- * Init the IPHelp member with needed values.
- * @return 0 if all is fine, -1 otherwise.
- */
-int Updater::init_http_helper()
-{
- // initialize IPHelper
- HTTPHelper::Ptr _httphelp(new HTTPHelper(Log,Conf->get_proxy(),Conf->get_proxy_port()));
- HTTPHelp = _httphelp;
- _httphelp.reset();
-
- return 0;
-}
-
-
-/**
* Getter for member Config.
* @return Member Config.
*/