DYNDNS protocol from now on accepts alternative update server name.
[bpdyndnsd] / src / service_dyndns.cpp
index a298a10..cb48fd3 100644 (file)
@@ -28,7 +28,8 @@ ServiceDyndns::ServiceDyndns()
  * @param _login The login name.
  * @param _password The corresponding password.
  */
-ServiceDyndns::ServiceDyndns(const string& _protocol, const string& _hostname, const string& _login, const string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int _dns_cache_ttl, const string& _proxy, const int _proxy_port)
+ServiceDyndns::ServiceDyndns(const string& _protocol, const string& _hostname, const string& _login, const string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int _dns_cache_ttl, const string& _proxy, const int _proxy_port, const string& _alternative_server)
+    : AlternativeServer(_alternative_server)
 {
     if ( _update_interval == -1 )        // If _update_interval is default po::option_desc (not specified via config)
         set_update_interval(0);              // use default protocol value
@@ -73,9 +74,14 @@ ServiceDyndns::~ServiceDyndns()
  */
 string ServiceDyndns::assemble_base_url(const string& fqhn) const
 {
-    string base_url;
+    string base_url = "https://";
+
+    // Test if a AlternativeServer name is given, needed for e.g. NO-IP
+    if ( AlternativeServer.empty() )
+        base_url.append("members.dyndns.org");
+    else
+        base_url.append("dynupdate.no-ip.com");
 
-    base_url = "https://members.dyndns.org";
     base_url.append("/nic/update?hostname=");
     base_url.append(fqhn);
     base_url.append("&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG&myip=");