/**
* Get the actual IP of this host through a conventional DNS query or through a IP webcheck URL if configured so.
+ * @param changed_to_online Indicates if we just went online
* @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 )
+string IPAddrHelper::get_actual_ip( bool use_webcheck, bool changed_to_online )
{
string ip;
if ( !WebcheckIpUrl.empty() && use_webcheck )
- ip = webcheck_ip();
+ ip = webcheck_ip(changed_to_online);
else
ip = get_local_wan_nic_ip();
/**
* Get the actual IP of this host through a IP webcheck URL.
+ * @param changed_to_online Indicates if we just went online
* @return A string representation of the actual IP in dotted format or an empty string if something went wrong.
*/
-string IPAddrHelper::webcheck_ip()
+string IPAddrHelper::webcheck_ip(bool changed_to_online)
{
// Init IPAddress with a empty string.
string ip_addr = "";
time_t current_time = time(NULL);
// Test if webcheck is allowed due to webcheck_interval.
- if ( (LastWebcheck + ((time_t)WebcheckInterval*60)) >= current_time )
+ // Ignored if we just went online.
+ if ( !changed_to_online && (LastWebcheck + ((time_t)WebcheckInterval*60)) >= current_time )
{
// Webcheck not allowed, log it and return empty string.
Log->print_webcheck_exceed_interval( LastWebcheck, (WebcheckInterval*60), current_time );