[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
This commit is contained in:
rhailrake
2023-04-27 06:01:05 +06:00
committed by Remuchi
parent eeec02119d
commit aca6843c0a
26 changed files with 1175 additions and 81 deletions

View File

@@ -0,0 +1,57 @@
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);
}
}