Ejemplo n.º 1
0
//检查所有服的所有def文件的md5是否匹配
int CWorldCrossserver::CheckMd5(CPluto& u)
{
	CMailBox* pmb = u.GetMailbox();
	if(pmb == NULL)
	{
		return -1;
	}

	if(((CCrossserverServer*)GetServer())->IsTrustedIp(pmb->GetServerName()))
	{
		//来自受信任的客户端,校验md5是否匹配
		CHECK_AND_GET_RPC_FIELD(u, strMd5, string);

		if(m_strDefMd5 == strMd5)
		{
			//设置信任标记
			pmb->SetAuthz(MAILBOX_CLIENT_TRUSTED);
			LogInfo("CheckMd5", "ip=%s", pmb->GetServerName().c_str());

			return 0;
		}
		else
		{
			LogWarning("CheckMd5.err1", "md5_mismatch;self=%s;other=%s", m_strDefMd5.c_str(), strMd5.c_str());
			return -2;
		}
	}

	//来自不受信任的客户端,断开连接
	GetServer()->CloseFdFromServer(pmb->GetFd());
	LogInfo("CheckMd5.err2", "err_ip=%s", pmb->GetServerName().c_str());    
	return -3;
}
Ejemplo n.º 2
0
 //获取连接的IP地址
 int CEntityBase::lGetIPAddr(lua_State* L)
 {
     if (this->m_bHasClient)
     {
         int fd = this->GetClientFd();
         CMailBox* mb = GetWorld()->GetServer()->GetClientMailbox(fd);
         if (mb)
         {
             lua_pushstring(L, mb->GetServerName().c_str());
             return 1;
         }
         else
         {
             lua_pushstring(L, "GetIPAddr, client not connected");
             lua_error(L);
             return 0;
         }
     }
     else
     {
         lua_pushstring(L, "GetIPAddr, entity has no client");
         lua_error(L);
         return 0;
     }
 }
Ejemplo n.º 3
0
int CWorldLogin::NotifyClientToAttach(T_VECTOR_OBJECT* p)
{
    if(p->size() != 3)
    {
        return -1;
    }

    const char* pszAccount = VOBJECT_GET_STR((*p)[0]);
    uint16_t baseapp_id = VOBJECT_GET_U16((*p)[1]);
    const char* pszKey = VOBJECT_GET_STR((*p)[2]);

    map<string, int>::const_iterator iter = m_accounts2fd.find(pszAccount);
    if(iter == m_accounts2fd.end())
    {
        LogWarning("NotifyClientToAttach", "Account '%s' hasn't client", pszAccount);
        return -2;
    }

    LogDebug("NotifyClientToAttach", "account=%s;fd=%d", pszAccount, iter->second);
    CMailBox* mb = GetServer()->GetClientMailbox(iter->second);
    if(mb != NULL)
    {
        CMailBox* smb = GetServer()->GetServerMailbox(baseapp_id);
        if(smb == NULL)
        {
            LogWarning("NotifyClientToAttach", "error baseapp_id:%d", baseapp_id);
            return -3;
        }

        mb->RpcCall(GetRpcUtil(), MSGID_CLIENT_NOTIFY_ATTACH_BASEAPP, smb->GetServerName().c_str(), smb->GetServerPort(), pszKey);
    }

    return 0;
}
Ejemplo n.º 4
0
    //停止所有服务器
    int CWorldMgrD::ShutdownAllServers(T_VECTOR_OBJECT* p, CPluto& u)
    {
        if(m_bShutdown)
        {
            return 0;
        }

        m_bShutdown = true;         //设置正在停止之中标记

        //步骤1:通知loginapp/baseapp/cellapp退出
        vector<CMailBox*>& mbs = GetServer()->GetAllServerMbs();
        vector<CMailBox*>::iterator iter = mbs.begin();
        for(; iter != mbs.end(); ++iter)
        {
            CMailBox* basemb = *iter;
            if(basemb && basemb->GetServerMbType() != SERVER_DBMGR)
            {
                LogDebug("CWorldMgrD::ShutdownAllServers", "basemb->GetServerMbType()=%d;basemb->GetServerName()=%s;basemb->GetServerPort()=%d", 
                                                            basemb->GetServerMbType(), basemb->GetServerName().c_str(), basemb->GetServerPort());
                basemb->RpcCall(GetRpcUtil(), MSGID_ALLAPP_SHUTDOWN_SERVER, (uint8_t)1);
            }
        }

        //步骤2:确认其他服务器退出之后,再通知dbmgr退出
        //在另外一个方法里实现

        CMailBox* mb = u.GetMailbox();
        if(mb != NULL)
        {
            mb->RpcCall(GetRpcUtil(), MSGID_BASEAPPMGR_SHUTDOWN_SERVERS_CALLBACK, (uint8_t)1);
        }

        return 0;
    }