protected virtual void CheckNonStandardPort(List <byte> header, GameServer server) { ///only dedicated server have different query report port and host port ///the query report port and host port are the same on peer server ///so we do not need to check this for peer server //we check host port is standard port or not if (!server.ServerData.KeyValue.ContainsKey("hostport")) { return; } if (server.ServerData.KeyValue["hostport"] == "") { return; } if (server.ServerData.KeyValue["hostport"] != "6500") { header[0] ^= (byte)GameServerFlags.NonStandardPort; //we do not need htons here byte[] port = HtonsExtensions.PortToIntBytes( server.ServerData.KeyValue["hostport"]); byte[] htonPort = HtonsExtensions.UshortPortToHtonBytes( server.ServerData.KeyValue["hostport"]); header.AddRange(htonPort); } }
public override byte[] BuildResponse() { List <byte> data = new List <byte>(); data.AddRange(base.BuildResponse()); data.Add((byte)PortType); data.Add(ClientIndex); data.Add(UseGamePort); data.AddRange(HtonsExtensions.IPStringToBytes(LocalIP)); data.AddRange(HtonsExtensions.UshortPortToBytes(LocalPort)); return(data.ToArray()); }
public override byte[] BuildResponse() { //change packet type to challenge List <byte> data = new List <byte>(); data.AddRange(base.BuildResponse()); //Challenge data.AddRange(Challenge); //IP data.AddRange(HtonsExtensions.IPStringToBytes(RemoteIP)); data.AddRange(Spliter); //port data.AddRange(HtonsExtensions.PortToIntBytes(RemotePort)); return(data.ToArray()); }
public override byte[] BuildResponse() { List <byte> data = new List <byte>(); data.AddRange(base.BuildResponse()); data.AddRange(HtonsExtensions. EndPointToIPBytes(RemoteEndPoint)); data.AddRange(HtonsExtensions. EndPointToHtonsPortBytes(RemoteEndPoint)); data.Add(GotYourData); data.Add(Finished); return(data.ToArray()); }
public override byte[] BuildResponse() { //change packet type to challenge List <byte> data = new List <byte>(); PacketType = QRPacketType.Challenge; data.AddRange(base.BuildResponse()); //Challenge data.AddRange(new byte[] { 0x54, 0x54, 0x54, 0x00, 0x00 }); //IP data.AddRange(HtonsExtensions.IPStringToBytes(RemoteIP)); data.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x00 }); //port data.AddRange(HtonsExtensions.PortToIntBytes(RemotePort)); return(data.ToArray()); }
protected virtual void CheckPrivatePort(List <byte> header, GameServer server) { // we check private port here if (!server.ServerData.KeyValue.ContainsKey("privateport")) { return; } if (server.ServerData.KeyValue["privateport"] == "") { return; } header[0] ^= (byte)GameServerFlags.NonStandardPrivatePortFlag; byte[] port = HtonsExtensions.PortToIntBytes( server.ServerData.KeyValue["privateport"]); header.AddRange(port); }
public override bool Parse() { if (!base.Parse()) { return(false); } PortType = (NatPortType)RawRequest[NNRequestBase.Size]; // ClientIndex = RawRequest[NNRequestBase.Size + 1]; //00 UseGamePort = RawRequest[NNRequestBase.Size + 2]; //00 LocalIP = HtonsExtensions. BytesToIPString( ByteTools.SubBytes(RawRequest, NNRequestBase.Size + 3, 4)); LocalPort = HtonsExtensions. BytesToUshortPort( ByteTools.SubBytes(RawRequest, NNRequestBase.Size + 7, 2)); return(true); }
public override bool Parse(byte[] recv) { if (!base.Parse(recv)) { return(false); } PortType = (NatPortType)recv[BasePacket.Size]; // ClientIndex = recv[BasePacket.Size + 1]; //00 UseGamePort = recv[BasePacket.Size + 2]; //00 LocalIP = HtonsExtensions. BytesToIPString( ByteTools.SubBytes(recv, BasePacket.Size + 3, 4)); LocalPort = HtonsExtensions. BytesToUshortPort( ByteTools.SubBytes(recv, BasePacket.Size + 7, 2)); return(true); }
protected virtual void CheckPrivateIP(List <byte> header, GameServer server) { string localIP = ""; // now we check if there are private ip if (server.ServerData.KeyValue.ContainsKey("localip0")) { localIP = server.ServerData.KeyValue["localip0"]; } else if (server.ServerData.KeyValue.ContainsKey("localip1")) { localIP = server.ServerData.KeyValue["localip1"]; } if (localIP == "") { return; } header[0] ^= (byte)GameServerFlags.PrivateIPFlag; byte[] address = HtonsExtensions.IPStringToBytes(localIP); header.AddRange(address); }
public HeartBeatResponse(QRSession session, HeartBeatRequest request) : base(request) { RemoteIP = HtonsExtensions.EndPointToIP(session.RemoteEndPoint); RemotePort = HtonsExtensions.EndPointToPort(session.RemoteEndPoint); PacketType = QRPacketType.Challenge; }
public void Parse(EndPoint endPoint, byte[] recv) { base.Parse(recv); RemoteIP = HtonsExtensions.EndPointToIPString(endPoint); RemotePort = HtonsExtensions.EndPointToPortString(endPoint); }
protected void CheckICMPSupport(List <byte> header, GameServer server) { header[0] ^= (byte)GameServerFlags.ICMPIPFlag; byte[] address = HtonsExtensions.IPStringToBytes(server.RemoteQueryReportIP); header.AddRange(address); }