mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-12-02 22:18:09 +01:00
linux (compat): Add linux to most Win64 guards
This commit is contained in:
1 parent
8cf5675892
commit
9626065598
180 files changed
+941
-935
No files matched your search
@@ -14,7 +14,7 @@
|
||||
#include "../Minecraft.World/net.minecraft.world.item.h"
|
||||
#include "../Minecraft.World/SharedConstants.h"
|
||||
#include "Settings.h"
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#if (defined(_WINDOWS64) || defined(__linux__)) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include "Common/Network/GameNetworkManager.h"
|
||||
@@ -33,11 +33,11 @@
|
||||
|
||||
Random *PendingConnection::random = new Random();
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#if defined(_WINDOWS64) || defined(__linux__)
|
||||
bool g_bRejectDuplicateNames = true;
|
||||
#endif
|
||||
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#if (defined(_WINDOWS64) || defined(__linux__)) && defined(MINECRAFT_SERVER_BUILD)
|
||||
namespace
|
||||
{
|
||||
static SOCKET GetWindowsTransportSocket(unsigned char smallId)
|
||||
@@ -131,7 +131,7 @@ void PendingConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet)
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#if (defined(_WINDOWS64) || defined(__linux__)) && defined(MINECRAFT_SERVER_BUILD)
|
||||
{
|
||||
std::string connectionIp = "";
|
||||
int connectionPort = 0;
|
||||
@@ -178,7 +178,7 @@ void PendingConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#if (defined(_WINDOWS64) || defined(__linux__)) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (ServerRuntime::Security::GetSettings().onlineMode)
|
||||
{
|
||||
if (m_verifyTicket != nullptr || m_onlineVerified)
|
||||
@@ -197,7 +197,7 @@ void PendingConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet)
|
||||
|
||||
void PendingConnection::tickOnlineVerify()
|
||||
{
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#if (defined(_WINDOWS64) || defined(__linux__)) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (m_verifyTicket == nullptr || done)
|
||||
return;
|
||||
int state = m_verifyTicket->state.load();
|
||||
@@ -258,7 +258,7 @@ void PendingConnection::sendPreLoginResponse()
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#if (defined(_WINDOWS64) || defined(__linux__)) && defined(MINECRAFT_SERVER_BUILD)
|
||||
// Security: strip real XUIDs from pre-login response to prevent unauthenticated enumeration.
|
||||
// The client receives the correct player count but cannot identify who is connected.
|
||||
// Real XUID data is sent post-login via PlayerInfoPacket broadcasts.
|
||||
@@ -305,7 +305,7 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#if (defined(_WINDOWS64) || defined(__linux__)) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (ServerRuntime::Security::GetSettings().onlineMode)
|
||||
{
|
||||
if (!m_onlineVerified || packet->m_onlineXuid != m_verifiedXuid || _wcsicmp(packet->userName.c_str(), name.c_str()) != 0)
|
||||
@@ -323,7 +323,7 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
|
||||
//if (true)// 4J removed !server->onlineMode)
|
||||
bool sentDisconnect = false;
|
||||
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#if (defined(_WINDOWS64) || defined(__linux__)) && defined(MINECRAFT_SERVER_BUILD)
|
||||
{
|
||||
std::string connectionIp = "";
|
||||
int connectionPort = 0;
|
||||
@@ -396,7 +396,7 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
|
||||
duplicateXuid = true;
|
||||
}
|
||||
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#if (defined(_WINDOWS64) || defined(__linux__)) && defined(MINECRAFT_SERVER_BUILD)
|
||||
// Cross-reference: if someone claims the same XUID as an existing player from a different IP,
|
||||
// log and reject as a potential spoofing attempt.
|
||||
// Note: this runs on the main tick thread (via PendingConnection::tick -> Connection::tick ->
|
||||
@@ -457,7 +457,7 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
|
||||
}
|
||||
|
||||
bool whitelistSatisfied = true;
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#if (defined(_WINDOWS64) || defined(__linux__)) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (ServerRuntime::Access::IsWhitelistEnabled())
|
||||
{
|
||||
whitelistSatisfied = false;
|
||||
@@ -478,14 +478,14 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
|
||||
}
|
||||
else if (bannedXuid)
|
||||
{
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#if (defined(_WINDOWS64) || defined(__linux__)) && defined(MINECRAFT_SERVER_BUILD)
|
||||
ServerRuntime::ServerLogManager::OnRejectedPlayerLogin(GetPendingConnectionSmallId(connection), name, ServerRuntime::ServerLogManager::eLoginRejectReason_BannedXuid);
|
||||
#endif
|
||||
disconnect(DisconnectPacket::eDisconnect_Banned);
|
||||
}
|
||||
else if (!whitelistSatisfied)
|
||||
{
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#if (defined(_WINDOWS64) || defined(__linux__)) && defined(MINECRAFT_SERVER_BUILD)
|
||||
// Cache name->XUID so `whitelist add <name>` can resolve the XUID
|
||||
ServerRuntime::ServerLogManager::CachePlayerXuid(name, loginXuid);
|
||||
ServerRuntime::ServerLogManager::OnRejectedPlayerLogin(GetPendingConnectionSmallId(connection), name, ServerRuntime::ServerLogManager::eLoginRejectReason_NotWhitelisted);
|
||||
@@ -496,7 +496,7 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
|
||||
}
|
||||
else if (duplicateXuid)
|
||||
{
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#if (defined(_WINDOWS64) || defined(__linux__)) && defined(MINECRAFT_SERVER_BUILD)
|
||||
ServerRuntime::ServerLogManager::OnRejectedPlayerLogin(GetPendingConnectionSmallId(connection), name, ServerRuntime::ServerLogManager::eLoginRejectReason_DuplicateXuid);
|
||||
#endif
|
||||
// Reject the incoming connection — a player with this UID is already
|
||||
@@ -505,7 +505,7 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
|
||||
app.DebugPrintf("LOGIN: Rejecting duplicate xuid for name: %ls\n", name.c_str());
|
||||
disconnect(DisconnectPacket::eDisconnect_Banned);
|
||||
}
|
||||
#ifdef _WINDOWS64
|
||||
#if defined(_WINDOWS64) || defined(__linux__)
|
||||
else if (g_bRejectDuplicateNames)
|
||||
{
|
||||
bool nameTaken = false;
|
||||
@@ -520,7 +520,7 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
|
||||
}
|
||||
if (nameTaken)
|
||||
{
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#if (defined(_WINDOWS64) || defined(__linux__)) && defined(MINECRAFT_SERVER_BUILD)
|
||||
ServerRuntime::ServerLogManager::OnRejectedPlayerLogin(GetPendingConnectionSmallId(connection), name, ServerRuntime::ServerLogManager::eLoginRejectReason_DuplicateName);
|
||||
#endif
|
||||
app.DebugPrintf("Rejecting duplicate name: %ls\n", name.c_str());
|
||||
@@ -573,7 +573,7 @@ void PendingConnection::handleAcceptedLogin(shared_ptr<LoginPacket> packet)
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#if (defined(_WINDOWS64) || defined(__linux__)) && defined(MINECRAFT_SERVER_BUILD)
|
||||
{
|
||||
std::string connectionIp = "";
|
||||
int connectionPort = 0;
|
||||
@@ -633,7 +633,7 @@ void PendingConnection::handleAcceptedLogin(shared_ptr<LoginPacket> packet)
|
||||
PlayerUID playerXuid = packet->m_offlineXuid;
|
||||
if(playerXuid == INVALID_XUID) playerXuid = packet->m_onlineXuid;
|
||||
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#if (defined(_WINDOWS64) || defined(__linux__)) && defined(MINECRAFT_SERVER_BUILD)
|
||||
// Cache name->XUID for console commands (whitelist add, revoketoken, etc.)
|
||||
ServerRuntime::ServerLogManager::CachePlayerXuid(name, playerXuid);
|
||||
#endif
|
||||
@@ -641,7 +641,7 @@ void PendingConnection::handleAcceptedLogin(shared_ptr<LoginPacket> packet)
|
||||
shared_ptr<ServerPlayer> playerEntity = server->getPlayers()->getPlayerForLogin(this, name, playerXuid,packet->m_onlineXuid);
|
||||
if (playerEntity != nullptr)
|
||||
{
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#if (defined(_WINDOWS64) || defined(__linux__)) && defined(MINECRAFT_SERVER_BUILD)
|
||||
ServerRuntime::ServerLogManager::OnAcceptedPlayerLogin(GetPendingConnectionSmallId(connection), name,
|
||||
packet->m_offlineXuid, packet->m_onlineXuid, packet->m_isGuest);
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user