mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
The old Windows64 port had no real player identity — it used hardcoded fake XUIDs, so anyone could impersonate anyone. This replaces that with proper auth supporting Mojang, Ely.by, and offline accounts. MCAuth library (new, MCAuth/): Mojang auth via MSA device code flow (XBL, SISU, MC services), Ely.by via Yggdrasil with 2FA, offline UUID generation matching Java Edition (MD5 v3 from "OfflinePlayer:<name>"). Multi-account manager with background token refresh, per-slot sessions, and on-disk token persistence. Server-side session verification via Mojang/Ely.by hasJoined API. Skin fetching and PNG validation from texture servers. Network protocol (version bumped to 80): Three new packets (AuthScheme, AuthResponse, AuthResult) implement a server-driven auth handshake before login completes. Player identity migrated from 64-bit XUID to 128-bit GameUUID backed by two uint64 fields (hi/lo). readPlayerUID/writePlayerUID now serialize 16 bytes on the wire. Old and new clients cannot connect to each other — version mismatch is rejected at PreLogin. Save migration: Map data mappings auto-migrate from old format: the old 64-bit XUID is placed in hi, lo is set to 0 as a sentinel. On first access by the real player, the sentinel entry is upgraded in-place to the full 128-bit UUID. Format detection is by file size (2080, 2112, or 4160 bytes). Player .dat filenames inside saveData.ms change from decimal XUID to dashed UUID — old saves need manual entry renaming in the archive. UI: NativeUIRenderer: immediate-mode drawing system (quads, text, 9-slice panels, scrollbars, focus lists) for rendering auth screens without Flash/Scaleform. UIScene_MSAuth handles device code display, Ely.by credential input with 2FA, per-account skin head preview, and multi-account add/remove/switch. Server: online-mode and auth-provider (mojang/elyby) in server.properties. Whitelist and ban checks validate against the server-verified UUID. Incompatible auth scheme logs which provider the server expects vs what the client is using. Also fixes a pre-existing exploit where any client could send a DebugOptionsPacket to grant themselves CraftAnything and other debug privileges on any server — now requires OP status server-side.
177 lines
6.7 KiB
C++
177 lines
6.7 KiB
C++
#pragma once
|
|
using namespace std;
|
|
#include <vector>
|
|
#include "..\..\..\Minecraft.World\C4JThread.h"
|
|
#include "NetworkPlayerInterface.h"
|
|
#include "PlatformNetworkManagerInterface.h"
|
|
#include "SessionInfo.h"
|
|
|
|
class CPlatformNetworkManagerStub : public CPlatformNetworkManager
|
|
{
|
|
friend class CGameNetworkManager;
|
|
public:
|
|
virtual bool Initialise(CGameNetworkManager *pGameNetworkManager, int flagIndexSize);
|
|
virtual void Terminate();
|
|
virtual int GetJoiningReadyPercentage();
|
|
virtual int CorrectErrorIDS(int IDS);
|
|
|
|
virtual void DoWork();
|
|
virtual int GetPlayerCount();
|
|
virtual int GetOnlinePlayerCount();
|
|
virtual int GetLocalPlayerMask(int playerIndex);
|
|
virtual bool AddLocalPlayerByUserIndex( int userIndex );
|
|
virtual bool RemoveLocalPlayerByUserIndex( int userIndex );
|
|
virtual INetworkPlayer *GetLocalPlayerByUserIndex( int userIndex );
|
|
virtual INetworkPlayer *GetPlayerByIndex(int playerIndex);
|
|
virtual INetworkPlayer * GetPlayerByXuid(PlayerUID xuid);
|
|
virtual INetworkPlayer * GetPlayerBySmallId(unsigned char smallId);
|
|
virtual bool ShouldMessageForFullSession();
|
|
|
|
virtual INetworkPlayer *GetHostPlayer();
|
|
virtual bool IsHost();
|
|
virtual bool JoinGameFromInviteInfo( int userIndex, int userMask, const INVITE_INFO *pInviteInfo);
|
|
virtual bool LeaveGame(bool bMigrateHost);
|
|
|
|
virtual bool IsInSession();
|
|
virtual bool IsInGameplay();
|
|
virtual bool IsReadyToPlayOrIdle();
|
|
virtual bool IsInStatsEnabledSession();
|
|
virtual bool SessionHasSpace(unsigned int spaceRequired = 1);
|
|
virtual void SendInviteGUI(int quadrant);
|
|
virtual bool IsAddingPlayer();
|
|
|
|
virtual void HostGame(int localUsersMask, bool bOnlineGame, bool bIsPrivate, int publicSlots = MINECRAFT_NET_MAX_PLAYERS, int privateSlots = 0);
|
|
virtual int JoinGame(FriendSessionInfo *searchResult, int localUsersMask, int primaryUserIndex );
|
|
virtual bool SetLocalGame(bool isLocal);
|
|
virtual bool IsLocalGame() { return m_bIsOfflineGame; }
|
|
virtual void SetPrivateGame(bool isPrivate);
|
|
virtual bool IsPrivateGame() { return m_bIsPrivateGame; }
|
|
virtual bool IsLeavingGame() { return m_bLeavingGame; }
|
|
virtual void ResetLeavingGame() { m_bLeavingGame = false; }
|
|
|
|
virtual void RegisterPlayerChangedCallback(int iPad, void (*callback)(void *callbackParam, INetworkPlayer *pPlayer, bool leaving), void *callbackParam);
|
|
virtual void UnRegisterPlayerChangedCallback(int iPad, void (*callback)(void *callbackParam, INetworkPlayer *pPlayer, bool leaving), void *callbackParam);
|
|
|
|
virtual void HandleSignInChange();
|
|
|
|
virtual bool _RunNetworkGame();
|
|
|
|
private:
|
|
bool isSystemPrimaryPlayer(IQNetPlayer *pQNetPlayer);
|
|
virtual bool _LeaveGame(bool bMigrateHost, bool bLeaveRoom);
|
|
virtual void _HostGame(int dwUsersMask, int publicSlots = MINECRAFT_NET_MAX_PLAYERS, int privateSlots = 0);
|
|
virtual bool _StartGame();
|
|
|
|
IQNet * m_pIQNet; // pointer to QNet interface
|
|
|
|
HANDLE m_notificationListener;
|
|
|
|
vector<IQNetPlayer *> m_machineQNetPrimaryPlayers; // collection of players that we deem to be the main one for that system
|
|
|
|
bool m_bLeavingGame;
|
|
bool m_bLeaveGameOnTick;
|
|
bool m_migrateHostOnLeave;
|
|
bool m_bHostChanged;
|
|
|
|
bool m_bIsOfflineGame;
|
|
bool m_bIsPrivateGame;
|
|
int m_flagIndexSize;
|
|
|
|
// This is only maintained by the host, and is not valid on client machines
|
|
GameSessionData m_hostGameSessionData;
|
|
CGameNetworkManager *m_pGameNetworkManager;
|
|
public:
|
|
virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = nullptr);
|
|
|
|
private:
|
|
// TODO 4J Stu - Do we need to be able to have more than one of these?
|
|
void (*playerChangedCallback[XUSER_MAX_COUNT])(void *callbackParam, INetworkPlayer *pPlayer, bool leaving);
|
|
void *playerChangedCallbackParam[XUSER_MAX_COUNT];
|
|
|
|
static int RemovePlayerOnSocketClosedThreadProc( void* lpParam );
|
|
virtual bool RemoveLocalPlayer( INetworkPlayer *pNetworkPlayer );
|
|
|
|
// Things for handling per-system flags
|
|
class PlayerFlags
|
|
{
|
|
public:
|
|
INetworkPlayer *m_pNetworkPlayer;
|
|
unsigned char *flags;
|
|
unsigned int count;
|
|
int m_smallId;
|
|
PlayerFlags(INetworkPlayer *pNetworkPlayer, unsigned int count);
|
|
~PlayerFlags();
|
|
};
|
|
vector<PlayerFlags *> m_playerFlags;
|
|
void SystemFlagAddPlayer(INetworkPlayer *pNetworkPlayer);
|
|
void SystemFlagRemovePlayer(INetworkPlayer *pNetworkPlayer);
|
|
void SystemFlagRemoveBySmallId(int smallId);
|
|
void SystemFlagReset();
|
|
public:
|
|
virtual void SystemFlagSet(INetworkPlayer *pNetworkPlayer, int index);
|
|
virtual bool SystemFlagGet(INetworkPlayer *pNetworkPlayer, int index);
|
|
|
|
// For telemetry
|
|
private:
|
|
float m_lastPlayerEventTimeStart;
|
|
|
|
public:
|
|
wstring GatherStats();
|
|
wstring GatherRTTStats();
|
|
|
|
private:
|
|
vector<FriendSessionInfo *> friendsSessions[XUSER_MAX_COUNT];
|
|
int m_searchResultsCount[XUSER_MAX_COUNT];
|
|
int m_lastSearchStartTime[XUSER_MAX_COUNT];
|
|
|
|
// The results that will be filled in with the current search
|
|
XSESSION_SEARCHRESULT_HEADER *m_pSearchResults[XUSER_MAX_COUNT];
|
|
XNQOS *m_pQoSResult[XUSER_MAX_COUNT];
|
|
|
|
// The results from the previous search, which are currently displayed in the game
|
|
XSESSION_SEARCHRESULT_HEADER *m_pCurrentSearchResults[XUSER_MAX_COUNT];
|
|
XNQOS *m_pCurrentQoSResult[XUSER_MAX_COUNT];
|
|
int m_currentSearchResultsCount[XUSER_MAX_COUNT];
|
|
|
|
int m_lastSearchPad;
|
|
bool m_bSearchResultsReady;
|
|
bool m_bSearchPending;
|
|
LPVOID m_pSearchParam;
|
|
void (*m_SessionsUpdatedCallback)(LPVOID pParam);
|
|
|
|
C4JThread* m_SearchingThread;
|
|
|
|
void TickSearch();
|
|
void SearchForGames();
|
|
static int SearchForGamesThreadProc( void* lpParameter );
|
|
|
|
void SetSearchResultsReady(int resultCount = 0);
|
|
|
|
vector<INetworkPlayer *>currentNetworkPlayers;
|
|
INetworkPlayer *addNetworkPlayer(IQNetPlayer *pQNetPlayer);
|
|
void removeNetworkPlayer(IQNetPlayer *pQNetPlayer);
|
|
static INetworkPlayer *getNetworkPlayer(IQNetPlayer *pQNetPlayer);
|
|
|
|
virtual void SetSessionTexturePackParentId( int id );
|
|
virtual void SetSessionSubTexturePackId( int id );
|
|
virtual void Notify(int ID, ULONG_PTR Param);
|
|
|
|
public:
|
|
virtual vector<FriendSessionInfo *> *GetSessionList(int iPad, int localPlayers, bool partyOnly);
|
|
virtual bool GetGameSessionInfo(int iPad, SessionID sessionId,FriendSessionInfo *foundSession);
|
|
virtual void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(LPVOID pParam), LPVOID pSearchParam );
|
|
virtual void GetFullFriendSessionInfo( FriendSessionInfo *foundSession, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam );
|
|
virtual void ForceFriendsSessionRefresh();
|
|
|
|
// Win64: used by accept thread to reject connections when server is at max players (so we don't assign smallId > max).
|
|
bool CanAcceptMoreConnections();
|
|
|
|
public:
|
|
void NotifyPlayerJoined( IQNetPlayer *pQNetPlayer );
|
|
void NotifyPlayerLeaving(IQNetPlayer* pQNetPlayer);
|
|
|
|
#ifndef _XBOX
|
|
void FakeLocalPlayerJoined() { NotifyPlayerJoined(m_pIQNet->GetLocalPlayerByUserIndex(0)); }
|
|
#endif
|
|
};
|