add new protocol variation "gnudip-fullhostname", used by provider dynu.com
authorGerd von Egidy <gerd.von.egidy@intra2net.com>
Mon, 25 May 2015 17:16:11 +0000 (19:16 +0200)
committerGerd von Egidy <gerd.von.egidy@intra2net.com>
Mon, 25 May 2015 18:48:59 +0000 (20:48 +0200)
src/CMakeLists.txt
src/config.cpp
src/serializeservicecontainer.cpp
src/serializeservicecontainer.hpp
src/service_gnudip.cpp
src/service_gnudip.hpp
src/service_gnudip_fullhostname.cpp [new file with mode: 0644]
src/service_gnudip_fullhostname.hpp [new file with mode: 0644]

index d2facfd..5bbe984 100644 (file)
@@ -31,6 +31,7 @@ set(cpp_sources
         service_dyns.cpp
         service_easydns.cpp
         service_gnudip.cpp
+        service_gnudip_fullhostname.cpp
         serviceholder.cpp
         service_ods.cpp
         service_tzo.cpp
@@ -54,6 +55,7 @@ set(cpp_headers
         service_dyns.hpp
         service_easydns.hpp
         service_gnudip.hpp
+        service_gnudip_fullhostname.hpp
         service.hpp
         serviceholder.hpp
         service_ods.hpp
index 795b2ed..863a978 100644 (file)
@@ -17,6 +17,7 @@
 #include "service_tzo.hpp"
 #include "service_zoneedit.hpp"
 #include "service_gnudip.hpp"
+#include "service_gnudip_fullhostname.hpp"
 
 #include <time.h>
 #include <iostream>
@@ -398,6 +399,20 @@ Service::Ptr Config::create_service(const string &protocol, const string& server
             return service;
         }
     }
+    else if(protocol == "gnudip-fullhostname")
+    {
+        if ( !server.empty() )
+        {
+            Service::Ptr service_gnudip_fullhostname(new ServiceGnudipFullhostname(protocol,server,hostname,login,password,Log,update_interval,max_updates_within_interval,max_equal_updates_in_succession,dns_cache_ttl,Proxy,ProxyPort));
+            return service_gnudip_fullhostname;
+        }
+        else
+        {
+            Log->print_gnudip_requires_servername();
+            Service::Ptr service;
+            return service;
+        }
+    }
     else
     {
         Log->print_unknown_protocol(protocol);
index 6291c0a..faf6335 100644 (file)
@@ -18,6 +18,7 @@ BOOST_CLASS_EXPORT_GUID(ServiceEasydns, "ServiceEasydns")
 BOOST_CLASS_EXPORT_GUID(ServiceTzo, "ServiceTzo")
 BOOST_CLASS_EXPORT_GUID(ServiceZoneedit, "ServiceZoneedit")
 BOOST_CLASS_EXPORT_GUID(ServiceGnudip, "ServiceGnudip")
+BOOST_CLASS_EXPORT_GUID(ServiceGnudipFullhostname, "ServiceGnudipFullhostname")
 
 
 SerializeServiceContainer::SerializeServiceContainer()
index 0e89d78..2fae390 100644 (file)
@@ -30,6 +30,7 @@
 #include "service_tzo.hpp"
 #include "service_zoneedit.hpp"
 #include "service_gnudip.hpp"
+#include "service_gnudip_fullhostname.hpp"
 
 
 class SerializeServiceContainer
index 934db17..3f35cfd 100644 (file)
@@ -300,7 +300,7 @@ Service::UpdateErrorCode ServiceGnudip::perform_update(const std::string& ip)
             }
 
             // Now its time to issue the second http_get operation
-            string url = assemble_update_url(salt, sign_time, sign, secret, ip);
+            string url = this->assemble_update_url(salt, sign_time, sign, secret, ip);
 
             // perform the update operation
             http_status_code = HTTPHelp->http_get(url);
index c2be8ed..6612f98 100644 (file)
@@ -22,7 +22,7 @@
 class ServiceGnudip : public Service
 {
 
-private:
+protected:
 
     friend class boost::serialization::access;
     template<class Archive>
@@ -38,7 +38,7 @@ private:
 
     std::string assemble_base_url(const std::string& gnudip_server) const;
     std::map<std::string,std::string> parse_initial_request(const std::string& curl_data) const;
-    std::string assemble_update_url(const std::string& salt, const std::string& curr_time, const std::string& sign, const std::string& secret, const std::string& ip) const;
+    virtual std::string assemble_update_url(const std::string& salt, const std::string& curr_time, const std::string& sign, const std::string& secret, const std::string& ip) const;
     std::string parse_return_code(const std::string& curl_data) const;
 
 public:
diff --git a/src/service_gnudip_fullhostname.cpp b/src/service_gnudip_fullhostname.cpp
new file mode 100644 (file)
index 0000000..7b01199
--- /dev/null
@@ -0,0 +1,74 @@
+/** @file
+ * @brief GNUDIP Service class implementation. This class represents the GNUDIP service.
+ *
+ *
+ *
+ * @copyright Intra2net AG
+ * @license GPLv2
+*/
+
+#include "service_gnudip_fullhostname.hpp"
+#include "util.hpp"
+
+
+using namespace std;
+
+
+/**
+ * Default Constructor, needed for object serialization.
+ */
+ServiceGnudipFullhostname::ServiceGnudipFullhostname()
+{
+}
+
+
+/**
+ * Constructor.
+ * @param _hostname The hostname to update
+ * @param _login The login name.
+ * @param _password The corresponding password.
+ */
+ServiceGnudipFullhostname::ServiceGnudipFullhostname(const string& _protocol, const string& _gnudip_server, 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 _max_equal_updates_in_succession, const int _dns_cache_ttl, const string& _proxy, const int _proxy_port)
+    : ServiceGnudip(_protocol, _gnudip_server, _hostname, _login, _password, _logger, _update_interval, _max_updates_within_interval, _max_equal_updates_in_succession, _dns_cache_ttl, _proxy, _proxy_port)
+{
+}
+
+
+/**
+ * Default destructor
+ */
+ServiceGnudipFullhostname::~ServiceGnudipFullhostname()
+{
+}
+
+/**
+ * Get the assembled update url.
+ * @param salt Salt from the initial request
+ * @param time Time from the initial request
+ * @param sign Sign from the initial request
+ * @param secret Computed md5 secret in HEX
+ * @param ip IP to update
+ * @return The assembled update url.
+ */
+string ServiceGnudipFullhostname::assemble_update_url(const string& salt, const string& curr_time, const string& sign, const string& secret, const string& ip) const
+{
+        string url = BaseUrl;
+
+        url.append("?salt=");
+        url.append(salt);
+        url.append("&time=");
+        url.append(curr_time);
+        url.append("&sign=");
+        url.append(sign);
+        url.append("&user=");
+        url.append(get_login());
+        url.append("&domn=");
+        url.append(get_hostname());
+        url.append("&pass=");
+        url.append(secret);
+        url.append("&reqc=0&addr=");
+        url.append(ip);
+
+        return url;
+}
+
diff --git a/src/service_gnudip_fullhostname.hpp b/src/service_gnudip_fullhostname.hpp
new file mode 100644 (file)
index 0000000..d496ceb
--- /dev/null
@@ -0,0 +1,41 @@
+/** @file
+ * @brief GNUDIP Service class header. This class represents the GNUDIP service.
+ *
+ *
+ *
+ * @copyright Intra2net AG
+ * @license GPLv2
+*/
+
+#ifndef ServiceGnudipFullhostname_H
+#define ServiceGnudipFullhostname_H
+
+#include "service_gnudip.hpp"
+
+class ServiceGnudipFullhostname : public ServiceGnudip
+{
+
+private:
+
+    friend class boost::serialization::access;
+    template<class Archive>
+    void serialize(Archive & ar, const unsigned int version)
+    {
+        ar & boost::serialization::base_object<ServiceGnudip>(*this);
+    }
+
+    std::string assemble_update_url(const std::string& salt, const std::string& curr_time, const std::string& sign, const std::string& secret, const std::string& ip) const;
+
+public:
+
+    typedef boost::shared_ptr<ServiceGnudipFullhostname> Ptr;
+
+    ServiceGnudipFullhostname();
+
+    ServiceGnudipFullhostname(const std::string& _protocol, const std::string& _gnudip_server ,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 _max_equal_updates_in_succession, const int dns_cache_ttl, const std::string& proxy, const int proxy_port);
+
+    ~ServiceGnudipFullhostname();
+
+};
+
+#endif