From f04a7cb4c9bc05e1d5c5b477b165b5f1968b3514 Mon Sep 17 00:00:00 2001 From: Bjoern Sikora Date: Wed, 13 Oct 2010 13:55:16 +0200 Subject: [PATCH] DYNDNS protocol from now on accepts alternative update server name. Verions is loaded from version_info.h. --- src/config.cpp | 4 ++-- src/httphelper.cpp | 5 ++++- src/service_dyndns.cpp | 12 +++++++++--- src/service_dyndns.hpp | 3 ++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index 401f4c1..b3b1494 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -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(),"The service protocol.") - ("server",po::value(),"Servername needed for gnudip protocol.") + ("server",po::value(),"Servername needed for gnudip/dyndns protocol.") ("host",po::value(),"The hostname to update.") ("login",po::value(),"Login name.") ("password",po::value(),"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") diff --git a/src/httphelper.cpp b/src/httphelper.cpp index a728d4e..474e79f 100644 --- a/src/httphelper.cpp +++ b/src/httphelper.cpp @@ -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 ) diff --git a/src/service_dyndns.cpp b/src/service_dyndns.cpp index a298a10..cb48fd3 100644 --- a/src/service_dyndns.cpp +++ b/src/service_dyndns.cpp @@ -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="); diff --git a/src/service_dyndns.hpp b/src/service_dyndns.hpp index 4be4e12..fb0da1c 100644 --- a/src/service_dyndns.hpp +++ b/src/service_dyndns.hpp @@ -30,6 +30,7 @@ private: ar & boost::serialization::base_object(*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(); -- 1.7.1