• 🎉 Hey there! I've just launched my brand new server voting platform — Metin2 P Servers 🚀

How To speed UP the auth login in few seconds (Disable Packets Encryption)

Banned
Member
Jan
Threads
0
31
1
8
HubMoney
109
You must be wondering what will happen if we disable packet encryption?
Let's see together.
We run the risk of overloading the buffers, which will cause unmistakable game crashes and even pretty weird bugs.

I could see various strange errors. The most common thing was that we could no longer perform an action that required a contract with the game. For example, after 15 minutes of gameplay with several players connected, some will no longer be able to click on an item or others will no longer be able to speak, etc.

There was a lot of discussion about this, I got opinions from right and left and I found a topic.

I. Explication
Why weren't these bugs present before packet encryption?
Quite simply because the structure has been edited!
Indeed, we can see that in the protocol.h of the Game, the buffer_adjust_size function has been commented.
Also, in the desc.cpp, they completely removed the condition in the function:


C++:
void DESC::Packet

But why ? Simply because it's no longer useful, the new system no longer requires a size adjuster for buffers (I think)
Or, they have coded something else that automatically adjusts the size of the buffers, but I haven't looked yet.

Why would I disable this system?
LARGELY reduced connection time (since we no longer use Cipher)
Loading time also reduced
Better fluidity (personal opinion)

Hugely reduced game size as well as that of the launcher

II. Server-side changes
I. Folder service.h (Common)
Look for this line:
C++:
#define _IMPROVED_PACKET_ENCRYPTION_

And comment out the line like this:
C++:
//#define _IMPROVED_PACKET_ENCRYPTION_
Save file.
II. Folder protocol.h (Game)
Look for the following line:
C++:
//buffer_adjust_size(pbuf, length);

Uncomment it like this:
C++:
buffer_adjust_size(pbuf, length);
Save file.
III. Folder desc.cpp (Game)
Look for this code:
C++:
void DESC::Packet(const void * c_pvData, int iSize)
Replace the entire function with this:
C++:
void DESC::Packet(const void * c_pvData, int iSize)
{
    assert(iSize > 0);

    if (m_iPhase == PHASE_CLOSE) // 끊는 상태면 보내지 않는다.
        return;

    if (m_stRelayName.length() != 0)
    {
        // Relay 패킷은 암호화하지 않는다.
        TPacketGGRelay p;

        p.bHeader = HEADER_GG_RELAY;
        strlcpy(p.szName, m_stRelayName.c_str(), sizeof(p.szName));
        p.lSize = iSize;

        if (!packet_encode(m_lpOutputBuffer, &p, sizeof(p)))
        {
            m_iPhase = PHASE_CLOSE;
            return;
        }

        m_stRelayName.clear();

        if (!packet_encode(m_lpOutputBuffer, c_pvData, iSize))
        {
            m_iPhase = PHASE_CLOSE;
            return;
        }
    }
    else
    {
        if (m_lpBufferedOutputBuffer)
        {
            buffer_write(m_lpBufferedOutputBuffer, c_pvData, iSize);

            c_pvData = buffer_read_peek(m_lpBufferedOutputBuffer);
            iSize = buffer_size(m_lpBufferedOutputBuffer);
        }

        // TRAFFIC_PROFILE
        if (g_bTrafficProfileOn)
            TrafficProfiler::instance().Report(TrafficProfiler::IODIR_OUTPUT, *(BYTE *) c_pvData, iSize);
        // END_OF_TRAFFIC_PROFILER

#ifdef _IMPROVED_PACKET_ENCRYPTION_
        void* buf = buffer_write_peek(m_lpOutputBuffer);


        if (packet_encode(m_lpOutputBuffer, c_pvData, iSize))
        {
            if (cipher_.activated()) {
                cipher_.Encrypt(buf, iSize);
            }
        }
        else
        {
            m_iPhase = PHASE_CLOSE;
        }
#else
        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
            {
                // 암호화에 필요한 충분한 버퍼 크기를 확보한다.
                /* buffer_adjust_size(m_lpOutputBuffer, iSize + 8); */
                DWORD * pdwWritePoint = (DWORD *) buffer_write_peek(m_lpOutputBuffer);

                if (packet_encode(m_lpOutputBuffer, c_pvData, iSize))
                {
                    int iSize2 = TEA_Encrypt(pdwWritePoint, pdwWritePoint, GetEncryptionKey(), iSize);

                    if (iSize2 > iSize)
                        buffer_write_proceed(m_lpOutputBuffer, iSize2 - iSize);
                }
            }
        }
#endif // _IMPROVED_PACKET_ENCRYPTION_

        SAFE_BUFFER_DELETE(m_lpBufferedOutputBuffer);
    }

    //sys_log(0, "%d bytes written (first byte %d)", iSize, *(BYTE *) c_pvData);
    if (m_iPhase != PHASE_CLOSE)
        fdwatch_add_fd(m_lpFdw, m_sock, this, FDW_WRITE, true);
}
Save file.

III. Changes Client
I.Folder ServiceDefs.h (Eterpack)
Look for this line:
C++:
#define _IMPROVED_PACKET_ENCRYPTION_

And comment it like this:
C++:
//#define _IMPROVED_PACKET_ENCRYPTION_
II.Folder Locale.cpp (UserInterface)
Look for the following line:
C++:
#define LSS_SECURITY_KEY    "testtesttesttest"
Edit it like this:
C++:
#define LSS_SECURITY_KEY    "1234abcd5678efgh"