示例#1
0
void CInputAuth::PasspodAnswer(LPDESC d, const char * c_pData)
{

    if (!g_bAuthServer)
    {
        sys_err ("CInputAuth class is not for game server. IP %s might be a hacker.",
                 inet_ntoa(d->GetAddr().sin_addr));
        d->DelayedDisconnect(5);
        return;
    }

    TPacketCGPasspod * packet = (TPacketCGPasspod*)c_pData;

    RequestConfirmPasspod Confirm;

    memcpy(Confirm.passpod, packet->szAnswer, MAX_PASSPOD + 1);
    memcpy(Confirm.login, d->GetAccountTable().login, LOGIN_MAX_LEN + 1);


    if (!d->GetAccountTable().id)
    {
        sys_err("HEADER_CG_PASSPOD_ANSWER received to desc with no account table binded");
        return;
    }

    int ret_code = 1;
    sys_log(0, "Passpod start %s %s", d->GetAccountTable().login, packet->szAnswer);
    ret_code = CPasspod::instance().ConfirmPasspod(d->GetAccountTable().login, packet->szAnswer);

    if (ret_code != 0)
    {
        sys_log(0, "PASSPOD: wrong answer: %s ret_code %d", d->GetAccountTable().login, ret_code);

        LoginFailure(d, ERR_MESSAGE[ret_code]);

        if (!d->CheckMatrixTryCount())
        {
            LoginFailure(d, "QUIT");
            d->SetPhase(PHASE_CLOSE);
        }
    }
    else
    {
        sys_log(0, "PASSPOD: success: %s", d->GetAccountTable().login);
        DBManager::instance().SendAuthLogin(d);
    }
//	g_PasspodDesc->DBPacket(HEADER_GP_CONFIRM_PASSPOD,  0, &Confirm, sizeof(Confirm));

//	sys_log(0, "PASSPOD %s %d", Confirm.login, Confirm.passpod);
}
示例#2
0
void DESC_MANAGER::SendClientPackageCryptKey( LPDESC desc )
{
	if( !desc )
	{
		return;
	}

	TPacketGCHybridCryptKeys packet;
	{
		packet.bHeader = HEADER_GC_HYBRIDCRYPT_KEYS;
		m_pPackageCrypt->GetPackageCryptKeys( &(packet.pDataKeyStream), packet.KeyStreamLen );
	}

	if( packet.KeyStreamLen > 0 )
	{
		if (g_test_server)
		{
			// keys를 string으로 남기는 건 문제가 있음. 중간에 NULL 있으면 잘릴테니.. 그래도 혹시 모르니 남김.
			sys_log(0, "[PackageCryptInfo] send to %s. (keys: %s, len: %d)", desc->GetAccountTable().login, std::string((char*)packet.pDataKeyStream).c_str(), packet.KeyStreamLen);
		}
		desc->Packet( packet.GetStreamData(), packet.GetStreamSize() );
	}
}
示例#3
0
void CLIENT_DESC::SetPhase(int iPhase)
{
    switch (iPhase)
    {
    case PHASE_CLIENT_CONNECTING:
        sys_log(1, "PHASE_CLIENT_DESC::CONNECTING");
        m_pInputProcessor = NULL;
        break;

    case PHASE_DBCLIENT:
    {
        sys_log(1, "PHASE_DBCLIENT");

        if (!g_bAuthServer)
        {
            static bool bSentBoot = false;

            if (!bSentBoot)
            {
                bSentBoot = true;
                TPacketGDBoot p;
                p.dwItemIDRange[0] = 0;
                p.dwItemIDRange[1] = 0;
                memcpy(p.szIP, g_szPublicIP, 16);
                DBPacket(HEADER_GD_BOOT, 0, &p, sizeof(p));
            }
        }

        TEMP_BUFFER buf;

        TPacketGDSetup p;

        memset(&p, 0, sizeof(p));
        strlcpy(p.szPublicIP, g_szPublicIP, sizeof(p.szPublicIP));

        if (!g_bAuthServer)
        {
            p.bChannel	= g_bChannel;
            p.wListenPort = mother_port;
            p.wP2PPort	= p2p_port;
            p.bAuthServer = false;
            map_allow_copy(p.alMaps, 32);

            const DESC_MANAGER::DESC_SET & c_set = DESC_MANAGER::instance().GetClientSet();
            DESC_MANAGER::DESC_SET::const_iterator it;

            for (it = c_set.begin(); it != c_set.end(); ++it)
            {
                LPDESC d = *it;

                if (d->GetAccountTable().id != 0)
                    ++p.dwLoginCount;
            }

            buf.write(&p, sizeof(p));

            if (p.dwLoginCount)
            {
                TPacketLoginOnSetup pck;

                for (it = c_set.begin(); it != c_set.end(); ++it)
                {
                    LPDESC d = *it;

                    TAccountTable & r = d->GetAccountTable();

                    if (r.id != 0)
                    {
                        pck.dwID = r.id;
                        strlcpy(pck.szLogin, r.login, sizeof(pck.szLogin));
                        strlcpy(pck.szSocialID, r.social_id, sizeof(pck.szSocialID));
                        strlcpy(pck.szHost, d->GetHostName(), sizeof(pck.szHost));
                        pck.dwLoginKey = d->GetLoginKey();
#ifndef _IMPROVED_PACKET_ENCRYPTION_
                        thecore_memcpy(pck.adwClientKey, d->GetDecryptionKey(), 16);
#endif

                        buf.write(&pck, sizeof(TPacketLoginOnSetup));
                    }
                }
            }

            sys_log(0, "DB_SETUP current user %d size %d", p.dwLoginCount, buf.size());

            // 파티를 처리할 수 있게 됨.
            CPartyManager::instance().EnablePCParty();
            //CPartyManager::instance().SendPartyToDB();
        }
        else
        {
            p.bAuthServer = true;
            buf.write(&p, sizeof(p));
        }

        DBPacket(HEADER_GD_SETUP, 0, buf.read_peek(), buf.size());
        m_pInputProcessor = &m_inputDB;
    }
    break;

    case PHASE_P2P:
        sys_log(1, "PHASE_P2P");

        if (m_lpInputBuffer)
            buffer_reset(m_lpInputBuffer);

        if (m_lpOutputBuffer)
            buffer_reset(m_lpOutputBuffer);

        m_pInputProcessor = &m_inputP2P;
        break;

    case PHASE_CLOSE:
        m_pInputProcessor = NULL;
        break;

    case PHASE_TEEN:
        m_inputTeen.SetStep(0);
        m_pInputProcessor = &m_inputTeen;
        break;

    }

    m_iPhase = iPhase;
}