mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-22 10:21:57 -05:00
Only reply to broadcasts with correct message
This commit is contained in:
parent
59ddd7e1ea
commit
6a4791e39e
3 changed files with 6 additions and 5 deletions
|
@ -102,11 +102,11 @@ private:
|
|||
}
|
||||
else
|
||||
{
|
||||
char buffer[256];
|
||||
size_t recievedBytes;
|
||||
char buffer[256]{};
|
||||
size_t recievedBytes{};
|
||||
std::unique_ptr<INetworkEndpoint> endpoint;
|
||||
auto p = _lanListener->ReceiveData(buffer, sizeof(buffer), &recievedBytes, &endpoint);
|
||||
if (p == NETWORK_READPACKET_SUCCESS)
|
||||
auto p = _lanListener->ReceiveData(buffer, sizeof(buffer) - 1, &recievedBytes, &endpoint);
|
||||
if (p == NETWORK_READPACKET_SUCCESS && String::Equals(buffer, NETWORK_LAN_BROADCAST_MSG))
|
||||
{
|
||||
std::string sender = endpoint->GetHostname();
|
||||
log_verbose("Received %zu bytes from %s on LAN broadcast port", recievedBytes, sender.c_str());
|
||||
|
|
|
@ -240,7 +240,7 @@ std::future<std::vector<ServerListEntry>> ServerList::FetchLocalServerListAsync(
|
|||
constexpr auto RECV_DELAY_MS = 10;
|
||||
constexpr auto RECV_WAIT_MS = 2000;
|
||||
|
||||
std::string msg = "Are you an OpenRCT2 server?";
|
||||
std::string_view msg = NETWORK_LAN_BROADCAST_MSG;
|
||||
auto udpSocket = CreateUdpSocket();
|
||||
|
||||
log_verbose("Broadcasting %zu bytes to the LAN (%s)", msg.size(), broadcastAddress);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#define NETWORK_DEFAULT_PORT 11753
|
||||
#define NETWORK_LAN_BROADCAST_PORT 11754
|
||||
#define NETWORK_LAN_BROADCAST_MSG "openrct2.server.query"
|
||||
#define MAX_SERVER_DESCRIPTION_LENGTH 256
|
||||
|
||||
#include "../common.h"
|
||||
|
|
Loading…
Reference in a new issue