Fix another user-agent pointer bug. Fix user-agent string
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Thu, 14 Oct 2010 13:48:23 +0000 (15:48 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Thu, 14 Oct 2010 13:48:23 +0000 (15:48 +0200)
src/ip_addr_helper.cpp

index 429356a..49c4b9a 100644 (file)
@@ -14,6 +14,7 @@
 #include <sys/socket.h>
 #include <netdb.h>
 #include <ifaddrs.h>
+#include "version_info.h"
 
 
 using namespace std;
@@ -556,7 +557,9 @@ CURLcode IPAddrHelper::set_curl_url(CURL * curl_easy_handle, const string& url)
  */
 CURL * IPAddrHelper::init_curl(string& curl_writedata_buff,char* curl_err_buff) const
 {
-    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 )
@@ -580,7 +583,7 @@ CURL * IPAddrHelper::init_curl(string& curl_writedata_buff,char* curl_err_buff)
     if ( curlError == CURLE_OK)
         curlError = curl_easy_setopt(curl_easy_handle,CURLOPT_WRITEDATA,&curl_writedata_buff);
     if ( curlError == CURLE_OK)
-        curlError = curl_easy_setopt(curl_easy_handle,CURLOPT_USERAGENT,&user_agent);
+        curlError = curl_easy_setopt(curl_easy_handle,CURLOPT_USERAGENT,user_agent.c_str());
 
     if ( !Proxy.empty() )
     {