DYNDNS protocol from now on accepts alternative update server name.
authorBjoern Sikora <bjoern.sikora@intra2net.com>
Wed, 13 Oct 2010 11:55:16 +0000 (13:55 +0200)
committerBjoern Sikora <bjoern.sikora@intra2net.com>
Wed, 13 Oct 2010 11:57:44 +0000 (13:57 +0200)
Verions is loaded from version_info.h.

src/config.cpp
src/httphelper.cpp
src/service_dyndns.cpp
src/service_dyndns.hpp

index 401f4c1..b3b1494 100644 (file)
@@ -107,7 +107,7 @@ void Config::define_config_options()
     po::options_description opt_desc_service("Service description options");
     opt_desc_service.add_options()
         ("protocol",po::value<string>(),"The service protocol.")
-        ("server",po::value<string>(),"Servername needed for gnudip protocol.")
+        ("server",po::value<string>(),"Servername needed for gnudip/dyndns protocol.")
         ("host",po::value<string>(),"The hostname to update.")
         ("login",po::value<string>(),"Login name.")
         ("password",po::value<string>(),"Corresponding password.")
@@ -352,7 +352,7 @@ Service::Ptr Config::create_service(const string &protocol, const string& server
     }
     else if(protocol == "dyndns")
     {
-        Service::Ptr service_dyndns(new ServiceDyndns(protocol,hostname,login,password,Log,update_interval,max_updates_within_interval,dns_cache_ttl,Proxy,ProxyPort));
+        Service::Ptr service_dyndns(new ServiceDyndns(protocol,hostname,login,password,Log,update_interval,max_updates_within_interval,dns_cache_ttl,Proxy,ProxyPort,server));
         return service_dyndns;
     }
     else if(protocol == "dyns")
index a728d4e..474e79f 100644 (file)
@@ -8,6 +8,7 @@
 */
 
 #include "httphelper.hpp"
+#include "version_info.h"
 
 using namespace std;
 
@@ -164,7 +165,9 @@ string HTTPHelper::get_curl_data() const
 CURL* HTTPHelper::init_curl(string& curl_writedata_buff,char* curl_err_buff)
 {
     CurlInitError = CURLE_OK;
-    string user_agent = "Intra2net AG - Bullet Proof DYNDNS Daemon - 0.1.1";
+    ostringstream user_agent_stream;
+    user_agent_stream << "Intra2net AG - Bullet Proof DYNDNS Daemon - " << MAJOR_VERSION << "." << MINOR_VERSION << endl;
+    string user_agent = user_agent_stream.str();
 
     CURL *curl_easy_handle = curl_easy_init();
     if ( curl_easy_handle == NULL )
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=");
index 4be4e12..fb0da1c 100644 (file)
@@ -30,6 +30,7 @@ private:
         ar & boost::serialization::base_object<Service>(*this);
     }
 
+    std::string AlternativeServer;  // Needed for NO-IP
     std::string BaseUrl;
 
     HTTPHelper::Ptr HTTPHelp;
@@ -42,7 +43,7 @@ public:
 
     ServiceDyndns();
 
-    ServiceDyndns(const std::string& _protocol, const std::string& _hostname, const std::string& _login, const std::string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int dns_cache_ttl, const std::string& proxy, const int proxy_port);
+    ServiceDyndns(const std::string& _protocol, const std::string& _hostname, const std::string& _login, const std::string& _password, const Logger::Ptr& _logger, const int _update_interval, const int _max_updates_within_interval, const int dns_cache_ttl, const std::string& proxy, const int proxy_port, const std::string& _alternative_server = "");
 
     ~ServiceDyndns();