First steps in fine tuning and improving error handling.
[bpdyndnsd] / src / config.cpp
1 /** @file
2  * @brief Config class implementation. This class represents the actual configuration.
3  *
4  *
5  *
6  * @copyright Intra2net AG
7  * @license GPLv2
8 */
9
10 #include "config.h"
11
12 #include "service_dhs.h"
13 #include "service_ods.h"
14 #include "service_dyndns.h"
15 #include "service_dyns.h"
16 #include "service_easydns.h"
17 #include "service_tzo.h"
18 #include "service_zoneedit.h"
19 #include "service_gnudip.h"
20
21 #include <time.h>
22 #include <iostream>
23 #include <fstream>
24
25 #include <boost/foreach.hpp>
26 #include <boost/filesystem.hpp>
27 #include <boost/regex.hpp>
28 #include <boost/algorithm/string.hpp>
29
30
31 namespace po = boost::program_options;
32 namespace fs = boost::filesystem;
33 namespace ba = boost::algorithm;
34
35 typedef boost::shared_ptr<boost::program_options::options_description> Options_descriptionPtr;
36
37 using namespace std;
38
39
40 /**
41  * Default Constructor. Available command line and config file options with their default values are defined here.
42  */
43 Config::Config()
44     : Log(new Logger)
45     , ServiceHolder(new Serviceholder)
46     , DaemonMode(false)
47     , Syslog(false)
48     , EnableIPv6(false)
49     , Loglevel(0)
50     , ConfigPath("/etc/bpdyndnsd")
51     , WebcheckInterval(0)
52     , ProxyPort(0)
53     , ExternalWarningLog("")
54     , ExternalWarningLevel(0)
55 {
56     // Available service description config options
57     po::options_description opt_desc_service("Service description options");
58     opt_desc_service.add_options()
59         ("protocol",po::value<string>(),"The service protocol.")
60         ("server",po::value<string>(),"Servername needed for gnudip protocol.")
61         ("host",po::value<string>(),"The hostname to update.")
62         ("login",po::value<string>(),"Login name.")
63         ("password",po::value<string>(),"Corresponding password.")
64         ("update_interval",po::value<int>()->default_value(-1),"Update interval in minutes.")
65         ("max_updates_within_interval",po::value<int>()->default_value(-1),"How many updates can be made in one interval.")
66         ("dns_cache_ttl",po::value<int>()->default_value(-1),"How long a dns record is valid.")
67     ;
68
69     // Available command line only options
70     po::options_description opt_desc_cmd_only("Command line only options");
71     opt_desc_cmd_only.add_options()
72         ("help,?","Show help.")
73         ("version,v","Show version.")
74         ("config,c",po::value<string>()->default_value("/etc/bpdyndnsd"),"Set the config path.")
75     ;
76
77      // Available generic options. Valid on cmd or in config file.
78     po::options_description opt_desc_generic("Generic config options");
79     opt_desc_generic.add_options()
80         ("daemon_mode",po::value<bool>()->default_value(false),"Run as system daemon.")
81         ("loglevel",po::value<int>()->default_value(0),"Loglevel.")
82         ("syslog",po::value<bool>()->default_value(false),"Use syslog facility.")
83         ("enable_ipv6",po::value<bool>()->default_value(false),"Try to use IPv6.")
84         ("webcheck_url",po::value<string>()->default_value(""),"Use this URL to determine IP.")
85         ("webcheck_url_alt",po::value<string>()->default_value(""),"Use this alternative URL to determine IP.")
86         ("webcheck_interval",po::value<int>()->default_value(10),"The webcheck interval in minutes.")
87         ("http_proxy",po::value<string>(),"Use this proxy for all http requests.")
88         ("http_proxy_port",po::value<int>(),"Port of the proxy.")
89         ("external_warning_log",po::value<string>()->default_value(""),"External programm to pass warning log messages to.")
90         ("external_warning_level",po::value<int>()->default_value(0),"Warning messages of which loglevel should be passed to external programm.")
91     ;
92
93     // Define valid command line parameters
94     Options_descriptionPtr _opt_desc_cmd(new po::options_description("Command line options"));
95     OptDescCmd.swap(_opt_desc_cmd);
96     OptDescCmd->add(opt_desc_cmd_only);
97     OptDescCmd->add(opt_desc_generic);
98     OptDescCmd->add(opt_desc_service);
99
100     // Define valid config file options
101     Options_descriptionPtr _opt_desc_conf_main(new po::options_description("Config file options"));
102     OptDescConfMain.swap(_opt_desc_conf_main);
103     OptDescConfMain->add(opt_desc_generic);
104
105     // Define valid service file options
106     Options_descriptionPtr _opt_desc_conf_service(new po::options_description("Service file options"));
107     OptDescConfService.swap(_opt_desc_conf_service);
108     OptDescConfService->add(opt_desc_service);
109 }
110
111
112 /**
113  * Constructor with Logger and Serviceholder objects. Available command line and config file options with their default values are defined here.
114  */
115 Config::Config(Logger::Ptr _log, Serviceholder::Ptr _serviceholder)
116     : Log(_log)
117     , ServiceHolder(_serviceholder)
118     , DaemonMode(false)
119     , Syslog(false)
120     , EnableIPv6(false)
121     , Loglevel(0)
122     , ConfigPath("/etc/bpdyndnsd")
123     , WebcheckInterval(0)
124     , ProxyPort(0)
125     , ExternalWarningLog("")
126     , ExternalWarningLevel(0)
127 {
128     // Available service description config options
129     po::options_description opt_desc_service("Service description options");
130     opt_desc_service.add_options()
131         ("protocol",po::value<string>(),"The service protocol.")
132         ("server",po::value<string>(),"Servername needed for gnudip protocol.")
133         ("host",po::value<string>(),"The hostname to update.")
134         ("login",po::value<string>(),"Login name.")
135         ("password",po::value<string>(),"Corresponding password.")
136         ("update_interval",po::value<int>()->default_value(-1),"Update interval in minutes.")
137         ("max_updates_within_interval",po::value<int>()->default_value(-1),"How many updates can be made in one interval.")
138         ("dns_cache_ttl",po::value<int>()->default_value(-1),"How long a dns record is valid.")
139     ;
140
141     // Available command line only options
142     po::options_description opt_desc_cmd_only("Command line only options");
143     opt_desc_cmd_only.add_options()
144         ("help,?","Show help.")
145         ("version,v","Show version.")
146         ("config,c",po::value<string>()->default_value("/etc/bpdyndnsd"),"Set the config path.")
147     ;
148
149      // Available generic options. Valid on cmd or in config file.
150     po::options_description opt_desc_generic("Generic config options");
151     opt_desc_generic.add_options()
152         ("daemon_mode",po::value<bool>()->default_value(false),"Run as system daemon.")
153         ("loglevel",po::value<int>()->default_value(0),"Loglevel.")
154         ("syslog",po::value<bool>()->default_value(false),"Use syslog facility.")
155         ("enable_ipv6",po::value<bool>()->default_value(false),"Try to use IPv6.")
156         ("webcheck_url",po::value<string>()->default_value(""),"Use this URL to determine IP.")
157         ("webcheck_url_alt",po::value<string>()->default_value(""),"Use this alternative URL to determine IP.")
158         ("webcheck_interval",po::value<int>()->default_value(10),"The webcheck interval in minutes.")
159         ("http_proxy",po::value<string>(),"Use this proxy for all http requests.")
160         ("http_proxy_port",po::value<int>(),"Port of the proxy.")
161         ("external_warning_log",po::value<string>()->default_value(""),"External programm to pass warning log messages to.")
162         ("external_warning_level",po::value<int>()->default_value(0),"Warning messages of which loglevel should be passed to external programm.")
163     ;
164
165     // Define valid command line parameters
166     Options_descriptionPtr _opt_desc_cmd(new po::options_description("Command line options"));
167     OptDescCmd.swap(_opt_desc_cmd);
168     OptDescCmd->add(opt_desc_cmd_only);
169     OptDescCmd->add(opt_desc_generic);
170     OptDescCmd->add(opt_desc_service);
171
172     // Define valid config file options
173     Options_descriptionPtr _opt_desc_conf_main(new po::options_description("Config file options"));
174     OptDescConfMain.swap(_opt_desc_conf_main);
175     OptDescConfMain->add(opt_desc_generic);
176
177     // Define valid service file options
178     Options_descriptionPtr _opt_desc_conf_service(new po::options_description("Service file options"));
179     OptDescConfService.swap(_opt_desc_conf_service);
180     OptDescConfService->add(opt_desc_service);
181 }
182
183
184 /**
185  * Default Destructor
186  */
187 Config::~Config()
188 {
189 }
190
191
192 /**
193  * Parses the command line arguments and does the needed actions.
194  * @param argc Command line argument number given to main.
195  * @param argv[] Pointer to command line argument array given to main.
196  * @return 0 if all is fine, -1 if not.
197  */
198 int Config::parse_cmd_line(int argc, char *argv[])
199 {
200     try
201     {
202         po::store(po::parse_command_line(argc, argv, *this->OptDescCmd), VariablesMap);
203         po::notify(VariablesMap);
204
205         if ( VariablesMap.count("help") )
206         {
207             Log->print_usage(OptDescCmd);
208             return -1;
209         }
210         else if ( VariablesMap.count("version") )
211         {
212             Log->print_version();
213             return -1;
214         }
215
216         // Create a service object if all needed options are set on the command line
217         if ( VariablesMap.count("protocol") && VariablesMap.count("host") && VariablesMap.count("login") && VariablesMap.count("password") )
218         {
219             // Get the cmd parameter values for protocol host login and password
220             string protocol = VariablesMap["protocol"].as<string>();
221             string host = VariablesMap["host"].as<string>();
222             string login = VariablesMap["login"].as<string>();
223             string password = VariablesMap["password"].as<string>();
224
225             protocol = ba::to_lower_copy(protocol);
226
227             string server;
228             if ( VariablesMap.count("server") )
229                 server = VariablesMap["server"].as<string>();
230
231             int update_interval = 0;
232             if ( VariablesMap.count("update_interval") )
233                 update_interval = VariablesMap["update_interval"].as<int>();
234
235             int max_updates_within_interval = 0;
236             if ( VariablesMap.count("max_updates_within_interval") )
237                 max_updates_within_interval = VariablesMap["max_updates_within_interval"].as<int>();
238
239             int dns_cache_ttl = 0;
240             if ( VariablesMap.count("dns_cache_ttl") )
241                 dns_cache_ttl = VariablesMap["dns_cache_ttl"].as<int>();
242
243             Service::Ptr service = create_service(protocol,server,host,login,password,update_interval,max_updates_within_interval,dns_cache_ttl);
244             if ( service )
245             {
246                 ServiceHolder->add_service(service);
247                 Log->print_service_object("New Service object from command line options:", service->get_protocol(), service->get_hostname(), service->get_login() ,service->get_password(), service->get_update_interval(), service->get_max_updates_within_interval(), service->get_dns_cache_ttl() , service->get_actual_ip(), service->get_last_updates());
248             }
249             else
250                 return -1;
251         }
252         else if ( VariablesMap.count("protocol") || VariablesMap.count("host") || VariablesMap.count("login") || VariablesMap.count("password") )
253         {
254             Log->print_missing_cmd_service_option();
255             Log->print_usage(OptDescCmd);
256             return -1;
257         }
258
259         if ( VariablesMap.count("config") )
260         {
261             fs::path full_config_path = fs::system_complete(fs::path(VariablesMap["config"].as<string>()));
262             ConfigPath = full_config_path.string();
263             if ( !fs::exists(full_config_path) ||  !fs::is_directory(full_config_path) )
264             {
265                 // Config path doesn't exist or is not a directory
266                 Log->print_error_config_path(ConfigPath);
267                 return -1;
268             }
269         }
270
271         if ( VariablesMap.count("daemon_mode") )
272             DaemonMode = VariablesMap["daemon_mode"].as<bool>();
273
274         if ( VariablesMap.count("loglevel") )
275             Loglevel = VariablesMap["loglevel"].as<int>();
276
277         if ( VariablesMap.count("syslog") )
278             Syslog = VariablesMap["syslog"].as<bool>();
279
280         if ( VariablesMap.count("enable_ipv6") )
281             EnableIPv6 = VariablesMap["enable_ipv6"].as<bool>();
282
283         if ( VariablesMap.count("webcheck_url") )
284             WebcheckIpUrl = VariablesMap["webcheck_url"].as<string>();
285
286         if ( VariablesMap.count("webcheck_url_alt") )
287             WebcheckIpUrlAlt = VariablesMap["webcheck_url_alt"].as<string>();
288
289         if ( VariablesMap.count("webcheck_interval") )
290             WebcheckInterval = VariablesMap["webcheck_interval"].as<int>();
291
292         if ( VariablesMap.count("http_proxy") && VariablesMap.count("http_proxy_port") )
293         {
294             Proxy = VariablesMap["http_proxy"].as<string>();
295             ProxyPort = VariablesMap["http_proxy_port"].as<int>();
296         }
297         else if ( VariablesMap.count("http_proxy") || VariablesMap.count("http_proxy_port") )
298         {
299             Log->print_missing_cmd_proxy_option();
300             Log->print_usage(OptDescCmd);
301             return -1;
302         }
303
304         if ( VariablesMap.count("external_warning_log") )
305             ExternalWarningLog = VariablesMap["external_warning_log"].as<string>();
306
307         if ( VariablesMap.count("external_warning_level") )
308             ExternalWarningLevel = VariablesMap["external_warning_level"].as<int>();
309
310     }
311     catch( po::unknown_option& e )
312     {
313         Log->print_unknown_cmd_option(e.what());
314         Log->print_usage(OptDescCmd);
315         return -1;
316     }
317     catch( po::multiple_occurrences& e )
318     {
319         Log->print_multiple_cmd_option(e.what());
320         Log->print_usage(OptDescCmd);
321         return -1;
322     }
323     catch( po::error& e )
324     {
325         Log->print_error_parsing_cmd(e.what());
326         Log->print_usage(OptDescCmd);
327         return -1;
328     }
329     return 0;
330 }
331
332
333 /**
334  * Creates a Service object from the given parameters.
335  * @param protocol Protocol to use.
336  * @param host Hostname to update.
337  * @param login Login.
338  * @param password Password.
339  * @return A pointer to the created Service object.
340  */
341 Service::Ptr Config::create_service(const string &protocol, const string& server, const string& hostname, const string& login, const string& password, const int update_interval, const int max_updates_within_interval, const int dns_cache_ttl)
342 {
343     // Test for valid hostname. Must contain 3 parts minimum.
344     list<string> fqhn_parts;
345     ba::split(fqhn_parts,hostname,boost::is_any_of("."));
346     if ( fqhn_parts.size() < 3 )
347     {
348         Log->print_invalid_hostname(protocol);
349         Service::Ptr service;
350         return service;
351     }
352
353     if(protocol == "dhs")
354     {
355         Service::Ptr service_dhs(new ServiceDhs(protocol,hostname,login,password,Log,update_interval,max_updates_within_interval,dns_cache_ttl,Proxy,ProxyPort));
356         return service_dhs;
357     }
358     else if(protocol == "ods")
359     {
360         Service::Ptr service_ods(new ServiceOds(protocol,hostname,login,password,Log,update_interval,max_updates_within_interval,dns_cache_ttl));
361         return service_ods;
362     }
363     else if(protocol == "dyndns")
364     {
365         Service::Ptr service_dyndns(new ServiceDyndns(protocol,hostname,login,password,Log,update_interval,max_updates_within_interval,dns_cache_ttl,Proxy,ProxyPort));
366         return service_dyndns;
367     }
368     else if(protocol == "dyns")
369     {
370         Service::Ptr service_dyns(new ServiceDyns(protocol,hostname,login,password,Log,update_interval,max_updates_within_interval,dns_cache_ttl,Proxy,ProxyPort));
371         return service_dyns;
372     }
373     else if(protocol == "easydns")
374     {
375         Service::Ptr service_easydns(new ServiceEasydns(protocol,hostname,login,password,Log,update_interval,max_updates_within_interval,dns_cache_ttl,Proxy,ProxyPort));
376         return service_easydns;
377     }
378     else if(protocol == "tzo")
379     {
380         Service::Ptr service_tzo(new ServiceTzo(protocol,hostname,login,password,Log,update_interval,max_updates_within_interval,dns_cache_ttl,Proxy,ProxyPort));
381         return service_tzo;
382     }
383     else if(protocol == "zoneedit")
384     {
385         Service::Ptr service_zoneedit(new ServiceZoneedit(protocol,hostname,login,password,Log,update_interval,max_updates_within_interval,dns_cache_ttl,Proxy,ProxyPort));
386         return service_zoneedit;
387     }
388     else if(protocol == "gnudip")
389     {
390         cout << "Server: " << server << endl; 
391         if ( !server.empty() )
392         {
393             Service::Ptr service_gnudip(new ServiceGnudip(protocol,server,hostname,login,password,Log,update_interval,max_updates_within_interval,dns_cache_ttl,Proxy,ProxyPort));
394             return service_gnudip;
395         }
396         else
397         {
398             Log->print_gnudip_requires_servername();
399             Service::Ptr service;
400             return service;
401         }
402     }
403     else
404     {
405         Log->print_unknown_protocol(protocol);
406         Service::Ptr service;
407         return service;
408     }
409 }
410
411
412 /**
413  * Loads a service config file, invoked by load_config_from_files.
414  * @param full_filename Filename of the service config file to load.
415  * @return 0 if all is fine, -1 otherwise.
416  */
417 int Config::load_service_config_file(const string& full_filename)
418 {
419     Log->print_load_service_conf(full_filename);
420
421     ifstream service_config_file(full_filename.c_str(),ifstream::in);
422     if(service_config_file.is_open())
423     {
424         try
425         {
426             po::variables_map vm;
427             po::parsed_options parsed_service_options = po::parse_config_file(service_config_file,*this->OptDescConfService,true);
428             po::store(parsed_service_options,vm);
429             po::notify(vm);
430
431             if(vm.count("protocol") && vm.count("host") && vm.count("login") && vm.count("password"))
432             {
433                 // create the corresponding service
434                 string protocol = vm["protocol"].as<string>();
435                 string host = vm["host"].as<string>();
436                 string login = vm["login"].as<string>();
437                     string password = vm["password"].as<string>();
438
439                 protocol = ba::to_lower_copy(protocol);
440
441                 string server;
442                 if ( vm.count("server") )
443                     server = vm["server"].as<string>();
444
445                 int update_interval = 0;
446                 if ( vm.count("update_interval") )
447                     update_interval = vm["update_interval"].as<int>();
448
449                 int max_updates_within_interval = 0;
450                 if ( vm.count("max_updates_within_interval") )
451                     max_updates_within_interval = vm["max_updates_within_interval"].as<int>();
452
453                 int dns_cache_ttl = 0;
454                 if ( vm.count("dns_cache_ttl") )
455                     dns_cache_ttl = vm["dns_cache_ttl"].as<int>();
456
457                 Service::Ptr service = create_service(protocol,server,host,login,password,update_interval,max_updates_within_interval,dns_cache_ttl);
458                 if ( service )
459                 {
460                     ServiceHolder->add_service(service);
461                     Log->print_service_object("New Service object from config:", service->get_protocol(), service->get_hostname(), service->get_login() ,service->get_password(), service->get_update_interval(), service->get_max_updates_within_interval(), service->get_dns_cache_ttl() , service->get_actual_ip(), service->get_last_updates());
462                 }
463                 else
464                     return -1;
465             }
466             else if ( vm.count("protocol") || vm.count("host") || vm.count("login") || vm.count("password") )
467             {
468                 service_config_file.close();
469                 Log->print_missing_service_conf_option(full_filename);
470                 return -1;
471             }
472         }
473         catch ( po::unknown_option& e )
474         {
475             // unknown option in config file detected
476             service_config_file.close();
477             Log->print_unknown_service_conf_option(full_filename,e.what());
478             return -1;
479         }
480         catch( po::multiple_occurrences& e )
481         {
482             service_config_file.close();
483             Log->print_multiple_service_conf_option(full_filename,e.what());
484             return -1;
485         }
486         catch( po::error& e )
487         {
488             service_config_file.close();
489             Log->print_error_parsing_config_file(full_filename,e.what());
490             return -1;
491         }
492         service_config_file.close();
493     }
494     else
495     {
496         // error opening service config file for reading
497         Log->print_error_opening_r(full_filename);
498         return -1;
499     }
500     return 0;
501 }
502
503
504 /**
505  * Loads the main config file, invoked by load_config_from_files
506  * @param full_filename The full filename of the main config file to load
507  * @return 0 if all is fine, -1 otherwise
508  */
509 int Config::load_main_config_file(const string& full_filename)
510 {
511     Log->print_load_main_conf(full_filename);
512
513     ifstream main_config_file(full_filename.c_str(),ifstream::in);
514     if(main_config_file.is_open())
515     {
516         try
517         {
518             po::parsed_options parsed_main_options = po::parse_config_file(main_config_file,*this->OptDescConfMain,true);
519             po::store(parsed_main_options,VariablesMap);
520             po::notify(VariablesMap);
521
522             if ( VariablesMap.count("daemon_mode") )
523                 DaemonMode = VariablesMap["daemon_mode"].as<bool>();
524
525             if ( VariablesMap.count("loglevel") )
526                 Loglevel = VariablesMap["loglevel"].as<int>();
527
528             if ( VariablesMap.count("syslog") )
529                 Syslog = VariablesMap["syslog"].as<bool>();
530
531             if ( VariablesMap.count("enable_ipv6") )
532                 EnableIPv6 = VariablesMap["enable_ipv6"].as<bool>();
533
534             if ( VariablesMap.count("webcheck_url") )
535                 WebcheckIpUrl = VariablesMap["webcheck_url"].as<string>();
536
537             if ( VariablesMap.count("webcheck_url_alt") )
538                 WebcheckIpUrlAlt = VariablesMap["webcheck_url_alt"].as<string>();
539
540             if ( VariablesMap.count("webcheck_interval") )
541                 WebcheckInterval = VariablesMap["webcheck_interval"].as<int>();
542
543             if ( VariablesMap.count("http_proxy") && VariablesMap.count("http_proxy_port") )
544             {
545                 Proxy = VariablesMap["http_proxy"].as<string>();
546                 ProxyPort = VariablesMap["http_proxy_port"].as<int>();
547             }
548             else if ( VariablesMap.count("http_proxy") || VariablesMap.count("http_proxy_port") )
549             {
550                 main_config_file.close();
551                 Log->print_missing_conf_proxy_option(full_filename);
552                 return -1;
553             }
554
555             if ( VariablesMap.count("external_warning_log") )
556                 ExternalWarningLog = VariablesMap["external_warning_log"].as<string>();
557
558             if ( VariablesMap.count("external_warning_level") )
559                 ExternalWarningLevel = VariablesMap["external_warning_level"].as<int>();
560
561         }
562         catch ( po::unknown_option& e )      // at the moment 04-08-2009 this exception is never thrown :-(
563         {
564             // unknown option in main config file detected
565             main_config_file.close();
566             Log->print_unknown_main_conf_option(e.what());
567             return -1;
568         }
569         catch(po::multiple_occurrences& e)
570         {
571             main_config_file.close();
572             Log->print_multiple_main_conf_option(full_filename,e.what());
573             return -1;
574         }
575         main_config_file.close();
576     }
577     else
578     {
579         // error opening main config file for reading
580         Log->print_error_opening_r(full_filename);
581         return -1;
582     }
583     return 0;
584 }
585
586
587 /**
588  * Loads the main and the service config file and does the needed action.
589  * @param config_path The path to the config directory.
590  * @return 0 if all is fine, -1 otherwise
591  */
592 int Config::load_config_from_files()
593 {
594     fs::path full_config_path = fs::path(ConfigPath);
595
596     fs::directory_iterator end_iter;
597     for ( fs::directory_iterator dir_itr(full_config_path) ; dir_itr != end_iter ; ++dir_itr )
598     {
599         if( fs::is_regular_file( dir_itr->status() ) )
600         {
601             string actual_file = dir_itr->path().filename();
602             boost::regex expr(".*\\.conf?");
603              // If it is the main config file do the following
604             if ( actual_file == "bpdyndnsd.conf" )
605             {
606                 // Load the main config file
607                 string full_filename = dir_itr->path().string();
608                 if ( load_main_config_file(full_filename) != 0 )
609                     return -1;
610             }
611             // If it is a service definition file *.conf, parse it and generate the corresponding service
612             else if ( boost::regex_search( actual_file,expr ) )
613             {
614                 string full_filename = dir_itr->path().string();
615                 if ( load_service_config_file(full_filename) != 0 )
616                     return -1;
617             }
618         }
619     }
620     // Config file successfully loaded
621     Log->print_conf_loaded(ConfigPath);
622     return 0;
623 }
624
625
626 /**
627  * Getter method for member OptDescCmd.
628  * @return options_description*.
629  */
630 Options_descriptionPtr Config::get_opt_desc_cmd() const
631 {
632     return OptDescCmd;
633 }
634
635
636 /**
637  * Getter method for member OptDescConfMain.
638  * @return options_description*.
639  */
640 Options_descriptionPtr Config::get_opt_desc_conf_main() const
641 {
642     return OptDescConfMain;
643 }
644
645
646 /**
647  * Getter method for member OptDescConfService.
648  * @return options_description*.
649  */
650 Options_descriptionPtr Config::get_opt_desc_conf_service() const
651 {
652     return OptDescConfService;
653 }
654
655
656 /**
657  * Getter for member Loglevel.
658  * @return Member Loglevel.
659  */
660 int Config::get_loglevel() const
661 {
662     return Loglevel;
663 }
664
665
666 /**
667  * Getter for member DaemonMode.
668  * @return TRUE if enabled, FALSE if disabled.
669  */
670 bool Config::get_daemon_mode() const
671 {
672     return DaemonMode;
673 }
674
675
676 /**
677  * Deletes the map with the previously parsed options.
678  * This is needed in case we reload the config and don't want the old cmd options to overwrite new config file options.
679  */
680 void Config::delete_variables_map()
681 {
682     VariablesMap.clear();
683
684     po::variables_map _variables_map;
685     VariablesMap = _variables_map;
686 }
687
688
689 /**
690  * Getter for member Syslog.
691  * @return True if logging through syslog is enabled, false otherwise.
692  */
693 bool Config::get_syslog() const
694 {
695     return Syslog;
696 }
697
698
699 /**
700  * Getter for member EnableIPv6
701  * @return Wether IPv6 should be used or not.
702  */
703 bool Config::get_enable_ipv6() const
704 {
705     return EnableIPv6;
706 }
707
708
709 /**
710  * Getter for member WebcheckIpUrl
711  * @return The primary IP Webcheck URL
712  */
713 string Config::get_webcheck_ip_url() const
714 {
715     return WebcheckIpUrl;
716 }
717
718
719 /**
720  * Getter for member WebcheckIpUrlAlt
721  * @return The alternative IP Webcheck URL
722  */
723 string Config::get_webcheck_ip_url_alt() const
724 {
725     return WebcheckIpUrlAlt;
726 }
727
728
729 /**
730  * Get member WebcheckInterval
731  * @return WebcheckInterval
732  */
733 int Config::get_webcheck_interval() const
734 {
735     return WebcheckInterval;
736 }
737
738
739 /**
740  * Get member Proxy
741  * @return Proxy
742  */
743 string Config::get_proxy() const
744 {
745     return Proxy;
746 }
747
748
749 /**
750  * Get member ProxyPort
751  * @return ProxyPort
752  */
753 int Config::get_proxy_port() const
754 {
755     return ProxyPort;
756 }
757
758
759 /**
760  * Get member ExternalWarningLog
761  * @return ExternalWarningLog
762  */
763 string Config::get_external_warning_log() const
764 {
765     return ExternalWarningLog;
766 }
767
768
769 /**
770  * Get member ExternalWarningLevel
771  * @return ExternalWaringLevel
772  */
773 int Config::get_external_warning_level() const
774 {
775     return ExternalWarningLevel;
776 }
777