Example #1
0
	void CAuthModule::Handle_Ident_Packet( CIdentPacket* pPacket, CConnection* pConnection ) {
		if( CDCEngine::GetInstance()->Get_Driver_Mode() == MODE_MASTER ) {
			// Error...Master server will never connect to another system so should never receive this
			Log(LOG_AUTH, "Invalid Ident Packet received\n");
			return;
		}
		
		// Get the user object for this peer
		CUser* pUser = Get_User_By_Name( pPacket->m_Username );
		
		if( pUser ) {
			// We have the user obj and connection, link them
			pConnection->m_pUser = pUser;
			pUser->m_pConnection = pConnection;
			
			// if this is the root user, mark this as connection to Master server
			if( pUser->m_Name == "root" ) {
				m_pNetworkModule->Set_Upstream_Connection( pConnection );
			}
		}
		
		// Request update of this user's info

		CConnection* pUpstream = m_pNetworkModule->Get_Upstream_Connection();
		if( pUpstream ) {
			CUserUpdateRequestPacket* pRequestPacket = (CUserUpdateRequestPacket*)m_pNetworkModule->Create_Packet( PACKET_USERUPDATEREQUEST );
			pRequestPacket->m_Username = pPacket->m_Username;
			
			pUpstream->Send_Packet( pRequestPacket );
			
			m_pNetworkModule->Destroy_Packet( pRequestPacket );
		} else {
			Log(LOG_AUTH, "No upstream connection in Handle_Ident_Packet()\n");
		}
		
		// Notify Engine of our connection
		if(!pUser) {
			Log(LOG_AUTH, "Wtf\n");
			return;
		}
		CDCEngine::GetInstance()->On_Connect( pUser );
	}