Added decompression/compression of packets. Cleaned up handshaking.

This commit is contained in:
Filip Maj 2016-08-24 15:41:54 -04:00
parent 4aae16e458
commit 364ab40b3f
8 changed files with 123 additions and 43 deletions

View file

@ -1,11 +1,11 @@
using FFXIVClassic.Common;
using FFXIVClassic_World_Server.DataObjects;
using FFXIVClassic_World_Server.Packets.Receive;
using FFXIVClassic_World_Server.Packets.Send;
using FFXIVClassic_World_Server.Packets.Send.Login;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace FFXIVClassic_World_Server
{
@ -27,7 +27,6 @@ namespace FFXIVClassic_World_Server
Server mServer;
List<ClientConnection> mConnections;
public PacketProcessor(Server server)
{
@ -36,57 +35,29 @@ namespace FFXIVClassic_World_Server
public void ProcessPacket(ClientConnection client, BasePacket packet)
{
//if (packet.header.isCompressed == 0x01)
// BasePacket.DecryptPacket(client.blowfish, ref packet);
if (packet.header.isCompressed == 0x01)
BasePacket.DecompressPacket(ref packet);
List<SubPacket> subPackets = packet.GetSubpackets();
foreach (SubPacket subpacket in subPackets)
{
//Initial Connect Packet, Create session
if (subpacket.header.type == 0x01)
{
#region Hardcoded replies
packet.DebugPrintPacket();
byte[] reply1Data = {
0x01, 0x00, 0x00, 0x00, 0x28, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFD, 0xFF, 0xFF,
0xE5, 0x6E, 0x01, 0xE0, 0x00, 0x00, 0x00, 0x0
};
byte[] reply2Data = {
0x01, 0x00, 0x00, 0x00, 0x28, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x38, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x2B, 0x5F, 0x26,
0x66, 0x00, 0x00, 0x00, 0xC8, 0xD6, 0xAF, 0x2B, 0x38, 0x2B, 0x5F, 0x26, 0xB8, 0x8D, 0xF0, 0x2B,
0xC8, 0xFD, 0x85, 0xFE, 0xA8, 0x7C, 0x5B, 0x09, 0x38, 0x2B, 0x5F, 0x26, 0xC8, 0xD6, 0xAF, 0x2B,
0xB8, 0x8D, 0xF0, 0x2B, 0x88, 0xAF, 0x5E, 0x26
};
BasePacket reply1 = new BasePacket(reply1Data);
BasePacket reply2 = new BasePacket(reply2Data);
//Write Timestamp into Reply1
using (MemoryStream mem = new MemoryStream(reply1.data))
{
using (BinaryWriter binReader = new BinaryWriter(mem))
{
binReader.BaseStream.Seek(0x14, SeekOrigin.Begin);
binReader.Write((UInt32)Utils.UnixTimeStampUTC());
}
}
#endregion
{
HelloPacket hello = new HelloPacket(packet.data);
if (packet.header.connectionType == BasePacket.TYPE_ZONE)
mServer.AddSession(client, Session.Channel.ZONE, hello.sessionId);
else if (packet.header.connectionType == BasePacket.TYPE_CHAT)
mServer.AddSession(client, Session.Channel.CHAT, hello.sessionId);
mServer.AddSession(client, Session.Channel.CHAT, hello.sessionId);
client.QueuePacket(_0x7Packet.BuildPacket(0x0E016EE5), true, false);
client.QueuePacket(_0x2Packet.BuildPacket(hello.sessionId), true, false);
}
//Ping from World Server
else if (subpacket.header.type == 0x07)
{
SubPacket init = Login0x7ResponsePacket.BuildPacket(0x50);
SubPacket init = _0x8PingPacket.BuildPacket(client.owner.sessionId);
client.QueuePacket(BasePacket.CreatePacket(init, true, false));
}
//Zoning Related