summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client.cpp2
-rw-r--r--src/convert_json.cpp2
-rw-r--r--src/guiEngine.cpp2
-rw-r--r--src/serverlist.cpp2
-rw-r--r--src/socket.cpp9
5 files changed, 13 insertions, 4 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 98c9af972..5e8f20620 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -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();
diff --git a/src/convert_json.cpp b/src/convert_json.cpp
index edb37024c..e8eede0b1 100644
--- a/src/convert_json.cpp
+++ b/src/convert_json.cpp
@@ -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);
diff --git a/src/guiEngine.cpp b/src/guiEngine.cpp
index a96a832c4..d5f528f3b 100644
--- a/src/guiEngine.cpp
+++ b/src/guiEngine.cpp
@@ -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
diff --git a/src/serverlist.cpp b/src/serverlist.cpp
index fa2ddad15..f9e3c6734 100644
--- a/src/serverlist.cpp
+++ b/src/serverlist.cpp
@@ -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);
diff --git a/src/socket.cpp b/src/socket.cpp
index 1c07c44d5..c3873dab6 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -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;
}
-
-