mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
add: authentication failure handling and ingame error messages
This commit is contained in:
parent
14afabda0e
commit
f238e682b3
|
|
@ -4173,6 +4173,12 @@ void ClientConnection::handleAuth(const shared_ptr<AuthPacket> &packet)
|
||||||
if (handshakeManager->isComplete())
|
if (handshakeManager->isComplete())
|
||||||
{
|
{
|
||||||
authComplete = true;
|
authComplete = true;
|
||||||
|
const wstring &authName = handshakeManager->finalUsername;
|
||||||
|
minecraft->user->name = authName;
|
||||||
|
extern char g_Win64Username[17];
|
||||||
|
extern wchar_t g_Win64UsernameW[17];
|
||||||
|
wcsncpy_s(g_Win64UsernameW, authName.c_str(), 16);
|
||||||
|
wcstombs_s(nullptr, g_Win64Username, g_Win64UsernameW, 16);
|
||||||
}
|
}
|
||||||
else if (handshakeManager->isFailed())
|
else if (handshakeManager->isFailed())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4589,6 +4589,9 @@ int CMinecraftApp::SignoutExitWorldThreadProc( void* lpParameter )
|
||||||
case DisconnectPacket::eDisconnect_OutdatedClient:
|
case DisconnectPacket::eDisconnect_OutdatedClient:
|
||||||
exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD;
|
exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD;
|
||||||
break;
|
break;
|
||||||
|
case DisconnectPacket::eDisconnect_AuthFailed:
|
||||||
|
exitReasonStringId = IDS_DISCONNECTED_AUTH_FAILED;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
exitReasonStringId = IDS_DISCONNECTED;
|
exitReasonStringId = IDS_DISCONNECTED;
|
||||||
}
|
}
|
||||||
|
|
@ -4649,6 +4652,10 @@ int CMinecraftApp::SignoutExitWorldThreadProc( void* lpParameter )
|
||||||
break;
|
break;
|
||||||
case DisconnectPacket::eDisconnect_OutdatedClient:
|
case DisconnectPacket::eDisconnect_OutdatedClient:
|
||||||
exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD;
|
exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD;
|
||||||
|
break;
|
||||||
|
case DisconnectPacket::eDisconnect_AuthFailed:
|
||||||
|
exitReasonStringId = IDS_DISCONNECTED_AUTH_FAILED;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
exitReasonStringId = IDS_DISCONNECTED;
|
exitReasonStringId = IDS_DISCONNECTED;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -508,6 +508,10 @@ void IUIScene_PauseMenu::_ExitWorld(LPVOID lpParameter)
|
||||||
exitReasonTitleId = IDS_CONNECTION_FAILED;
|
exitReasonTitleId = IDS_CONNECTION_FAILED;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case DisconnectPacket::eDisconnect_AuthFailed:
|
||||||
|
exitReasonStringId = IDS_DISCONNECTED_AUTH_FAILED;
|
||||||
|
exitReasonTitleId = IDS_CONNECTION_FAILED;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
exitReasonStringId = IDS_CONNECTION_LOST_SERVER;
|
exitReasonStringId = IDS_CONNECTION_LOST_SERVER;
|
||||||
}
|
}
|
||||||
|
|
@ -609,6 +613,10 @@ void IUIScene_PauseMenu::_ExitWorld(LPVOID lpParameter)
|
||||||
exitReasonTitleId = IDS_CONNECTION_FAILED;
|
exitReasonTitleId = IDS_CONNECTION_FAILED;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case DisconnectPacket::eDisconnect_AuthFailed:
|
||||||
|
exitReasonStringId = IDS_DISCONNECTED_AUTH_FAILED;
|
||||||
|
exitReasonTitleId = IDS_CONNECTION_FAILED;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
exitReasonStringId = IDS_DISCONNECTED;
|
exitReasonStringId = IDS_DISCONNECTED;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,9 @@ void UIScene_ConnectingProgress::tick()
|
||||||
case DisconnectPacket::eDisconnect_Banned:
|
case DisconnectPacket::eDisconnect_Banned:
|
||||||
exitReasonStringId = IDS_DISCONNECTED_KICKED;
|
exitReasonStringId = IDS_DISCONNECTED_KICKED;
|
||||||
break;
|
break;
|
||||||
|
case DisconnectPacket::eDisconnect_AuthFailed:
|
||||||
|
exitReasonStringId = IDS_DISCONNECTED_AUTH_FAILED;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
exitReasonStringId = IDS_CONNECTION_LOST_SERVER;
|
exitReasonStringId = IDS_CONNECTION_LOST_SERVER;
|
||||||
break;
|
break;
|
||||||
|
|
@ -277,6 +280,9 @@ void UIScene_ConnectingProgress::handleTimerComplete(int id)
|
||||||
exitReasonStringId = IDS_DISCONNECTED_NAT_TYPE_MISMATCH;
|
exitReasonStringId = IDS_DISCONNECTED_NAT_TYPE_MISMATCH;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case DisconnectPacket::eDisconnect_AuthFailed:
|
||||||
|
exitReasonStringId = IDS_DISCONNECTED_AUTH_FAILED;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
exitReasonStringId = IDS_CONNECTION_LOST_SERVER;
|
exitReasonStringId = IDS_CONNECTION_LOST_SERVER;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@
|
||||||
#include "PlayerChunkMap.h"
|
#include "PlayerChunkMap.h"
|
||||||
#include "Common\Telemetry\TelemetryManager.h"
|
#include "Common\Telemetry\TelemetryManager.h"
|
||||||
#include "PlayerConnection.h"
|
#include "PlayerConnection.h"
|
||||||
|
#include "AuthScreen.h"
|
||||||
#ifdef _XBOX_ONE
|
#ifdef _XBOX_ONE
|
||||||
#include "Durango\Network\NetworkPlayerDurango.h"
|
#include "Durango\Network\NetworkPlayerDurango.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -648,6 +649,19 @@ bool MinecraftServer::initServer(int64_t seed, NetworkGameInitData *initData, DW
|
||||||
//motd = settings->getString(L"motd", L"A Minecraft Server");
|
//motd = settings->getString(L"motd", L"A Minecraft Server");
|
||||||
//motd.replace('<27>', '$');
|
//motd.replace('<27>', '$');
|
||||||
|
|
||||||
|
if (ShouldUseDedicatedServerProperties())
|
||||||
|
{
|
||||||
|
wstring am = GetDedicatedServerString(settings, L"auth-mode", L"session");
|
||||||
|
authMode = (am == L"offline") ? "offline" : "session";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int idx = AuthProfileManager::getSelectedIndex();
|
||||||
|
const auto &profiles = AuthProfileManager::getProfiles();
|
||||||
|
authMode = (idx >= 0 && idx < static_cast<int>(profiles.size()) &&
|
||||||
|
profiles[idx].type != AuthProfile::OFFLINE) ? "session" : "offline";
|
||||||
|
}
|
||||||
|
|
||||||
setAnimals(GetDedicatedServerBool(settings, L"spawn-animals", true));
|
setAnimals(GetDedicatedServerBool(settings, L"spawn-animals", true));
|
||||||
setNpcsEnabled(GetDedicatedServerBool(settings, L"spawn-npcs", true));
|
setNpcsEnabled(GetDedicatedServerBool(settings, L"spawn-npcs", true));
|
||||||
setPvpAllowed(app.GetGameHostOption( eGameHostOption_PvP )>0?true:false);
|
setPvpAllowed(app.GetGameHostOption( eGameHostOption_PvP )>0?true:false);
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ private:
|
||||||
CRITICAL_SECTION m_consoleInputCS;
|
CRITICAL_SECTION m_consoleInputCS;
|
||||||
public:
|
public:
|
||||||
bool onlineMode;
|
bool onlineMode;
|
||||||
|
std::string authMode;
|
||||||
bool animals;
|
bool animals;
|
||||||
bool npcs;
|
bool npcs;
|
||||||
bool pvp;
|
bool pvp;
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,8 @@ void PendingConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// printf("Server: handlePreLogin\n");
|
// printf("Server: handlePreLogin\n");
|
||||||
name = packet->loginKey; // 4J Stu - Change from the login packet as we know better on client end during the pre-login packet
|
if (!authComplete)
|
||||||
|
name = packet->loginKey;
|
||||||
sendPreLoginResponse();
|
sendPreLoginResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -411,9 +412,10 @@ bool PendingConnection::isDisconnected()
|
||||||
void PendingConnection::initAuth()
|
void PendingConnection::initAuth()
|
||||||
{
|
{
|
||||||
handshakeManager = new HandshakeManager(true);
|
handshakeManager = new HandshakeManager(true);
|
||||||
handshakeManager->registerModule(new SessionAuthModule());
|
if (server->authMode == "session")
|
||||||
handshakeManager->registerModule(new KeypairOfflineAuthModule());
|
handshakeManager->registerModule(new SessionAuthModule());
|
||||||
handshakeManager->registerModule(new OfflineAuthModule());
|
else
|
||||||
|
handshakeManager->registerModule(new OfflineAuthModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingConnection::handleAuth(const shared_ptr<AuthPacket> &packet)
|
void PendingConnection::handleAuth(const shared_ptr<AuthPacket> &packet)
|
||||||
|
|
@ -433,6 +435,6 @@ void PendingConnection::handleAuth(const shared_ptr<AuthPacket> &packet)
|
||||||
}
|
}
|
||||||
else if (handshakeManager->isFailed())
|
else if (handshakeManager->isFailed())
|
||||||
{
|
{
|
||||||
disconnect(DisconnectPacket::eDisconnect_Closed);
|
disconnect(DisconnectPacket::eDisconnect_AuthFailed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5867,6 +5867,10 @@ Press{*CONTROLLER_VK_B*} if you already know about Fireworks.</value>
|
||||||
<value>You cannot join this game as the player you are trying to join is running a newer version of the game.</value>
|
<value>You cannot join this game as the player you are trying to join is running a newer version of the game.</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
|
<data name="IDS_DISCONNECTED_AUTH_FAILED">
|
||||||
|
<value>Authentication required. This server requires you to be signed in.</value>
|
||||||
|
</data>
|
||||||
|
|
||||||
<data name="IDS_DEFAULT_SAVENAME">
|
<data name="IDS_DEFAULT_SAVENAME">
|
||||||
<value>New World</value>
|
<value>New World</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
|
||||||
|
|
@ -2290,3 +2290,4 @@
|
||||||
#define IDS_RICHPRESENCESTATE_BREWING 2284
|
#define IDS_RICHPRESENCESTATE_BREWING 2284
|
||||||
#define IDS_RICHPRESENCESTATE_ANVIL 2285
|
#define IDS_RICHPRESENCESTATE_ANVIL 2285
|
||||||
#define IDS_RICHPRESENCESTATE_TRADING 2286
|
#define IDS_RICHPRESENCESTATE_TRADING 2286
|
||||||
|
#define IDS_DISCONNECTED_AUTH_FAILED 2287
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,7 @@ namespace ServerRuntime
|
||||||
case DisconnectPacket::eDisconnect_Banned: return "banned";
|
case DisconnectPacket::eDisconnect_Banned: return "banned";
|
||||||
case DisconnectPacket::eDisconnect_NotFriendsWithHost: return "not-friends-with-host";
|
case DisconnectPacket::eDisconnect_NotFriendsWithHost: return "not-friends-with-host";
|
||||||
case DisconnectPacket::eDisconnect_NATMismatch: return "nat-mismatch";
|
case DisconnectPacket::eDisconnect_NATMismatch: return "nat-mismatch";
|
||||||
|
case DisconnectPacket::eDisconnect_AuthFailed: return "auth-failed";
|
||||||
default: return "unknown";
|
default: return "unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ static const ServerPropertyDefault kServerPropertyDefaults[] =
|
||||||
{
|
{
|
||||||
{ "allow-flight", "true" },
|
{ "allow-flight", "true" },
|
||||||
{ "allow-nether", "true" },
|
{ "allow-nether", "true" },
|
||||||
|
{ "auth-mode", "session" },
|
||||||
{ "autosave-interval", "60" },
|
{ "autosave-interval", "60" },
|
||||||
{ "bedrock-fog", "true" },
|
{ "bedrock-fog", "true" },
|
||||||
{ "bonus-chest", "false" },
|
{ "bonus-chest", "false" },
|
||||||
|
|
@ -864,6 +865,9 @@ ServerPropertiesConfig LoadServerPropertiesConfig()
|
||||||
|
|
||||||
config.maxBuildHeight = ReadNormalizedIntProperty(&merged, "max-build-height", 256, 64, 256, &shouldWrite);
|
config.maxBuildHeight = ReadNormalizedIntProperty(&merged, "max-build-height", 256, 64, 256, &shouldWrite);
|
||||||
config.motd = ReadNormalizedStringProperty(&merged, "motd", "A Minecraft Server", 255, &shouldWrite);
|
config.motd = ReadNormalizedStringProperty(&merged, "motd", "A Minecraft Server", 255, &shouldWrite);
|
||||||
|
config.authMode = ReadNormalizedStringProperty(&merged, "auth-mode", "session", 16, &shouldWrite);
|
||||||
|
if (config.authMode != "session" && config.authMode != "offline")
|
||||||
|
config.authMode = "session";
|
||||||
|
|
||||||
if (shouldWrite)
|
if (shouldWrite)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ namespace ServerRuntime
|
||||||
bool doTileDrops;
|
bool doTileDrops;
|
||||||
bool naturalRegeneration;
|
bool naturalRegeneration;
|
||||||
bool doDaylightCycle;
|
bool doDaylightCycle;
|
||||||
|
std::string authMode;
|
||||||
/** other MinecraftServer runtime settings */
|
/** other MinecraftServer runtime settings */
|
||||||
int maxBuildHeight;
|
int maxBuildHeight;
|
||||||
std::string levelType;
|
std::string levelType;
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ public:
|
||||||
eDisconnect_Banned,
|
eDisconnect_Banned,
|
||||||
eDisconnect_NotFriendsWithHost,
|
eDisconnect_NotFriendsWithHost,
|
||||||
eDisconnect_NATMismatch,
|
eDisconnect_NATMismatch,
|
||||||
|
eDisconnect_AuthFailed,
|
||||||
#ifdef __ORBIS__
|
#ifdef __ORBIS__
|
||||||
eDisconnect_NetworkError,
|
eDisconnect_NetworkError,
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue