- Paket hatası çözümü
- 1) aç input.cpp
- ara:
- bool CInputProcessor::Process(LPDESC lpDesc, const void * c_pvOrig, int iBytes, int & r_iBytesProceed)
- ..............
- ............
- ......
- return true;
- }
- değiştir :
- int g_iLastPacket[2] = { -1, -1 };
- bool CInputProcessor::Process(LPDESC lpDesc, const void * c_pvOrig, int iBytes, int & r_iBytesProceed)
- {
- const char * c_pData = (const char *) c_pvOrig;
- int iPacketLen;
- if (!m_pPacketInfo)
- {
- sys_err("No packet info has been binded to");
- return true;
- }
- for (m_iBufferLeft = iBytes; m_iBufferLeft > 0;)
- {
- BYTE bHeader = (BYTE) *(c_pData);
- const char * c_pszName;
- if (bHeader == 0)
- iPacketLen = 1;
- else if (!m_pPacketInfo->Get(bHeader, &iPacketLen, &c_pszName))
- {
- lpDesc->SetPhase(PHASE_CLOSE);
- return true;
- }
- if (m_iBufferLeft < iPacketLen)
- return true;
- int originalPacketSize = iPacketLen;
- BYTE preAnalyzeSeq = *(BYTE*)(c_pData + iPacketLen - sizeof(BYTE));
- if (bHeader)
- {
- if (test_server && bHeader != HEADER_CG_MOVE)
- sys_log(0, "Packet Analyze [Header %d][bufferLeft %d] ", bHeader, m_iBufferLeft);
- m_pPacketInfo->Start();
- int iExtraPacketSize = Analyze(lpDesc, bHeader, c_pData);
- if (iExtraPacketSize < 0)
- {
- #ifdef ENABLE_ANTI_PACKET_FLOOD
- sys_err("Failed to analyze header(%u) host(%s)", bHeader, inet_ntoa(lpDesc->GetAddr().sin_addr));
- lpDesc->SetPhase(PHASE_CLOSE);
- #endif
- return true;
- }
- iPacketLen += iExtraPacketSize;
- lpDesc->Log("%s %d", c_pszName, iPacketLen);
- m_pPacketInfo->End();
- }
- c_pData += iPacketLen;
- m_iBufferLeft -= iPacketLen;
- r_iBytesProceed += iPacketLen;
- g_iLastPacket[1] = g_iLastPacket[0];
- g_iLastPacket[0] = bHeader;
- if (GetType() != lpDesc->GetInputProcessor()->GetType())
- return false;
- }
- return true;
- }
- client:
- Problem varsa:
- game.py aç ara ve sil
- if constInfo.SEQUENCE_PACKET_ENABLE:
- net.SetPacketSequenceMode()
- Constinfo aç ara ve sil
- SEQUENCE_PACKET_ENABLE = 1
- ----------------------------------------------------------------------------------------------
- Source Client:
- ara
- return SendSequence();
- değiştir
- // return disable;
- SERVERSIDE
- 0.1
- input_udp
- ara
- Set(1, sizeof(ServerStateChecker_RequestPacket), "ServerStateRequest", false);
- değiştir:
- Set(1, sizeof(ServerStateChecker_RequestPacket), "ServerStateRequest");
- 1) desc.cpp aç ve ara
- sil:
- #include "sequence.h"
- sil:
- m_iCurrentSequence = 0;
- hepsini sil
- m_seq_vector.clear();
- sil:
- BYTE DESC::GetSequence()
- {
- return gc_abSequence[m_iCurrentSequence];
- }
- void DESC::SetNextSequence()
- {
- if (++m_iCurrentSequence == SEQUENCE_MAX_NUM)
- m_iCurrentSequence = 0;
- }
- sil:
- void DESC::push_seq(BYTE hdr, BYTE seq)
- {
- if (m_seq_vector.size() >= 20)
- {
- m_seq_vector.erase(m_seq_vector.begin());
- }
- seq_t info = { hdr, seq };
- m_seq_vector.push_back(info);
- }
- 2) aç DESC.H
- sil:
- struct seq_t
- {
- BYTE hdr;
- BYTE seq;
- };
- typedef std::vector<seq_t> seq_vector_t;
- sil:
- BYTE GetSequence();
- void SetNextSequence();
- sil:
- int m_iCurrentSequence;
- sil:
- public:
- seq_vector_t m_seq_vector;
- void push_seq(BYTE hdr, BYTE seq);
- 3) aç INPUT.CPP
- ara:
- sys_log(0, "PONG! %u %u", m_pPacketInfo->IsSequence(bHeader), *(BYTE *)(c_pData + iPacketLen - sizeof(BYTE)));
- değiştir:
- sys_log(0, "PONG! %u", *(BYTE *)(c_pData + iPacketLen - sizeof(BYTE)));
- sil:
- if (m_pPacketInfo->IsSequence(bHeader))
- {
- BYTE bSeq = lpDesc->GetSequence();
- BYTE bSeqReceived = *(BYTE *)(c_pData + iPacketLen - sizeof(BYTE));
- if (bSeq != bSeqReceived)
- {
- sys_err("SEQUENCE %x mismatch 0x%x != 0x%x header %u", get_pointer(lpDesc), bSeq, bSeqReceived, bHeader);
- LPCHARACTER ch = lpDesc->GetCharacter();
- char buf[1024];
- int offset, len;
- offset = snprintf(buf, sizeof(buf), "SEQUENCE_LOG [%s]-------------\n", ch ? ch->GetName() : "UNKNOWN");
- if (offset < 0 || offset >= (int) sizeof(buf))
- offset = sizeof(buf) - 1;
- for (size_t i = 0; i < lpDesc->m_seq_vector.size(); ++i)
- {
- len = snprintf(buf + offset, sizeof(buf) - offset, "\t[%03d : 0x%x]\n",
- lpDesc->m_seq_vector[i].hdr,
- lpDesc->m_seq_vector[i].seq);
- if (len < 0 || len >= (int) sizeof(buf) - offset)
- offset += (sizeof(buf) - offset) - 1;
- else
- offset += len;
- }
- snprintf(buf + offset, sizeof(buf) - offset, "\t[%03d : 0x%x]\n", bHeader, bSeq);
- sys_err("%s", buf);
- lpDesc->SetPhase(PHASE_CLOSE);
- return true;
- }
- else
- {
- lpDesc->push_seq(bHeader, bSeq);
- lpDesc->SetNextSequence();
- //sys_err("SEQUENCE %x match %u next %u header %u", lpDesc, bSeq, lpDesc->GetSequence(), bHeader);
- }
- }
- sil:
- pkPacketInfo->SetSequence(HEADER_CG_PONG, false);
- 4)PACKET_INFO.CPP aç
- ara:
- void CPacketInfo::Set(int header, int iSize, const char * c_pszName, bool bSeq)
- değiştir:
- void CPacketInfo::Set(int header, int iSize, const char * c_pszName)
- sil:
- element->bSequencePacket = bSeq;
- if (element->bSequencePacket)
- element->iSize += sizeof(BYTE);
- sil:
- bool CPacketInfo::IsSequence(int header)
- {
- TPacketElement * pkElement = GetElement(header);
- return pkElement ? pkElement->bSequencePacket : false;
- }
- void CPacketInfo::SetSequence(int header, bool bSeq)
- {
- TPacketElement * pkElem = GetElement(header);
- if (pkElem)
- {
- if (bSeq)
- {
- if (!pkElem->bSequencePacket)
- pkElem->iSize++;
- }
- else
- {
- if (pkElem->bSequencePacket)
- pkElem->iSize--;
- }
- pkElem->bSequencePacket = bSeq;
- }
- }
- ara :
- void CPacketInfo::Log(const char * c_pszFileName)
- değiştir :
- void CPacketInfo::Log(const char * c_pszFileName)
- {
- #ifndef NO_PACKET_INFO_LOG
- FILE * fp;
- fp = fopen(c_pszFileName, "w");
- if (!fp)
- return;
- std::map<int, TPacketElement *>::iterator it = m_pPacketMap.begin();
- fprintf(fp, "Name Called Load Ratio\n");
- while (it != m_pPacketMap.end())
- {
- TPacketElement * p = it->second;
- ++it;
- fprintf(fp, "%-16s %-10d %-10u %.2f\n",
- p->stName.c_str(),
- p->iCalled,
- p->dwLoad,
- p->iCalled != 0 ? (float) p->dwLoad / p->iCalled : 0.0f);
- }
- fclose(fp);
- #endif
- }
- bul:
- , false");
- bu şekilde değiştir
- ");
- elle değiştirmek isterseniz ---> ", false" silin
- örnek:
- Set(HEADER_CG_TEXT, sizeof(TPacketCGText), "Text");
- 5) PACKET_INFO.H aç
- sil:
- bool bSequencePacket;
- ara:
- void Set(int header, int size, const char * c_pszName, bool bSeq = false);
- değiştir:
- void Set(int header, int size, const char * c_pszName);
- sil:
- bool IsSequence(int header);
- void SetSequence(int header, bool bSeq);
- 6) SEQUENCE.CPP aç
- sil
- const BYTE gc_abSequence[SEQUENCE_MAX_NUM] =
- {
- ..................BLA BLA
- ...............BLA BLA
- ............. BLA BLA
- .........BLA BLA BLA BLA
- };
- 7) aç SEQUENCE.H
- herşeyi sil
- CLIENTSIDE
- sil:
- m_iSequence = 0;
- sil tümünü:
- #define SEQUENCE_TABLE_SIZE 32768
- sil:
- void CNetworkStream::SetPacketSequenceMode(bool isOn)
- {
- m_bUseSequence = isOn;
- }
- ara:
- bool CNetworkStream::SendSequence()
- değiştir :
- bool CNetworkStream::SendSequence()
- {
- return true;
- }
- ara:
- static BYTE s_bSequenceTable[SEQUENCE_TABLE_SIZE] =
- sil:
- static BYTE s_bSequenceTable[SEQUENCE_TABLE_SIZE] =
- {
- ..................BLA BLA
- ...............BLA BLA
- ............. BLA BLA
- .........BLA BLA BLA BLA
- };
- sil:
- m_iSequence = 0;
- m_bUseSequence = false;
- m_kVec_bSequenceTable.resize(SEQUENCE_TABLE_SIZE);
- memcpy(&m_kVec_bSequenceTable[0], s_bSequenceTable, sizeof(BYTE) * SEQUENCE_TABLE_SIZE);
- NETSTREAM.H aç
- sil:
- void SetPacketSequenceMode(bool isOn);
- sil:
- DWORD m_iSequence;
- bool m_bUseSequence;
- std::vector<BYTE> m_kVec_bSequenceTable;
- PYTHONNETWORKSTREAMMODULE.CPP aö
- bul PyObject* netSetPacketSequenceMode(PyObject* poSelf, PyObject* poArgs)
- bunu sil
- CPythonNetworkStream& rns = CPythonNetworkStream::Instance();
- CAccountConnector & rkAccountConnector = CAccountConnector::Instance();
- rns.SetPacketSequenceMode(true);
- rkAccountConnector.SetPacketSequenceMode(true);
- ---------------------------------------------------------------------------------------------------------------
- 1.0 desc.cpp aç
- ara:
- void DESC::Packet(const void * c_pvData, int iSize)
- {
- assert(iSize > 0);
- değiştir:
- void DESC::Packet(const void * c_pvData, int iSize)
- {
- assert(NULL != c_pvData);
- assert(iSize > 0);
- ---------------------------------------------------------------------------------------------------------------
- ---------------------------------------------------------------------------------------------------------------
- 1.1) desc.cpp ara
- else if (!m_bEncrypted)
- değiştir:
- else if (!m_bEncrypted)
- {
- int iBytesProceed = 0;
- while (!m_pInputProcessor->Process(this, buffer_read_peek(m_lpInputBuffer), buffer_size(m_lpInputBuffer), iBytesProceed))
- {
- buffer_read_proceed(m_lpInputBuffer, iBytesProceed);
- iBytesProceed = 0;
- }
- buffer_read_proceed(m_lpInputBuffer, iBytesProceed);
- }
- else
- {
- int iSizeBuffer = buffer_size(m_lpInputBuffer);
- if (iSizeBuffer & 7)
- iSizeBuffer -= iSizeBuffer & 7;
- if (iSizeBuffer > 0)
- {
- TEMP_BUFFER tempbuf(8192 + 4);
- LPBUFFER lpBufferDecrypt = tempbuf.getptr();
- buffer_adjust_size(lpBufferDecrypt, iSizeBuffer);
- long iSizeAfter = TEA_Decrypt(reinterpret_cast<DWORD *>(buffer_write_peek(lpBufferDecrypt)),
- reinterpret_cast<const DWORD *>( buffer_read_peek(m_lpInputBuffer)),
- GetDecryptionKey(),
- iSizeBuffer);
- buffer_write_proceed(lpBufferDecrypt, iSizeAfter);
- int iBytesProceed = 0;
- while (!m_pInputProcessor->Process(this, buffer_read_peek(lpBufferDecrypt), buffer_size(lpBufferDecrypt), iBytesProceed))
- {
- if (iBytesProceed > iSizeBuffer)
- {
- buffer_read_proceed(m_lpInputBuffer, iSizeBuffer);
- iSizeBuffer = 0;
- iBytesProceed = 0;
- break;
- }
- buffer_read_proceed(m_lpInputBuffer, iBytesProceed);
- iSizeBuffer -= iBytesProceed;
- buffer_read_proceed(lpBufferDecrypt, iBytesProceed);
- iBytesProceed = 0;
- }
- buffer_read_proceed(m_lpInputBuffer, iBytesProceed);
- }
- }
- return (bytes_read);
- }
- ---------------------------------------------------------------------------------------------------------------
- ---------------------------------------------------------------------------------------------------------------
- 1.2) ara desc.cpp
- if (!m_bEncrypted)
- değiştir:
- if (!m_bEncrypted)
- {
- if (!packet_encode(m_lpOutputBuffer, c_pvData, iSize))
- {
- m_iPhase = PHASE_CLOSE;
- }
- }
- else
- {
- if (buffer_has_space(m_lpOutputBuffer) < iSize + 8)
- {
- buffer_adjust_size(m_lpOutputBuffer, iSize);
- if (buffer_has_space(m_lpOutputBuffer) < iSize + 8)
- {
- sys_err(
- "desc buffer mem_size overflow : ",
- " memsize(%u) ",
- " write_pos(%u)",
- " iSize(%d)",
- m_lpOutputBuffer->mem_size,
- m_lpOutputBuffer->write_point_pos,
- iSize);
- m_iPhase = PHASE_CLOSE;
- }
- }
- else
- {
- DWORD * pdwWritePoint = static_cast<DWORD *>(buffer_write_peek(m_lpOutputBuffer));
- if (packet_encode(m_lpOutputBuffer, c_pvData, iSize))
- {
- long iSize2 = TEA_Encrypt(pdwWritePoint, pdwWritePoint, GetEncryptionKey(), iSize);
- if (iSize2 > iSize)
- buffer_write_proceed(m_lpOutputBuffer, iSize2 - iSize);
- }
- }
- }
- SAFE_BUFFER_DELETE(m_lpBufferedOutputBuffer);
- }
- if (m_iPhase != PHASE_CLOSE)
- fdwatch_add_fd(m_lpFdw, m_sock, this, FDW_WRITE, true);
- }
- ---------------------------------------------------------------------------------------------------------------
- ---------------------------------------------------------------------------------------------------------------
- 1.4 protocol.h ara
- //buffer_adjust_size(pbuf, length);
- değiştir :
- buffer_adjust_size(pbuf, length);
- ---------------------------------------------------------------------------------------------------------------
- Anti flood sistemini aktif edelim
- 1) SERVICE.CPP aö
- ekle
- #define ENABLE_ANTI_PACKET_FLOOD
- 2) aç CHAR.CPP
- ara
- m_fAttMul = 1.0f;
- m_fDamMul = 1.0f;
- ekle
- #ifdef ENABLE_ANTI_PACKET_FLOOD
- m_dwPacketAntiFloodCount = 0;
- m_dwPacketAntiFloodPulse = 0;
- #endif
- 3) CHAR.H
- ara
- protected:
- CARDS_INFO character_cards;
- S_CARD randomized_cards[24];
- ekle
- #ifdef ENABLE_ANTI_PACKET_FLOOD
- private:
- int m_dwPacketAntiFloodPulse;
- DWORD m_dwPacketAntiFloodCount;
- public:
- int GetPacketAntiFloodPulse(){return m_dwPacketAntiFloodPulse;}
- DWORD GetPacketAntiFloodCount(){return m_dwPacketAntiFloodCount;}
- DWORD IncreasePacketAntiFloodCount(){return ++m_dwPacketAntiFloodCount;}
- void SetPacketAntiFloodPulse(int dwPulse){m_dwPacketAntiFloodPulse=dwPulse;}
- void SetPacketAntiFloodCount(DWORD dwCount){m_dwPacketAntiFloodCount=dwCount;}
- #endif
- 4) aç INPUT.CPP
- ara
- if (iExtraPacketSize < 0)
- {
- değiştir
- if (iExtraPacketSize < 0)
- {
- #ifdef ENABLE_ANTI_PACKET_FLOOD
- sys_err("Failed to analyze header(%u) host(%s)", bHeader, inet_ntoa(lpDesc->GetAddr().sin_addr));
- lpDesc->SetPhase(PHASE_CLOSE);
- #endif
- 5) INPUT_LOGIN.CPP de bul int CInputLogin::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
- tüm hepsini değiştir
- default:
- sys_err("login phase does not handle this packe2t! header %d", bHeader);
- #ifdef ENABLE_ANTI_PACKET_FLOOD
- return -1;
- #else
- return (0);
- #endif
- }
- return (iExtraLen);
- }
- 6) aç INPUT_MAIN.CPP
- ara
- if (!(ch = d->GetCharacter()))
- değiştir
- if (!(ch = d->GetCharacter()))
- {
- sys_err("no character on desc");
- d->SetPhase(PHASE_CLOSE);
- #ifdef ENABLE_ANTI_PACKET_FLOOD
- return -1;
- #else
- return (0);
- #endif
- }
- #ifdef ENABLE_ANTI_PACKET_FLOOD
- if (bHeader != HEADER_CG_ITEM_USE)
- {
- if (thecore_pulse() > ch->GetPacketAntiFloodPulse() + PASSES_PER_SEC(1))
- {
- ch->SetPacketAntiFloodCount(0);
- ch->SetPacketAntiFloodPulse(thecore_pulse());
- }
- if (ch->IncreasePacketAntiFloodCount() >= 250)
- {
- sys_err("<Flood packet> name(%s) header(%u) host(%s)", ch->GetName(), bHeader, inet_ntoa(d->GetAddr().sin_addr));
- ch->GetDesc()->DelayedDisconnect(0);
- return false;
- }
- }
- #endif
- ara
- if (!(ch = d->GetCharacter()))
- değiştir
- if (!(ch = d->GetCharacter()))
- {
- sys_err("no character on desc");
- #ifdef ENABLE_ANTI_PACKET_FLOOD
- return -1;
- #else
- return 0;
- #endif
- }
- int CInputDead::Analyze(LPDESC d, BYTE bHeader, const char * c_pData) da
- default: hepsini değiştir
- default: bununla
- #ifdef ENABLE_ANTI_PACKET_FLOOD
- return -1;
- #else
- return (0);
- #endif
- }
- return (iExtraLen);
- }
- CLIENT:
- 1) tüm sequence ile alakalı şeyleri silin
Sadece1.com