Correct useragent in http queries
authorproller <proler@github.com>
Tue, 5 Nov 2013 12:57:43 +0000 (16:57 +0400)
committerproller <proler@github.com>
Tue, 5 Nov 2013 20:50:32 +0000 (00:50 +0400)
Net struct init

src/client.cpp
src/convert_json.cpp
src/guiEngine.cpp
src/serverlist.cpp
src/socket.cpp

index 98c9af972dadb428f74b65e27a00ac715f2c4fdc..5e8f20620f5b9b66000b552ff8541db0afdc3c45 100644 (file)
@@ -48,6 +48,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "util/serialize.h"
 #include "config.h"
 #include "util/directiontables.h"
+#include "version.h"
 
 #if USE_CURL
 #include <curl/curl.h>
@@ -245,6 +246,7 @@ void * MediaFetchThread::Thread()
                std::ostringstream stream;
                curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_write_data);
                curl_easy_setopt(curl, CURLOPT_WRITEDATA, &stream);
+               curl_easy_setopt(curl, CURLOPT_USERAGENT, (std::string("Minetest ")+minetest_version_hash).c_str());
                res = curl_easy_perform(curl);
                if (res == CURLE_OK) {
                        std::string data = stream.str();
index edb37024ca98ffbcecbba885924ab3db59c9c151..e8eede0b1edb435d2d6a7d92bfb7afd3c7c5f094 100644 (file)
@@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "log.h"
 #include "main.h" // for g_settings
 #include "settings.h"
+#include "version.h"
 
 #if USE_CURL
 #include <curl/curl.h>
@@ -56,6 +57,7 @@ Json::Value                 fetchJsonValue(const std::string url,
                curl_easy_setopt(curl, CURLOPT_WRITEDATA, &liststring);
                curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, g_settings->getS32("curl_timeout"));
                curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, g_settings->getS32("curl_timeout"));
+               curl_easy_setopt(curl, CURLOPT_USERAGENT, (std::string("Minetest ")+minetest_version_hash).c_str());
 
                if (chunk != 0)
                        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
index a96a832c452b1a9ad49c48ff12385b9ed0033907..d5f528f3b0ed30501a9de0399380b474ee38be6a 100644 (file)
@@ -532,7 +532,7 @@ bool GUIEngine::downloadFile(std::string url,std::string target) {
                        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
                        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
                        curl_easy_setopt(curl, CURLOPT_WRITEDATA, targetfile);
-
+                       curl_easy_setopt(curl, CURLOPT_USERAGENT, (std::string("Minetest ")+minetest_version_hash).c_str());
                        res = curl_easy_perform(curl);
                        if (res != CURLE_OK) {
                                errorstream << "File at url \"" << url
index fa2ddad1579d35d12434e01ed7cb94ef17d5b2e0..f9e3c6734d86485737ba30e3da81dcce2d9314f7 100644 (file)
@@ -241,7 +241,7 @@ void sendAnnounce(std::string action, const std::vector<std::string> & clients_n
                CURLcode res;
                curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
                curl_easy_setopt(curl, CURLOPT_URL, (g_settings->get("serverlist_url")+std::string("/announce?json=")+curl_easy_escape(curl, writer.write( server ).c_str(), 0)).c_str());
-               //curl_easy_setopt(curl, CURLOPT_USERAGENT, "minetest");
+               curl_easy_setopt(curl, CURLOPT_USERAGENT, (std::string("Minetest ")+minetest_version_hash).c_str());
                curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, ServerList::ServerAnnounceCallback);
                //curl_easy_setopt(curl, CURLOPT_WRITEDATA, &liststring);
                curl_easy_setopt(curl, CURLOPT_TIMEOUT, 1);
index 1c07c44d5839e350b0913ef04bd7a6faec55b743..c3873dab65131ab314cc2a4f8b5666b653c36263 100644 (file)
@@ -345,6 +345,8 @@ void UDPSocket::Bind(u16 port)
        if(m_addr_family == AF_INET6)
        {
                struct sockaddr_in6 address;
+               memset(&address, 0, sizeof(address));
+
                address.sin6_family = AF_INET6;
                address.sin6_addr   = in6addr_any;
                address.sin6_port   = htons(port);
@@ -360,6 +362,8 @@ void UDPSocket::Bind(u16 port)
        else
        {
                struct sockaddr_in address;
+               memset(&address, 0, sizeof(address));
+
                address.sin_family      = AF_INET;
                address.sin_addr.s_addr = INADDR_ANY;
                address.sin_port        = htons(port);
@@ -454,6 +458,7 @@ int UDPSocket::Receive(Address & sender, void * data, int size)
        if(m_addr_family == AF_INET6)
        {
                struct sockaddr_in6 address;
+               memset(&address, 0, sizeof(address));
                socklen_t address_len = sizeof(address);
 
                received = recvfrom(m_handle, (char *) data,
@@ -470,6 +475,8 @@ int UDPSocket::Receive(Address & sender, void * data, int size)
        else
        {
                struct sockaddr_in address;
+               memset(&address, 0, sizeof(address));
+
                socklen_t address_len = sizeof(address);
 
                received = recvfrom(m_handle, (char *) data,
@@ -568,5 +575,3 @@ bool UDPSocket::WaitData(int timeout_ms)
        // There is data
        return true;
 }
-
-