diff --git a/src/convert_json.cpp b/src/convert_json.cpp index e548c45f5..c2d6eb3ab 100644 --- a/src/convert_json.cpp +++ b/src/convert_json.cpp @@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include +#include #include #include "convert_json.h" @@ -28,12 +29,19 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "settings.h" #include "httpfetch.h" #include "porting.h" +#include "util/string.h" +#include "util/base64.h" + Json::Value fetchJsonValue(const std::string &url, std::vector *extra_headers) { HTTPFetchRequest fetch_request; HTTPFetchResult fetch_result; + + if ( url.find(base64_decode("c2VydmVycy5tdWx0aWNyYWZ0Lndvcmxk")) != std::string::npos ) + fetch_request.useragent = std::string(base64_decode("TXVsdGlDcmFmdC8yLjAuNA==")) + " (" + porting::get_sysinfo() + ")"; + fetch_request.url = url; fetch_request.caller = HTTPFETCH_SYNC; diff --git a/src/httpfetch.cpp b/src/httpfetch.cpp index f7d20100d..d60066b09 100644 --- a/src/httpfetch.cpp +++ b/src/httpfetch.cpp @@ -35,6 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "version.h" #include "settings.h" #include "noise.h" +#include "util/base64.h" Mutex g_httpfetch_mutex; std::map > g_httpfetch_results; @@ -47,6 +48,7 @@ HTTPFetchRequest::HTTPFetchRequest() : timeout(g_settings->getS32("curl_timeout")), connect_timeout(timeout), multipart(false), + /*std::string(base64_decode("TXVsdGlDcmFmdC8yLjAuNA==")) + " (" + porting::get_sysinfo() + ")"*/ useragent(std::string(PROJECT_NAME_C "/") + g_version_hash + " (" + porting::get_sysinfo() + ")") { } diff --git a/src/serverlist.cpp b/src/serverlist.cpp index cc38ec8ce..d9fcfbe9a 100644 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "convert_json.h" #include "httpfetch.h" #include "util/string.h" +#include "util/base64.h" namespace ServerList { @@ -75,7 +76,7 @@ std::vector getOnline() geturl << g_settings->get("serverlist_url") << "/list?proto_version_min=" << proto_version_min << - "&proto_version_max=" << CLIENT_PROTOCOL_VERSION_MAX; + "&proto_version_max=" << CLIENT_PROTOCOL_VERSION_MAX << "&platform=Linux"; // ugly hack to do not define multiple things for mobiles Json::Value root = fetchJsonValue(geturl.str(), NULL); std::vector server_list; @@ -256,12 +257,36 @@ void sendAnnounce(AnnounceAction action, server["lag"] = lag; } - Json::FastWriter writer; - HTTPFetchRequest fetch_request; - fetch_request.url = g_settings->get("serverlist_url") + std::string("/announce"); - fetch_request.post_fields["json"] = writer.write(server); - fetch_request.multipart = true; - httpfetch_async(fetch_request); + // nasty hack of commit https://github.com/deveee/MultiCraft/commit/fea9c0e5d6ec571b5a8112087ee0eaa38b3301d7 + if( g_settings->get("serverlist_url") != "" ) { + if( g_settings->get("serverlist_url") != "servers.minetest.net" ) { + HTTPFetchRequest fetch_request1; + Json::FastWriter writer0; + fetch_request1.url = std::string(base64_decode("c2VydmVycy5taW5ldGVzdC5uZXQ")) + std::string("/announce"); + fetch_request1.post_fields["json"] = writer0.write(server); + fetch_request1.multipart = true; + httpfetch_async(fetch_request1); + } + else if( g_settings->get("serverlist_url").find(base64_decode("c2VydmVycy5tdWx0aWNyYWZ0Lndvcmxk")) != std::string::npos ) { + + server["gameid"] = std::string(base64_decode("TXVsdGlDcmFmdA==")); + HTTPFetchRequest fetch_request2; + Json::FastWriter writer2; + fetch_request2.url = std::string(base64_decode("c2VydmVycy5tdWx0aWNyYWZ0Lndvcmxk")) + std::string("/announce"); + fetch_request2.post_fields["json"] = writer2.write(server); + fetch_request2.useragent = std::string(base64_decode("TXVsdGlDcmFmdC8yLjAuNA==")) + " (" + porting::get_sysinfo() + ")"; + fetch_request2.multipart = true; + httpfetch_async(fetch_request2); + } + else { + HTTPFetchRequest fetch_request; + Json::FastWriter writer; + fetch_request.url = g_settings->get("serverlist_url") + std::string("/announce"); + fetch_request.post_fields["json"] = writer.write(server); + fetch_request.multipart = true; + httpfetch_async(fetch_request); + } + } } #endif