Skip to content

Commit 283159c

Browse files
DustyBagelDustyBagel
DustyBagel
authored and
DustyBagel
committed
Readd Server proto
1 parent 6c614eb commit 283159c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/network/lan.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ typedef int socket_t;
6969

7070
const char* adv_multicast_addr = "224.1.1.1";
7171
const static unsigned short int adv_port = 29998;
72+
const char* proto = "Luanti";
7273
static std::string ask_str;
7374

7475
bool use_ipv6 = true;
@@ -84,6 +85,7 @@ void lan_adv::ask()
8485
if (ask_str.empty()) {
8586
Json::Value j;
8687
j["cmd"] = "ask";
88+
j["proto"] = proto;
8789
ask_str = fastWriteJson(j);
8890
}
8991

@@ -258,6 +260,7 @@ void *lan_adv::run()
258260
server["port"] = server_port;
259261
server["clients"] = clients_num.load();
260262
server["clients_max"] = g_settings->getU16("max_users");
263+
server["proto"] = proto;
261264

262265
send_string(fastWriteJson(server));
263266
}
@@ -280,7 +283,7 @@ void *lan_adv::run()
280283
if (server_port) {
281284
if (p["cmd"] == "ask" && limiter[addr_str] < now) {
282285
(clients_num.load() ? infostream : actionstream)
283-
<< "lan: want play " << addr_str << std::endl;
286+
<< "lan: want play " << addr_str << " " << p["proto"] << std::endl;
284287

285288
server["clients"] = clients_num.load();
286289
answer_str = fastWriteJson(server);
@@ -292,7 +295,7 @@ void *lan_adv::run()
292295
}
293296
} else {
294297
if (p["cmd"] == "ask") {
295-
actionstream << "lan: want play " << addr_str << std::endl;
298+
actionstream << "lan: want play " << addr_str << " " << p["proto"] << std::endl;
296299
}
297300
if (p["port"].isInt()) {
298301
p["address"] = addr_str;
@@ -302,7 +305,7 @@ void *lan_adv::run()
302305
//infostream << "server shutdown " << key << "\n";
303306
collected.erase(key);
304307
fresh = true;
305-
} else {
308+
} else if (p["proto"] == proto) {
306309
if (!collected.count(key))
307310
actionstream << "lan server start " << key << "\n";
308311
collected.insert_or_assign(key, p);

0 commit comments

Comments
 (0)