Added possibility to override automatic WAN IP detection
[bpdyndnsd] / src / ip_addr_helper.cpp
index 16359dd..b0b2a84 100644 (file)
@@ -180,15 +180,19 @@ bool IPAddrHelper::is_local_ipv4(const string ip) const
 
 /**
  * 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();