("dialup_mode",po::value<bool>()->default_value(false),"Enable dialup mode (sleep periods between network traffic)")
("dialup_burst_period_seconds",po::value<int>()->default_value(120),"Seconds of normal operation before entering dialup mode")
("dialup_sleep_seconds",po::value<int>()->default_value(10 * 60),"Seconds to sleep between network traffic")
+ ("wan_ip_override",po::value<string>(),"Manual override for automatic WAN IP detection")
;
// Define valid command line parameters
DialupBurstPeriodSeconds = VariablesMap["dialup_burst_period_seconds"].as<int>();
if ( VariablesMap.count("dialup_sleep_seconds") )
DialupSleepSeconds = VariablesMap["dialup_sleep_seconds"].as<int>();
+
+ if ( VariablesMap.count("wan_ip_override") )
+ WanIpOverride = VariablesMap["wan_ip_override"].as<string>();
}
catch( const po::unknown_option& e )
{
DialupBurstPeriodSeconds = VariablesMap["dialup_burst_period_seconds"].as<int>();
if ( VariablesMap.count("dialup_sleep_seconds") )
DialupSleepSeconds = VariablesMap["dialup_sleep_seconds"].as<int>();
+
+ if ( VariablesMap.count("wan_ip_override") )
+ WanIpOverride = VariablesMap["wan_ip_override"].as<string>();
}
catch( const po::unknown_option& e )
{
{
return DialupSleepSeconds;
}
+
+/**
+ * Get WAN override IP (if present)
+ * @return WanIpOverride
+*/
+std::string Config::get_wan_ip_override() const
+{
+ return WanIpOverride;
+}
bool DialupMode;
int DialupBurstPeriodSeconds;
int DialupSleepSeconds;
+ std::string WanIpOverride;
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);
bool get_dialup_mode() const;
int get_dialup_burst_period_seconds() const;
int get_dialup_sleep_seconds() const;
+
+ std::string get_wan_ip_override() const;
};
#endif
/**
* Get the actual IP of this host through a conventional DNS query or through a IP webcheck URL if configured so.
+ * @param use_webcheck If true: Determine IP via web check
* @param changed_to_online Indicates if we just went online
+ * @param wan_override_ip Override automatic WAN IP detection if not empty
* @return A string representation of the actual IP in dotted format or an empty string if something went wrong.
*/
-string IPAddrHelper::get_actual_ip( bool use_webcheck, bool changed_to_online )
+string IPAddrHelper::get_actual_ip( bool use_webcheck, bool changed_to_online, const std::string &wan_override_ip )
{
string ip;
if ( !WebcheckIpUrl.empty() && use_webcheck )
ip = webcheck_ip(changed_to_online);
+ else if (!wan_override_ip.empty())
+ ip = wan_override_ip;
else
ip = get_local_wan_nic_ip();
std::string dns_query(const std::string& _hostname) const;
- std::string get_actual_ip( bool use_webcheck, bool changed_to_online );
+ std::string get_actual_ip( bool use_webcheck, bool changed_to_online, const std::string &wan_override_ip );
std::string get_local_wan_nic_ip() const;
list<Service::Ptr> services = ServiceHolder->get_services();
// Get the actual IP of this host.
- string ip_host = IPAddrHelp->get_actual_ip(Conf->get_webcheck_enabled(), changed_to_online);
+ string ip_host = IPAddrHelp->get_actual_ip(Conf->get_webcheck_enabled(), changed_to_online, Conf->get_wan_ip_override());
if ( ip_host.empty() )
{
Log->print_no_wan_ip(changed_to_online);