public void Redirect(Redirect redirect) { Logger.InfoFormat("Processing redirect"); GlobalConnectionManifest.RegisterRedirect(this, redirect); Logger.InfoFormat("Redirect: cid {0}", this.ConnectionId); //GlobalConnectionManifest.DeregisterClient(this); redirect.Destination.ExpectedConnections.TryAdd(redirect.Id, redirect); var endPoint = Socket.RemoteEndPoint as IPEndPoint; byte[] addressBytes = IPAddress.IsLoopback(endPoint.Address) ? IPAddress.Loopback.GetAddressBytes() : Game.IpAddress.GetAddressBytes(); Array.Reverse(addressBytes); var x03 = new ServerPacket(0x03); x03.Write(addressBytes); x03.WriteUInt16((ushort)redirect.Destination.Port); x03.WriteByte((byte)(redirect.EncryptionKey.Length + Encoding.GetEncoding(949).GetBytes(redirect.Name).Length + 7)); x03.WriteByte(redirect.EncryptionSeed); x03.WriteByte((byte)redirect.EncryptionKey.Length); x03.Write(redirect.EncryptionKey); x03.WriteString8(redirect.Name); x03.WriteUInt32(redirect.Id); Thread.Sleep(100); Enqueue(x03); }
private void PacketHandler_0x4B_RequestNotification(Client client, ClientPacket packet) { var x60 = new ServerPacket(0x60); x60.WriteByte(0x01); x60.WriteUInt16((ushort)Game.Notification.Length); x60.Write(Game.Notification); client.Enqueue(x60); }
private void PacketHandler_0x00_ClientVersion(Client client, ClientPacket packet) { var x00 = new ServerPacket(0x00); x00.WriteByte(0x00); x00.WriteUInt32(Game.ServerTableCrc); x00.WriteByte(client.EncryptionSeed); x00.WriteByte((byte)client.EncryptionKey.Length); x00.Write(client.EncryptionKey); client.Enqueue(x00); }
public void Redirect(Redirect redirect, bool isLogoff = false, int transmitDelay = 0) { GameLog.InfoFormat("Processing redirect"); GlobalConnectionManifest.RegisterRedirect(this, redirect); GameLog.InfoFormat("Redirect: cid {0}", this.ConnectionId); GameLog.Info($"Redirect EncryptionKey is {Encoding.ASCII.GetString(redirect.EncryptionKey)}"); if (isLogoff) { GlobalConnectionManifest.DeregisterClient(this); } redirect.Destination.ExpectedConnections.TryAdd(redirect.Id, redirect); var endPoint = Socket.RemoteEndPoint as IPEndPoint; byte[] addressBytes; if (Game.RedirectTarget != null) { addressBytes = Game.RedirectTarget.GetAddressBytes(); } else { addressBytes = IPAddress.IsLoopback(endPoint.Address) ? IPAddress.Loopback.GetAddressBytes() : Game.IpAddress.GetAddressBytes(); } Array.Reverse(addressBytes); var x03 = new ServerPacket(0x03); x03.Write(addressBytes); x03.WriteUInt16((ushort)redirect.Destination.Port); x03.WriteByte((byte)(redirect.EncryptionKey.Length + Encoding.ASCII.GetBytes(redirect.Name).Length + 7)); x03.WriteByte(redirect.EncryptionSeed); x03.WriteByte((byte)redirect.EncryptionKey.Length); x03.Write(redirect.EncryptionKey); x03.WriteString8(redirect.Name); x03.WriteUInt32(redirect.Id); x03.TransmitDelay = transmitDelay == 0 ? 250 : transmitDelay; Enqueue(x03); }
private void PacketHandler_0x57_ServerTable(Client client, ClientPacket packet) { var mismatch = packet.ReadByte(); if (mismatch == 1) { var x56 = new ServerPacket(0x56); x56.WriteUInt16((ushort)Game.ServerTable.Length); x56.Write(Game.ServerTable); client.Enqueue(x56); } else { var server = packet.ReadByte(); var redirect = new Redirect(client, this, Game.Login, "socket", client.EncryptionSeed, client.EncryptionKey); client.Redirect(redirect); } }
private void PacketHandler_0x57_ServerTable(Client client, ClientPacket packet) { var mismatch = packet.ReadByte(); if (mismatch == 1) { var x56 = new ServerPacket(0x56); x56.WriteUInt16((ushort)Game.ServerTable.Length); x56.Write(Game.ServerTable); Logger.InfoFormat("ServerTable: Sent: {0}", BitConverter.ToString(x56.ToArray())); client.Enqueue(x56); } else { var server = packet.ReadByte(); var redirect = new Redirect(client, this, Game.Login, "socket", client.EncryptionSeed, client.EncryptionKey); client.Redirect(redirect); } }
public void Redirect(Redirect redirect) { Logger.DebugFormat("Processing redirect"); GlobalConnectionManifest.DeregisterClient(this); redirect.Destination.ExpectedConnections.TryAdd(redirect.Id, redirect); var endPoint = Socket.RemoteEndPoint as IPEndPoint; byte[] addressBytes = IPAddress.IsLoopback(endPoint.Address) ? IPAddress.Loopback.GetAddressBytes() : Game.IpAddress.GetAddressBytes(); Array.Reverse(addressBytes); var x03 = new ServerPacket(0x03); x03.Write(addressBytes); x03.WriteUInt16((ushort)redirect.Destination.Port); x03.WriteByte((byte)(redirect.EncryptionKey.Length + Encoding.GetEncoding(949).GetBytes(redirect.Name).Length + 7)); x03.WriteByte(redirect.EncryptionSeed); x03.WriteByte((byte)redirect.EncryptionKey.Length); x03.Write(redirect.EncryptionKey); x03.WriteString8(redirect.Name); x03.WriteUInt32(redirect.Id); Enqueue(x03); }
private void PacketHandler_0x7B_RequestMetafile(Object obj, ClientPacket packet) { var user = (User) obj; var all = packet.ReadBoolean(); if (all) { var x6F = new ServerPacket(0x6F); x6F.WriteBoolean(all); x6F.WriteUInt16((ushort) Metafiles.Count); foreach (var metafile in Metafiles.Values) { x6F.WriteString8(metafile.Name); x6F.WriteUInt32(metafile.Checksum); } user.Enqueue(x6F); } else { var name = packet.ReadString8(); if (Metafiles.ContainsKey(name)) { var file = Metafiles[name]; var x6F = new ServerPacket(0x6F); x6F.WriteBoolean(all); x6F.WriteString8(file.Name); x6F.WriteUInt32(file.Checksum); x6F.WriteUInt16((ushort) file.Data.Length); x6F.Write(file.Data); user.Enqueue(x6F); } } }