예제 #1
0
//检查一个rpc调用是否合法
bool CWorldCrossserver::CSCheckClientRpc(CPluto& u)
{
	CMailBox* mb = u.GetMailbox();
	if(!mb)
	{
		//如果没有mb,是从本进程发来的包
		return true;
	}
	if(mb->IsDelete())
	{
		//已标记del的mb,其所有的包不再处理
		return false;
	}
	uint8_t authz = mb->GetAuthz();
	if(authz == MAILBOX_CLIENT_TRUSTED)
	{
		return true;
	}
	else if(authz == MAILBOX_CLIENT_UNAUTHZ)
	{
		//检查客户端地址是否可以信任
		//return CheckTrustedMailbox(mb);
		return u.GetMsgId() == MSGID_CROSSSERVER_CHECK_MD5;
	}
	else if(authz == MAILBOX_CLIENT_AUTHZ)
	{
		//return CheckTrustedMailbox(mb);
		return true;
	}
	else
	{
		return false;
	}
}
예제 #2
0
//检查一个rpc调用是否合法
bool world::CheckClientRpc(CPluto& u)
{
    CMailBox* mb = u.GetMailbox();
	if(!mb)
	{
		//如果没有mb,是从本进程发来的包
		return true;
	}
    uint8_t authz = mb->GetAuthz();
    //printf("authz status: %d\n", authz);
    pluto_msgid_t msg_id = u.GetMsgId();
    if(authz == MAILBOX_CLIENT_TRUSTED)
    {
        printf("authz status: %d MAILBOX_CLIENT_TRUSTED:%d\n", authz,MAILBOX_CLIENT_TRUSTED);
        return true;
    }
    else if(authz == MAILBOX_CLIENT_AUTHZ)
    {
        
        //pluto_msgid_t msg_id = u.GetMsgId();
        printf("authz status: %d MAILBOX_CLIENT_AUTHZ:%d msg_id: %d\n", authz,MAILBOX_CLIENT_AUTHZ, msg_id);
        return msg_id == MSGID_BASEAPP_CLIENT_RPCALL || msg_id == MSGID_BASEAPP_CLIENT_MOVE_REQ;
    }
    else if(authz == MAILBOX_CLIENT_UNAUTHZ)
    {
                
        printf("authz status: %d MAILBOX_CLIENT_UNAUTHZ:%d msg_id: %d\n", authz, MAILBOX_CLIENT_UNAUTHZ, msg_id);
        return msg_id == MSGID_LOGINAPP_LOGIN || msg_id == MSGID_BASEAPP_CLIENT_LOGIN || \
               msg_id == MSGID_LOGINAPP_MODIFY_LOGIN_FLAG || msg_id == MSGID_LOGINAPP_SELECT_ACCOUNT_CALLBACK;
    
    }
    else
    {
        //printf("authz status: %d error: %d\n", authz, -1);
        return false;
    }
}
예제 #3
0
파일: main.cpp 프로젝트: ilvxna/ahzs_easy
void* ThreadJob_SdkServerVerify(void* arg)
{
	CPluto& u = *((CPluto*)arg);
	pluto_msgid_t msg_id = u.GetMsgId();;
	T_VECTOR_OBJECT* p = NULL;

	CMailBox* pmb = u.GetMailbox();
	if(!pmb)
	{
		//如果没有mb,是从本进程发来的包
		delete &u;
		return (void*)-1;
	}
	uint8_t authz = pmb->GetAuthz();
	if(authz != MAILBOX_CLIENT_TRUSTED)
	{
		LogWarning("ThreadJob_SdkServerVerify", "invalid rpcall error.unknown msgid:%d\n", msg_id);
		delete &u;
		return (void*)-1;
	}

	p = g_worldOther.GetRpcUtil().Decode(u);
	if(p == NULL)
	{
		LogWarning("ThreadJob_SdkServerVerify", "rpc Decode error.unknown msgid:%d\n", msg_id);
		delete &u;
		return (void*)-2;
	}

	if(u.GetDecodeErrIdx() > 0)
	{
		ClearTListObject(p);
		//PrintHexPluto(u);
		LogWarning("ThreadJob_SdkServerVerify", "rpc Decode error.msgid:%d;pluto err idx=%d\n", msg_id, u.GetDecodeErrIdx());
		delete &u;
		return (void*)-3;
	}

	if (p->size() != 4)
	{
		delete &u;
		return (void*)-4;
	}
	string& url = VOBJECT_GET_SSTR((*p)[0]);
	int32_t nFd = VOBJECT_GET_I32((*p)[1]);
	string& strAccount = VOBJECT_GET_SSTR((*p)[2]);
	string& strPlatId = VOBJECT_GET_SSTR((*p)[3]);
	//CMailBox* pmb = u.GetMailbox();

	string resp = "";
	int ret = GetUrl(url.c_str(), resp);
	if (ret != CURLE_OK)
	{
		LogWarning("CWorldOther::SdkServerVerify", "%s ret = %d", strAccount.c_str(), ret);
		//todo:faild.
		pmb->RpcCall(g_worldOther.GetRpcUtil(), MSGID_LOGINAPP_LOGIN_VERIFY_CALLBACK, ret, nFd, strAccount, strPlatId);
		delete &u;
		return 0;
	}
	Trim(resp);
	cJSON* json = cJSON_Parse(resp.c_str());
	cJSON* childJs = cJSON_GetObjectItem(json, "code");
	int rst = cJSON_GetObjectItem(json, "code")->valueint;

	if (rst == 1)
	{
		//succeed.
		if (strAccount.c_str() != cJSON_GetObjectItem(json, "msg")->valuestring)
		{
			ret = 0;
		}
		else
		{
			LogWarning("CWorldOther::SdkServerVerify", "strAccount[%s] msg[%s]", 
				strAccount.c_str(), cJSON_GetObjectItem(json, "msg")->valuestring);
			ret = 1;
			//pmb->RpcCall(GetRpcUtil(), MSGID_LOGINAPP_LOGIN_VERIFY_CALLBACK, int32_t(1), nFd, strAccount, strPlatId);
		}
	}
	else
	{
		//failed.
		LogWarning("CWorldOther::SdkServerVerify", "strAccount[%s] rst[%d]", 
			strAccount.c_str(), rst);
		ret = -1;
		//pmb->RpcCall(GetRpcUtil(), MSGID_LOGINAPP_LOGIN_VERIFY_CALLBACK, -1, nFd, strAccount, strPlatId);
	}
	pmb->RpcCall(g_worldOther.GetRpcUtil(), MSGID_LOGINAPP_LOGIN_VERIFY_CALLBACK, ret, nFd, strAccount, strPlatId);
	delete &u;
	return (void*)0;
}