private void RunPacket(byte[] buff) { // if (closed) return; // Mudado para o metodo "read" UInt16 opcode = BitConverter.ToUInt16(buff, 0); // Debug Receive /* * { * string debugData = ""; * foreach (string str2 in BitConverter.ToString(buff).Split('-', ',', '.', ':', '\t')) * debugData += " " + str2; * Printf.warning("Receive [" + opcode + "]" + debugData); * } */ if (!receiveFirstPacket) // Nao recebeu ainda { if (!FirstPacketCheck(opcode) && opcode != 0) { string msg = "Primeiro pacote nao recebido, conexao finalizada. [" + opcode + "]"; Printf.warning(msg); SaveLog.warning(GetIPAddress() + " " + msg); Firewall.sendBlock(GetIPAddress(), msg, 1); Close(true); return; } } ReceiveLoginPacket packet = null; switch (opcode) { case 528: packet = new BASE_USER_GIFTLIST_REC(this, buff); break; case 2561: case 2563: LoginAttemps++; if (LoginAttemps > 10) { string msg = GetIPAddress() + " Enviou o login mais de 10 vezes"; Printf.warning(msg); SaveLog.warning(msg); Firewall.sendBlock(GetIPAddress(), msg, 2); Close(true); return; } else { packet = new BASE_LOGIN_REC(this, buff); break; } case 2565: packet = new BASE_USER_INFO_REC(this, buff); break; case 2666: Printf.blue("A_2666_REC"); packet = new A_2666_REC(this, buff); break; case 2672: // AutoLogin Printf.info("BASE_LOGIN_THAI_REC"); //packet = new BASE_LOGIN_THAI_REC(this, buff); return; break; case 2567: packet = new BASE_USER_CONFIGS_REC(this, buff); break; case 2575: // [2575] 0F 0A 1E 4C //packet = new UPDATE_GAMESERVERS_REC(this, buff); return; case 2577: packet = new BASE_SERVER_CHANGE_REC(this, buff); // Ultimo pacote? break; case 2579: packet = new BASE_USER_ENTER_REC(this, buff); break; case 2581: packet = new BASE_CONFIG_SAVE_REC(this, buff); break; case 2642: packet = new BASE_SERVER_LIST_REFRESH_REC(this, buff); break; case 2654: packet = new BASE_USER_EXIT_REC(this, buff); break; case 2668: // INCOMPLETO Printf.info("BASE_FREE_ITEMS_OF_LEVELUP_REC"); // packet = new BASE_FREE_ITEMS_OF_LEVELUP_REC(this, buff); return; case 2678: packet = new A_2678_REC(this, buff); break; case 2698: packet = new BASE_USER_INVENTORY_REC(this, buff); break; case 0: packet = new DEV_SERVER_DETAILS_REQ(this, buff); break; default: { string msg = "[" + opcode + "] Opcode nao encontrado " + GetIPAddress(true); Firewall.sendBlock(GetIPAddress(), msg, 1); Printf.warning(msg); SaveLog.warning(msg); Close(true); return; } } new Thread(packet.run).Start(); }
private void RunPacket(byte[] buff, byte[] simple) { ushort uint16 = BitConverter.ToUInt16(buff, 0); if (this.closed) { return; } ReceiveLoginPacket receiveLoginPacket = (ReceiveLoginPacket)null; switch (uint16) { case 528: receiveLoginPacket = (ReceiveLoginPacket) new BASE_USER_GIFTLIST_REC(this, buff); goto case 2575; case 2561: case 2563: receiveLoginPacket = (ReceiveLoginPacket) new BASE_LOGIN_REC(this, buff); goto case 2575; case 2565: receiveLoginPacket = (ReceiveLoginPacket) new BASE_USER_INFO_REC(this, buff); goto case 2575; case 2567: receiveLoginPacket = (ReceiveLoginPacket) new BASE_USER_CONFIGS_REC(this, buff); goto case 2575; case 2575: if (receiveLoginPacket == null) { break; } new Thread(new ThreadStart(receiveLoginPacket.run)).Start(); break; case 2577: receiveLoginPacket = (ReceiveLoginPacket) new BASE_SERVER_CHANGE_REC(this, buff); goto case 2575; case 2579: receiveLoginPacket = (ReceiveLoginPacket) new BASE_USER_ENTER_REC(this, buff); goto case 2575; case 2581: receiveLoginPacket = (ReceiveLoginPacket) new BASE_CONFIG_SAVE_REC(this, buff); goto case 2575; case 2642: receiveLoginPacket = (ReceiveLoginPacket) new BASE_SERVER_LIST_REFRESH_REC(this, buff); goto case 2575; case 2654: receiveLoginPacket = (ReceiveLoginPacket) new BASE_USER_EXIT_REC(this, buff); goto case 2575; case 2666: receiveLoginPacket = (ReceiveLoginPacket) new A_2666_REC(this, buff); Console.WriteLine("A_2666_REC"); goto case 2575; case 2672: receiveLoginPacket = (ReceiveLoginPacket) new BASE_LOGIN_THAI_REC(this, buff); Console.WriteLine("BASE_LOGIN_THAI_REC"); goto case 2575; case 2678: receiveLoginPacket = (ReceiveLoginPacket) new A_2678_REC(this, buff); goto case 2575; case 2698: receiveLoginPacket = (ReceiveLoginPacket) new BASE_USER_INVENTORY_REC(this, buff); goto case 2575; default: StringUtil stringUtil = new StringUtil(); stringUtil.AppendLine("|[LC]| Opcode não encontrado " + (object)uint16); stringUtil.AppendLine("Encry/SemLength/Cheio: " + BitConverter.ToString(simple)); stringUtil.AppendLine("SemEnc/SemLength/Cheio: " + BitConverter.ToString(buff)); stringUtil.AppendLine("Enc/ComLength/TUDO: " + BitConverter.ToString(this.lastCompleteBuffer)); stringUtil.AppendLine("SessionId: " + (object)this.SessionId + "; SessionSeed: " + (object)this.SessionSeed); Logger.error(stringUtil.getString()); goto case 2575; } }