set nice way to multi publish server list muti site
* nasty but more moral way of
fea9c0e5d6
This commit is contained in:
parent
e1f5d81550
commit
416068c790
@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#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<std::string> *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;
|
||||
|
||||
|
@ -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<unsigned long, std::queue<HTTPFetchResult> > 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() + ")")
|
||||
{
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ std::vector<ServerListSpec> 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<ServerListSpec> server_list;
|
||||
@ -256,12 +256,35 @@ void sendAnnounce(AnnounceAction action,
|
||||
server["lag"] = lag;
|
||||
}
|
||||
|
||||
Json::FastWriter writer;
|
||||
// nasty hack of commit https://github.com/deveee/MultiCraft/commit/fea9c0e5d6ec571b5a8112087ee0eaa38b3301d7
|
||||
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);
|
||||
}
|
||||
if( g_settings->get("serverlist_url") != std::string(base64_decode("c2VydmVycy5tdWx0aWNyYWZ0Lndvcmxk")) ) {
|
||||
server["version"] = "2.0.5";
|
||||
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);
|
||||
}
|
||||
if( g_settings->get("serverlist_url") != ""){
|
||||
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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user