("enable_ipv6",po::value<bool>()->default_value(false),"Try to use IPv6.")
("webcheck_url",po::value<string>()->default_value(""),"Use this URL to determine IP.")
("webcheck_url_alt",po::value<string>()->default_value(""),"Use this alternative URL to determine IP.")
+ ("http_proxy",po::value<string>()->default_value(""),"Use this proxy for all http requests.")
+ ("http_proxy_port",po::value<int>()->default_value(0),"Port of the proxy.")
;
// Define valid command line parameters
if ( VariablesMap.count("webcheck_url_alt") )
WebcheckIpUrlAlt = VariablesMap["webcheck_url_alt"].as<string>();
+ if ( VariablesMap.count("http_proxy") )
+ Proxy = VariablesMap["http_proxy"].as<string>();
+
+ if ( VariablesMap.count("http_proxy_port") )
+ ProxyPort = VariablesMap["http_proxy_port"].as<int>();
+
}
catch(po::unknown_option e)
{
if ( VariablesMap.count("webcheck_url_alt") )
WebcheckIpUrlAlt = VariablesMap["webcheck_url_alt"].as<string>();
+ if ( VariablesMap.count("http_proxy") )
+ Proxy = VariablesMap["http_proxy"].as<string>();
+
+ if ( VariablesMap.count("http_proxy_port") )
+ ProxyPort = VariablesMap["http_proxy_port"].as<int>();
+
}
catch ( po::unknown_option e ) // at the moment 04-08-2009 this exception is never thrown :-(
{
{
return WebcheckIpUrlAlt;
}
+
+
+/**
+ * Get member Proxy
+ * @return Proxy
+ */
+string Config::get_proxy() const
+{
+ return Proxy;
+}
+
+
+/**
+ * Get member ProxyPort
+ * @return ProxyPort
+ */
+int Config::get_proxy_port() const
+{
+ return ProxyPort;
+}
std::string ConfigPath;
std::string WebcheckIpUrl;
std::string WebcheckIpUrlAlt;
+ std::string Proxy;
+ int ProxyPort;
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);
bool get_enable_ipv6() const;
+ std::string get_proxy() const;
+
+ int get_proxy_port() const;
+
std::string get_webcheck_ip_url() const;
std::string get_webcheck_ip_url_alt() const;
: Hostname("")
, WebcheckIpUrl("")
, WebcheckIpUrlAlt("")
+ , Proxy("")
+ , ProxyPort(0)
, UseIPv6(false)
, Log(new Logger)
{
/**
* Constructor.
*/
-IPHelper::IPHelper(const Logger::Ptr _log, const string& _webcheck_url, const string& _webcheck_url_alt, const bool _use_ipv6)
+IPHelper::IPHelper(const Logger::Ptr _log, const string& _webcheck_url, const string& _webcheck_url_alt, const bool _use_ipv6, const string& _proxy, const int _proxy_port)
: Hostname("")
{
Log = _log;
WebcheckIpUrl = _webcheck_url;
WebcheckIpUrlAlt = _webcheck_url_alt;
+ Proxy = _proxy;
+ ProxyPort = _proxy_port;
UseIPv6 = _use_ipv6;
Hostname = net::ip::host_name();
curl_easy_setopt(curl_easy_handle,CURLOPT_WRITEFUNCTION,http_receive);
curl_easy_setopt(curl_easy_handle,CURLOPT_WRITEDATA,&curl_writedata_buff);
+ if ( !Proxy.empty() )
+ {
+ curl_easy_setopt(curl_easy_handle,CURLOPT_PROXY,Proxy);
+ curl_easy_setopt(curl_easy_handle,CURLOPT_PROXYPORT,ProxyPort);
+ }
+
return curl_easy_handle;
}
std::string Hostname;
std::string WebcheckIpUrl;
std::string WebcheckIpUrlAlt;
+ std::string Proxy;
+ int ProxyPort;
bool UseIPv6;
IPHelper();
- IPHelper(const Logger::Ptr _log, const std::string& _webcheck_url, const std::string& _webcheck_url_alt, const bool _use_ipv6);
+ IPHelper(const Logger::Ptr _log, const std::string& _webcheck_url, const std::string& _webcheck_url_alt, const bool _use_ipv6, const std::string& _proxy, const int _proxy_port);
~IPHelper();
int Updater::init_ip_helper()
{
// initialize IPHelper
- IPHelper::Ptr _iphelp(new IPHelper(Log,Conf->get_webcheck_ip_url(),Conf->get_webcheck_ip_url_alt(),Conf->get_enable_ipv6()));
+ IPHelper::Ptr _iphelp(new IPHelper(Log,Conf->get_webcheck_ip_url(),Conf->get_webcheck_ip_url_alt(),Conf->get_enable_ipv6(),Conf->get_proxy(),Conf->get_proxy_port()));
IPHelp = _iphelp;
_iphelp.reset();
if ( service->get_last_updates()->size() > 0 )
lastupdated = service->get_last_updates()->front();
+ // If the dns cache ttl is expired, then get the actual ip of the dns record (this should be the IP in the last update)
if ( (lastupdated != 0) && ((lastupdated + service->get_dns_cache_ttl()) < current_time) )
{
Log->print_recheck_dns_entry(service->get_hostname(),lastupdated,service->get_dns_cache_ttl(),current_time);
dns_recheck_ip = _dns_recheck_ip;
}
+ // In case the local hosts IP (ip) differ from the IP set in the last update (actual_ip) or
+ // the IP of the dns record (dns_recheck_ip) differs from the IP of the local host (ip)
+ // then perform an update. This implies that the update is not performed if actual_ip == dns_recheck_ip.
if ( (service->get_actual_ip() != ip) || (dns_recheck_ip != ip) )
service->update(ip,current_time);
}