Logo Search packages:      
Sourcecode: verlihub version File versions

int nDirectConnect::nProtocol::cDCProto::DC_ConnectToMe ( cMessageDC msg,
cConnDC conn 
) [protected]

Treat the DC message in a appropriate way

Definition at line 909 of file cdcproto.cpp.

References nDirectConnect::cUser::Can(), nDirectConnect::nTables::cDCConf::check_ctm, nDirectConnect::nTables::cDCConf::classdif_download, nDirectConnect::cServerDC::ConnCloseMsg(), nDirectConnect::nTables::cDCConf::ctm_share_min, nDirectConnect::cServerDC::DCPrivateHS(), nServer::cAsyncConn::mAddrIP, nDirectConnect::cServerDC::mC, nDirectConnect::cServerDC::mCallBacks, nDirectConnect::cUserBase::mClass, nDirectConnect::nTables::cDCConf::min_share_use_hub, nDirectConnect::cUserBase::mInList, nDirectConnect::cConnDC::mpUser, nServer::cAsyncSocketServer::mTime, nDirectConnect::cServerDC::mUserList, nDirectConnect::cUser::mxConn, nUtils::cTime::Sec(), nDirectConnect::cConnDC::Send(), and nDirectConnect::nProtocol::cMessageDC::SplitChunks().

{
      string ostr;
      ostringstream os;
      if(msg->SplitChunks()) return -1;
      if(!conn->mpUser || !conn->mpUser->mInList) return -1;
      if(!conn->mpUser->Can(eUR_CTM, mS->mTime.Sec(), 0))
      {
            if(mS->mC.min_share_use_hub > 0)
            {
                  ReplaceVarInString(mS->mC.ctm_share_min, "min_share_use_hub", ostr, Simplify(mS->mC.min_share_use_hub));
                  mS->DCPrivateHS(ostr, conn);
            }
            return -4;
      }
      string &nick = msg->ChunkString(eCH_CM_NICK);
      
      // todo kontrola ip
//    if(!conn->mpUser->mIP4DL.size())
//          conn->mpUser->mIP4DL = msg->ChunkString(eCH_CM_IP);
//    else if(conn->mpUser->mIP4DL != msg->ChunkString(eCH_CM_IP))
//    {
//          os << "(automatic) CTM ip faking, flooding users; your ip: " << conn->mAddrIP
//                << " pretending to be: " << conn->mpUser->mIP4DL
//                << " and:" << msg->ChunkString(eCH_CM_IP) << endl;
//          mS->mBanList->AddBan( conn->mAddrIP, conn->mpUser->mNick, mS->mEmpty, NULL, 0, os.str(), eBT_NICKIP);
//          conn->CloseNow();
//    }
      
      if(!CheckIP(conn,msg->ChunkString(eCH_CM_IP))) {
            if(mS->mC.check_ctm) {
            os << "Your reported IP: " << msg->ChunkString(eCH_CM_IP) << " does not match your real IP: " << conn->mAddrIP;
            mS->ConnCloseMsg(conn, os.str(), 2000, eCR_SYNTAX);
            }
            return -1;
            }

      cUser *other = mS->mUserList.GetUserByNick ( nick );
      // check nick
      if(!other) return -1;
      if(conn->mpUser->mClass + mS->mC.classdif_download < other->mClass) return -4;

      #ifndef WITHOUT_PLUGINS
      if (!mS->mCallBacks.mOnParsedMsgConnectToMe.CallAll(conn, msg))
            return -2;
      #endif


      if(other->mxConn)
            other->mxConn->Send( msg->mStr );
/*    else if(nick == mS->mC.hub_security)
      {
            mS->DCPrivateHS("Hub-security doesn't share.",conn);
      }*/
      return 0;
}


Generated by  Doxygen 1.6.0   Back to index