コード例 #1
0
ファイル: cserverdc.cpp プロジェクト: Sorin91/verlihub
bool cServerDC::VerifyUniqueNick(cConnDC *conn)
{
	string UsrKey, omsg;
	mUserList.Nick2Key(conn->mpUser->mNick,UsrKey);
	/// add user to the list or fail
	if(mUserList.ContainsKey(UsrKey)) {
		bool CloseOld = false;
		cUser *old_usr = mUserList.GetUserByKey(UsrKey);

		if(conn->mpUser->mClass >= eUC_REGUSER) CloseOld = true;
		if (    !CloseOld &&
			old_usr->mxConn &&
			(conn->AddrIP() == old_usr->mxConn->AddrIP()) &&
			(conn->mpUser->mShare == old_usr->mShare) &&
			(conn->mpUser->mMyINFO_basic == old_usr->mMyINFO_basic)
		) CloseOld = true;

		if (CloseOld) {
			if(old_usr) {
				if(old_usr->mxConn) {
					if(old_usr->mxConn->Log(2))
						old_usr->mxConn->LogStream() << "Closing because of a new connection" << endl;
					omsg = _("Another user has logged in with same nick and IP address.");
					//old_usr->mxConn->Send(omsg,true);
					DCPublicHS(omsg, old_usr->mxConn);
					old_usr->mxConn->CloseNow();
				} else {
					if(ErrLog(1))
					    LogStream() << "[CRITICAL] Found user '" << old_usr->mNick << "' without a valid conneciton pointer" << endl;
				}
				RemoveNick(old_usr);
			} else {
				// This else block is not usefull since old_user pointer is used to access CUser class property above
				//if(ErrLog(0))
				//	LogStream() << "[CRITICAL] Found user '" << old_usr->mNick << "' without a valid conneciton pointer" << endl;
				conn->CloseNow();
				return false;
			}
		}
		else
		{
			omsg = _("Your nick is already in use.");
			DCPublicHS(omsg, conn);
			omsg = "$ValidateDenide " + conn->mpUser->mNick; conn->Send(omsg);
			// @todo: add redirect
			conn->CloseNow();
			return false;
		}
	}
	return true;
}
コード例 #2
0
void CIrcNickListCtrl::DeleteNickInAll( CString sNick, CString sMessage )
{
	//Remove a nick in all Channels.
	//This is a client that Quit the network, so we have a quit message..
	POSITION pos1, pos2;
	Channel* pCurrChannel = NULL;
	for (pos1 = m_pParent->m_tabctrlChannelSelect.m_ptrlistChannel.GetHeadPosition();( pos2 = pos1 ) != NULL;)
	{
		//Go through all channels..
		m_pParent->m_tabctrlChannelSelect.m_ptrlistChannel.GetNext(pos1);
		pCurrChannel = (Channel*)(m_pParent->m_tabctrlChannelSelect.m_ptrlistChannel).GetAt(pos2);
		if(RemoveNick( pCurrChannel->m_sName, sNick ))
		{
			//If nick was in channel, put message in it saying why user quit..
			if( !thePrefs.GetIrcIgnoreQuitMessage() )
				m_pParent->AddInfoMessage( pCurrChannel->m_sName, GetResString(IDS_IRC_HASQUIT), sNick, sMessage);
		}
	}
}