Files
Quasar/Server/Core/Packets/PacketHandler.cs
T
d3agle 98bef4917a PacketHandler fix
For some reason, killing the Client process on my VM while Remote Desktop was running on my host would cause the Server to crash.  A NullReferenceException was thrown @ Line 16 in PacketHandler.cs.  Not sure if this is the best fix, but the server is trying to handle a packet after client.Value is nulled
2015-07-25 03:53:00 -05:00

87 lines
3.6 KiB
C#

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);
}
}
}
}