Files
OldThink/Content.Server/UtkaIntegration/Commands/UtkaAuthenticationCommand.cs
rhailrake aca6843c0a [feat] Sockets, i guess mm hmm
# Conflicts:
#	Content.Server/Administration/Systems/BwoinkSystem.cs
#	Content.Server/Chat/Managers/ChatManager.cs
#	Content.Server/Entry/EntryPoint.cs
#	Content.Server/GameTicking/GameTicker.RoundFlow.cs
#	Content.Server/IoC/ServerContentIoC.cs
#	Content.Server/RoundEnd/RoundEndSystem.cs
#	Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs
#	Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs
#	Content.Shared/CCVar/CCVars.cs
2024-01-10 22:21:52 +07:00

58 lines
1.6 KiB
C#

using Content.Server.UtkaIntegration.TCP;
using Content.Shared.CCVar;
using Content.Shared.White;
using Robust.Shared.Configuration;
namespace Content.Server.UtkaIntegration;
public sealed class UtkaAuthenticationCommand : IUtkaCommand
{
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private readonly UtkaTCPWrapper _utkaTcpWrapper = default!;
public string Name => "handshake";
public Type RequestMessageType => typeof(UtkaHandshakeMessage);
public void Execute(UtkaTCPSession session, UtkaBaseMessage baseMessage)
{
if (baseMessage is not UtkaHandshakeMessage message)
return;
IoCManager.InjectDependencies(this);
if (string.IsNullOrWhiteSpace(message.Key))
{
SendMessage(session, "key_missmatch");
return;
}
var key = _configurationManager.GetCVar(WhiteCVars.UtkaSocketKey);
if (key != message.Key)
{
SendMessage(session, "key_missmatch");
return;
}
if (session.Authenticated)
{
SendMessage(session, "already_authentificated");
return;
}
session.Authenticated = true;
SendMessage(session, "handshake_accepted");
}
private void SendMessage(UtkaTCPSession session, string message)
{
var response = new UtkaHandshakeMessage()
{
Key = _configurationManager.GetCVar(WhiteCVars.UtkaSocketKey),
Message = message
};
_utkaTcpWrapper.SendMessageToClient(session, response);
}
}