Commit | Line | Data |
---|---|---|
4f63f66e BS |
1 | /** @file |
2 | * @brief Config class header. This class represents the actual configuration. | |
3 | * | |
4 | * | |
5 | * | |
6 | * @copyright Intra2net AG | |
7 | * @license GPLv2 | |
8 | */ | |
9 | ||
10 | #ifndef CONFIG_H | |
11 | #define CONFIG_H | |
12 | ||
13 | #include <string> | |
14 | ||
15 | #include "logger.hpp" | |
16 | #include "serviceholder.hpp" | |
17 | #include "httphelper.hpp" | |
18 | #include "service.hpp" | |
19 | ||
20 | #include <boost/program_options.hpp> | |
21 | #include <boost/shared_ptr.hpp> | |
22 | ||
23 | ||
24 | class Config | |
25 | { | |
26 | ||
27 | private: | |
28 | ||
29 | boost::shared_ptr<boost::program_options::options_description> OptDescCmd; | |
30 | boost::shared_ptr<boost::program_options::options_description> OptDescConfMain; | |
31 | boost::shared_ptr<boost::program_options::options_description> OptDescConfService; | |
32 | boost::program_options::variables_map VariablesMap; | |
33 | ||
34 | Logger::Ptr Log; | |
35 | Serviceholder::Ptr ServiceHolder; | |
36 | ||
37 | bool DaemonMode; | |
38 | bool Syslog; | |
39 | bool EnableIPv6; | |
40 | int Loglevel; | |
41 | std::string ConfigPath; | |
42 | std::string WebcheckIpUrl; | |
43 | std::string WebcheckIpUrlAlt; | |
44 | int WebcheckInterval; | |
45 | std::string Proxy; | |
46 | int ProxyPort; | |
47 | std::string ExternalWarningLog; | |
48 | int ExternalWarningLevel; | |
49 | bool StartOffline; | |
50 | bool WebcheckEnabled; | |
51 | bool ExternalLogOnlyOnce; | |
2e9bd873 TJ |
52 | bool DialupMode; |
53 | int DialupBurstPeriodSeconds; | |
54 | int DialupSleepSeconds; | |
6114d87c | 55 | std::string WanIpOverride; |
4f63f66e BS |
56 | |
57 | 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); | |
58 | int load_main_config_file(const std::string& full_filename); | |
59 | int load_service_config_file(const std::string& full_filename); | |
38a04d54 | 60 | void define_config_options(); |
4f63f66e BS |
61 | |
62 | public: | |
63 | ||
64 | typedef boost::shared_ptr<Config> Ptr; | |
65 | ||
66 | Config(); | |
67 | ||
68 | Config(Logger::Ptr _log, Serviceholder::Ptr _serviceholder); | |
69 | ||
70 | ~Config(); | |
71 | ||
72 | int parse_cmd_line(int argc, char *argv[]); | |
73 | ||
74 | int load_config_from_files(); | |
75 | ||
76 | boost::shared_ptr<boost::program_options::options_description> get_opt_desc_cmd() const; | |
77 | ||
78 | boost::shared_ptr<boost::program_options::options_description> get_opt_desc_conf_main() const; | |
79 | ||
80 | boost::shared_ptr<boost::program_options::options_description> get_opt_desc_conf_service() const; | |
81 | ||
82 | bool get_daemon_mode() const; | |
83 | ||
84 | int get_loglevel() const; | |
85 | ||
86 | bool get_syslog() const; | |
87 | ||
88 | bool get_enable_ipv6() const; | |
89 | ||
90 | std::string get_proxy() const; | |
91 | ||
92 | int get_proxy_port() const; | |
93 | ||
94 | bool get_webcheck_enabled() const; | |
95 | ||
96 | void set_webcheck_enabled( bool webcheck_enabled ); | |
97 | ||
98 | std::string get_webcheck_ip_url() const; | |
99 | ||
100 | std::string get_webcheck_ip_url_alt() const; | |
101 | ||
102 | int get_webcheck_interval() const; | |
103 | ||
104 | void delete_variables_map(); | |
105 | ||
106 | int get_external_warning_level() const; | |
107 | ||
108 | std::string get_external_warning_log() const; | |
109 | ||
110 | bool get_start_offline() const; | |
111 | ||
112 | bool get_external_log_only_once() const; | |
113 | ||
2e9bd873 TJ |
114 | bool get_dialup_mode() const; |
115 | int get_dialup_burst_period_seconds() const; | |
116 | int get_dialup_sleep_seconds() const; | |
6114d87c TJ |
117 | |
118 | std::string get_wan_ip_override() const; | |
4f63f66e BS |
119 | }; |
120 | ||
121 | #endif |