add: authentication failure handling and ingame error messages
This commit is contained in:
parent
14afabda0e
commit
f238e682b3
13 changed files with 61 additions and 6 deletions
|
|
@ -4173,6 +4173,12 @@ void ClientConnection::handleAuth(const shared_ptr<AuthPacket> &packet)
|
|||
if (handshakeManager->isComplete())
|
||||
{
|
||||
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())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4589,6 +4589,9 @@ int CMinecraftApp::SignoutExitWorldThreadProc( void* lpParameter )
|
|||
case DisconnectPacket::eDisconnect_OutdatedClient:
|
||||
exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_AuthFailed:
|
||||
exitReasonStringId = IDS_DISCONNECTED_AUTH_FAILED;
|
||||
break;
|
||||
default:
|
||||
exitReasonStringId = IDS_DISCONNECTED;
|
||||
}
|
||||
|
|
@ -4649,6 +4652,10 @@ int CMinecraftApp::SignoutExitWorldThreadProc( void* lpParameter )
|
|||
break;
|
||||
case DisconnectPacket::eDisconnect_OutdatedClient:
|
||||
exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_AuthFailed:
|
||||
exitReasonStringId = IDS_DISCONNECTED_AUTH_FAILED;
|
||||
break;
|
||||
default:
|
||||
exitReasonStringId = IDS_DISCONNECTED;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -508,6 +508,10 @@ void IUIScene_PauseMenu::_ExitWorld(LPVOID lpParameter)
|
|||
exitReasonTitleId = IDS_CONNECTION_FAILED;
|
||||
break;
|
||||
#endif
|
||||
case DisconnectPacket::eDisconnect_AuthFailed:
|
||||
exitReasonStringId = IDS_DISCONNECTED_AUTH_FAILED;
|
||||
exitReasonTitleId = IDS_CONNECTION_FAILED;
|
||||
break;
|
||||
default:
|
||||
exitReasonStringId = IDS_CONNECTION_LOST_SERVER;
|
||||
}
|
||||
|
|
@ -609,6 +613,10 @@ void IUIScene_PauseMenu::_ExitWorld(LPVOID lpParameter)
|
|||
exitReasonTitleId = IDS_CONNECTION_FAILED;
|
||||
break;
|
||||
#endif
|
||||
case DisconnectPacket::eDisconnect_AuthFailed:
|
||||
exitReasonStringId = IDS_DISCONNECTED_AUTH_FAILED;
|
||||
exitReasonTitleId = IDS_CONNECTION_FAILED;
|
||||
break;
|
||||
default:
|
||||
exitReasonStringId = IDS_DISCONNECTED;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,6 +133,9 @@ void UIScene_ConnectingProgress::tick()
|
|||
case DisconnectPacket::eDisconnect_Banned:
|
||||
exitReasonStringId = IDS_DISCONNECTED_KICKED;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_AuthFailed:
|
||||
exitReasonStringId = IDS_DISCONNECTED_AUTH_FAILED;
|
||||
break;
|
||||
default:
|
||||
exitReasonStringId = IDS_CONNECTION_LOST_SERVER;
|
||||
break;
|
||||
|
|
@ -277,6 +280,9 @@ void UIScene_ConnectingProgress::handleTimerComplete(int id)
|
|||
exitReasonStringId = IDS_DISCONNECTED_NAT_TYPE_MISMATCH;
|
||||
break;
|
||||
#endif
|
||||
case DisconnectPacket::eDisconnect_AuthFailed:
|
||||
exitReasonStringId = IDS_DISCONNECTED_AUTH_FAILED;
|
||||
break;
|
||||
default:
|
||||
exitReasonStringId = IDS_CONNECTION_LOST_SERVER;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@
|
|||
#include "PlayerChunkMap.h"
|
||||
#include "Common\Telemetry\TelemetryManager.h"
|
||||
#include "PlayerConnection.h"
|
||||
#include "AuthScreen.h"
|
||||
#ifdef _XBOX_ONE
|
||||
#include "Durango\Network\NetworkPlayerDurango.h"
|
||||
#endif
|
||||
|
|
@ -648,6 +649,19 @@ bool MinecraftServer::initServer(int64_t seed, NetworkGameInitData *initData, DW
|
|||
//motd = settings->getString(L"motd", L"A Minecraft Server");
|
||||
//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));
|
||||
setNpcsEnabled(GetDedicatedServerBool(settings, L"spawn-npcs", true));
|
||||
setPvpAllowed(app.GetGameHostOption( eGameHostOption_PvP )>0?true:false);
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ private:
|
|||
CRITICAL_SECTION m_consoleInputCS;
|
||||
public:
|
||||
bool onlineMode;
|
||||
std::string authMode;
|
||||
bool animals;
|
||||
bool npcs;
|
||||
bool pvp;
|
||||
|
|
|
|||
|
|
@ -125,7 +125,8 @@ void PendingConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet)
|
|||
return;
|
||||
}
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
|
@ -411,9 +412,10 @@ bool PendingConnection::isDisconnected()
|
|||
void PendingConnection::initAuth()
|
||||
{
|
||||
handshakeManager = new HandshakeManager(true);
|
||||
handshakeManager->registerModule(new SessionAuthModule());
|
||||
handshakeManager->registerModule(new KeypairOfflineAuthModule());
|
||||
handshakeManager->registerModule(new OfflineAuthModule());
|
||||
if (server->authMode == "session")
|
||||
handshakeManager->registerModule(new SessionAuthModule());
|
||||
else
|
||||
handshakeManager->registerModule(new OfflineAuthModule());
|
||||
}
|
||||
|
||||
void PendingConnection::handleAuth(const shared_ptr<AuthPacket> &packet)
|
||||
|
|
@ -433,6 +435,6 @@ void PendingConnection::handleAuth(const shared_ptr<AuthPacket> &packet)
|
|||
}
|
||||
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>
|
||||
</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">
|
||||
<value>New World</value>
|
||||
</data>
|
||||
|
|
|
|||
|
|
@ -2290,3 +2290,4 @@
|
|||
#define IDS_RICHPRESENCESTATE_BREWING 2284
|
||||
#define IDS_RICHPRESENCESTATE_ANVIL 2285
|
||||
#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_NotFriendsWithHost: return "not-friends-with-host";
|
||||
case DisconnectPacket::eDisconnect_NATMismatch: return "nat-mismatch";
|
||||
case DisconnectPacket::eDisconnect_AuthFailed: return "auth-failed";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ static const ServerPropertyDefault kServerPropertyDefaults[] =
|
|||
{
|
||||
{ "allow-flight", "true" },
|
||||
{ "allow-nether", "true" },
|
||||
{ "auth-mode", "session" },
|
||||
{ "autosave-interval", "60" },
|
||||
{ "bedrock-fog", "true" },
|
||||
{ "bonus-chest", "false" },
|
||||
|
|
@ -864,6 +865,9 @@ ServerPropertiesConfig LoadServerPropertiesConfig()
|
|||
|
||||
config.maxBuildHeight = ReadNormalizedIntProperty(&merged, "max-build-height", 256, 64, 256, &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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ namespace ServerRuntime
|
|||
bool doTileDrops;
|
||||
bool naturalRegeneration;
|
||||
bool doDaylightCycle;
|
||||
|
||||
std::string authMode;
|
||||
/** other MinecraftServer runtime settings */
|
||||
int maxBuildHeight;
|
||||
std::string levelType;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ public:
|
|||
eDisconnect_Banned,
|
||||
eDisconnect_NotFriendsWithHost,
|
||||
eDisconnect_NATMismatch,
|
||||
eDisconnect_AuthFailed,
|
||||
#ifdef __ORBIS__
|
||||
eDisconnect_NetworkError,
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue