Client Class Reference

Client object encapsulates a single remote client that we are communicating with. More...

#include <clients.h>

List of all members.


Public Member Functions

 DECLARE_EVENT_TABLE (Client *, ClientEvent)
void setServerAddr (IPV4Address addr)
void startUpload ()
 Start uploading to this client.
void reqDownload ()
 Request to download current requested file from this client (e.g.
void sendQR ()
 Send queue ranking to the remote client.
float getScore () const
 Calculates client score, based on credits and wait time in queue (if applicaple).
void addOffered (Download *file, bool doConn=true)
 Add an offered file to this client's offered files list.
void remOffered (Download *file, bool cleanUp=true)
 Remove an offered file.
bool isConnected () const
 Check if the connection is currently established with this client.
bool callbackInProgress () const
 Check whether there's LowID callback in progress.
bool reaskInProgress () const
 Check whether we are currently in process of reasking the source.
void setOnQueue (uint32_t qr)
 Set the current client state to indicate that we are on remote client's queue, waiting for an upload.
void removeFromQueue ()
 Resets all queue-related data and emits EVT_CANCEL_UPLOADREQ to indicate that this client no longer wants anything from us.
void verifyIdent ()
 Attempt to verify this client's identity.
std::string getIpPort () const
 Small helper function for retrieving client IP/ID/port combination in printable format.
get-to-know-you-chit-chat
void onPacket (const ED2KPacket::Hello &p)
void onPacket (const ED2KPacket::HelloAnswer &p)
void onPacket (const ED2KPacket::MuleInfo &p)
void onPacket (const ED2KPacket::MuleInfoAnswer &p)
Uploading
void onPacket (const ED2KPacket::ReqFile &p)
void onPacket (const ED2KPacket::SetReqFileId &p)
void onPacket (const ED2KPacket::ReqHashSet &p)
void onPacket (const ED2KPacket::StartUploadReq &p)
void onPacket (const ED2KPacket::ReqChunks &p)
void onPacket (const ED2KPacket::CancelTransfer &)
Downloading
void onPacket (const ED2KPacket::FileName &p)
void onPacket (const ED2KPacket::FileDesc &p)
void onPacket (const ED2KPacket::NoFile &p)
void onPacket (const ED2KPacket::FileStatus &p)
void onPacket (const ED2KPacket::HashSet &p)
void onPacket (const ED2KPacket::AcceptUploadReq &)
void onPacket (const ED2KPacket::QueueRanking &p)
void onPacket (const ED2KPacket::MuleQueueRank &p)
void onPacket (const ED2KPacket::DataChunk &p)
void onPacket (const ED2KPacket::PackedChunk &p)
Source Exchange
void onPacket (const ED2KPacket::SourceExchReq &p)
void onPacket (const ED2KPacket::AnswerSources &p)
Miscellanous
void onPacket (const ED2KPacket::Message &p)
void onPacket (const ED2KPacket::ChangeId &p)
SecIdent
void onPacket (const ED2KPacket::SecIdentState &p)
void onPacket (const ED2KPacket::PublicKey &p)
void onPacket (const ED2KPacket::Signature &p)
UDP packets
void onPacket (const ED2KPacket::ReaskFilePing &p)
void onPacket (const ED2KPacket::FileNotFound &p)
void onPacket (const ED2KPacket::ReaskAck &p)
void onPacket (const ED2KPacket::QueueFull &p)
Accessors for this client's information
Hash< MD4Hash > getHash () const
uint32_t getId () const
uint16_t getTcpPort () const
uint16_t getUdpPort () const
IPV4Address getServerAddr () const
std::string getNick () const
bool supportsPreview () const
bool supportsMultiPacket () const
bool supportsViewShared () const
bool supportsPeerCache () const
uint8_t getCommentVer () const
uint8_t getExtReqVer () const
uint8_t getSrcExchVer () const
uint8_t getSecIdentVer () const
uint8_t getComprVer () const
uint8_t getUdpVer () const
bool supportsUnicode () const
uint8_t getAICHVer () const
bool isLowId () const
bool isHighId () const
uint8_t getClientSoft () const
uint32_t getVerMjr () const
uint32_t getVerMin () const
uint32_t getVerPch () const
uint32_t getVerBld () const
std::string getSoftStr () const
std::string getVerStr () const
bool isMule () const
Other generic accessors
ED2KClientSocketgetSocket () const
void setSocket (ED2KClientSocket *s)
Accessors for extensions
Detail::SourceInfoPtr getSourceInfo () const
Detail::QueueInfoPtr getQueueInfo () const
Detail::UploadInfoPtr getUploadInfo () const
Detail::DownloadInfoPtr getDownloadInfo () const

Private Member Functions

 Client ()
 Forbidden.
 ~Client ()
 Allowed by ClientList.
 Client (const Client &)
 Copying forbidden.
const Clientoperator= (const Client &)
 Copying forbidden.
 Client (ED2KClientSocket *c)
 Only allowed constructor.
 Client (IPV4Address addr, Download *file)
 Construct a "source" type client, which has a file to offer for us.
void onSocketEvent (ED2KClientSocket *c, SocketEvent evt)
 Event handler for socket events.
void destroy ()
 Scheduler the object for destruction.
void storeInfo (const ED2KPacket::Hello &p)
 Copy client information from the hello packet to internal variables.
void processMuleInfo (const ED2KPacket::MuleInfo &p)
 Processes, extracts and stores all useful information from this extinct packet, used by some older mule-based clients.
void merge (Client *c)
 Merge sockets and parser from other client to this client, taking ownership of those two.
void onUploadReq (const Hash< ED2KHash > &hash)
 Generalized version of upload requests - constructs the neccesery members and emits the neccesery events, indicating the client wishes to download something from us.
void sendChunkReqs (bool onlyNew=false)
 Sends next three chunk requests to current downloadclient.
void sendNextChunk ()
 Sends next chunk to socket (when uploading).
void establishConnection ()
 Establish connection with the remote client either by directly connecting to it, or performing a low-id callback operation through server.
void reaskForDownload ()
 Performs UDP reask for download.
void checkDestroy ()
 Checks if this client is useful to us at all, and if not, emits EVT_DESTROY.
void sendSignature ()
 Send our signature to this client.
void sendPublicKey ()
 Send our public key to this client.
void initTransfer ()
 Called after successful handshake (and optionally, SecIdent), starts actual data transfer.
void handshakeCompleted ()
 Called by ClientList after received IDChange event from us, this indicates that merging (if any) with existing client has been completed, and we are ready to proceed, depending on context.
void verifyHashSet (boost::shared_ptr< ED2KHashSet > hs)
 Verify the contents of the passed hashset by re-calculating the file- hash from the chunkhashes.

Static Private Member Functions

static ED2KUDPSocket *& getUdpSocket ()
 Returns reference to pointer to ClientUDPSocket; only allowed to be used by ClientList.

Private Attributes

bool m_callbackInProgress
 TCP callback is in progress.
bool m_reaskInProgress
 (UDP) reask is in progress
uint8_t m_failedUdpReasks
 Number of failed UDP reasks (in row).
uint64_t m_lastReaskTime
 When was last source reask done.
uint32_t m_sentChallenge
 During identity verification, contains challenge sent TO the client.
uint32_t m_reqChallenge
 During identity verification, contains challenge sent BY the client.
bool m_upReqInProgress
 State: Upload request is in progress.
bool m_dnReqInProgress
 State: Download request is in progress.
Information we have on this client
uint32_t m_id
 Client ID ( <= 0x00fffff == LowID ).
uint16_t m_tcpPort
 TCP port.
uint16_t m_udpPort
 UDP port.
uint32_t m_features
 Supported features.
Hash< MD4Hash > m_hash
 Userhash.
PublicKey m_pubKey
 Client's public key.
IPV4Address m_serverAddr
 Server the client is connected to.
std::string m_nick
 User nickname.
uint32_t m_clientSoft
 Client soft and version.
Internal things
boost::shared_ptr< ED2KParser<
Client > > 
m_parser
 Stream parser.
ED2KClientSocketm_socket
 Socket.
Creditsm_credits
 May be 0.
Detail::QueueInfoPtr m_queueInfo
Detail::UploadInfoPtr m_uploadInfo
Detail::SourceInfoPtr m_sourceInfo
Detail::DownloadInfoPtr m_downloadInfo

Friends

class ClientList

Detailed Description

Client object encapsulates a single remote client that we are communicating with.

The reasons for communication may be either because it wants something from us, because we want something from it, or even both. The exact purpose of the client is not defined by this object. Instead, the purpose is defined by member objects DownloadClient and/or UploadClient. As long as the client has at least a single purpose, it must be alive, however when it has fulfulled it's purpose, and no longer contains neither UploadClient nor DownloadClient, it must return to the source.

Definition at line 92 of file clients.h.


Constructor & Destructor Documentation

Client::Client  )  [private]
 

Forbidden.

Client::~Client  )  [private]
 

Allowed by ClientList.

Definition at line 173 of file clients.cpp.

References m_socket.

Client::Client const Client  )  [private]
 

Copying forbidden.

Client::Client ED2KClientSocket c  )  [private]
 

Only allowed constructor.

The socket is required to initialize the client and perform initial handshaking with the client.

Parameters:
c Socket connecting to this client.
Precondition:
The socket must be in connected state, waiting for data.
Postcondition:
The socket object ownership is transfered to this class.

Definition at line 148 of file clients.cpp.

References m_id, m_parser, m_tcpPort, and onSocketEvent().

Client::Client IPV4Address  addr,
Download file
[private]
 

Construct a "source" type client, which has a file to offer for us.

Parameters:
addr Address where the client is
file File the client is offering

Definition at line 163 of file clients.cpp.

References addOffered().


Member Function Documentation

Client::DECLARE_EVENT_TABLE Client ,
ClientEvent 
 

void Client::onPacket const ED2KPacket::Hello p  ) 
 

Definition at line 589 of file clients.cpp.

References getVerMin(), isMule(), m_socket, and storeInfo().

Referenced by ClientList::onUdpData().

void Client::onPacket const ED2KPacket::HelloAnswer p  ) 
 

Definition at line 604 of file clients.cpp.

References getIpPort(), and storeInfo().

void Client::onPacket const ED2KPacket::MuleInfo p  ) 
 

Definition at line 611 of file clients.cpp.

References getIpPort(), m_socket, and processMuleInfo().

void Client::onPacket const ED2KPacket::MuleInfoAnswer p  ) 
 

Definition at line 621 of file clients.cpp.

References getIpPort(), and processMuleInfo().

void Client::onPacket const ED2KPacket::ReqFile p  ) 
 

Definition at line 651 of file clients.cpp.

References DownloadList::find(), getIpPort(), DownloadList::instance(), isConnected(), m_socket, m_sourceInfo, m_upReqInProgress, and reqDownload().

void Client::onPacket const ED2KPacket::SetReqFileId p  ) 
 

Definition at line 683 of file clients.cpp.

References EVT_UPLOADREQ, getIpPort(), isConnected(), m_queueInfo, m_socket, and m_uploadInfo.

void Client::onPacket const ED2KPacket::ReqHashSet p  ) 
 

Definition at line 773 of file clients.cpp.

References getIpPort(), and m_socket.

void Client::onPacket const ED2KPacket::StartUploadReq p  ) 
 

Definition at line 735 of file clients.cpp.

References getIpPort(), and onUploadReq().

void Client::onPacket const ED2KPacket::ReqChunks p  ) 
 

Definition at line 876 of file clients.cpp.

References isConnected(), m_uploadInfo, and sendNextChunk().

void Client::onPacket const ED2KPacket::CancelTransfer  ) 
 

Definition at line 984 of file clients.cpp.

References EVT_CANCEL_UPLOADREQ, and TRACE_DEADSRC.

void Client::onPacket const ED2KPacket::FileName p  ) 
 

Definition at line 1007 of file clients.cpp.

References addOffered(), DownloadList::find(), Download::getHash(), getIpPort(), DownloadList::instance(), isConnected(), Download::isSourceReqAllowed(), m_socket, m_sourceInfo, Download::setLastSrcExch(), and TRACE_SRCEXCH.

void Client::onPacket const ED2KPacket::FileDesc p  ) 
 

Definition at line 1055 of file clients.cpp.

References Download::getPartData(), m_sourceInfo, and ED2KFile::ratingToString().

void Client::onPacket const ED2KPacket::NoFile p  ) 
 

Definition at line 1147 of file clients.cpp.

References DownloadList::find(), getIpPort(), DownloadList::instance(), m_sourceInfo, and remOffered().

void Client::onPacket const ED2KPacket::FileStatus p  ) 
 

Definition at line 1083 of file clients.cpp.

References addOffered(), EVT_REASKFILEPING, DownloadList::find(), getIpPort(), Download::getPartData(), DownloadList::instance(), isConnected(), m_downloadInfo, m_lastReaskTime, m_socket, m_sourceInfo, and SOURCE_REASKTIME.

void Client::onPacket const ED2KPacket::HashSet p  ) 
 

Definition at line 1166 of file clients.cpp.

References getIpPort(), Download::getPartData(), m_sourceInfo, and verifyHashSet().

void Client::onPacket const ED2KPacket::AcceptUploadReq  ) 
 

Definition at line 1302 of file clients.cpp.

References getIpPort(), Download::getPartData(), m_downloadInfo, m_sourceInfo, and sendChunkReqs().

void Client::onPacket const ED2KPacket::QueueRanking p  ) 
 

Definition at line 1260 of file clients.cpp.

References setOnQueue().

void Client::onPacket const ED2KPacket::MuleQueueRank p  ) 
 

Definition at line 1264 of file clients.cpp.

References setOnQueue().

void Client::onPacket const ED2KPacket::DataChunk p  ) 
 

Definition at line 1387 of file clients.cpp.

References Credits::addDownloaded(), COL_RECV, CreditsDb::create(), and CreditsDb::instance().

void Client::onPacket const ED2KPacket::PackedChunk p  ) 
 

Definition at line 1414 of file clients.cpp.

References Credits::addDownloaded(), COL_RECV, CreditsDb::create(), getIpPort(), CreditsDb::instance(), isConnected(), m_credits, m_downloadInfo, m_hash, m_pubKey, and sendChunkReqs().

void Client::onPacket const ED2KPacket::SourceExchReq p  ) 
 

Definition at line 1441 of file clients.cpp.

References DownloadList::find(), getIpPort(), Download::getSourceCount(), Download::getSources(), getSrcExchVer(), DownloadList::instance(), m_socket, m_sourceInfo, and TRACE_SRCEXCH.

void Client::onPacket const ED2KPacket::AnswerSources p  ) 
 

Definition at line 1467 of file clients.cpp.

References Detail::foundServer, Detail::foundSource, getIpPort(), getSrcExchVer(), and TRACE_SRCEXCH.

void Client::onPacket const ED2KPacket::Message p  ) 
 

Definition at line 1516 of file clients.cpp.

References getIpPort().

void Client::onPacket const ED2KPacket::ChangeId p  ) 
 

Definition at line 1499 of file clients.cpp.

References Detail::changeId, getIpPort(), and isHighId().

void Client::onPacket const ED2KPacket::SecIdentState p  ) 
 

Definition at line 1523 of file clients.cpp.

References getIpPort(), m_pubKey, m_reqChallenge, m_sentChallenge, sendPublicKey(), sendSignature(), SI_KEYANDSIGNEEDED, SI_SIGNEEDED, TRACE_SECIDENT, and verifyIdent().

void Client::onPacket const ED2KPacket::PublicKey p  ) 
 

Definition at line 1550 of file clients.cpp.

References PublicKey::clear(), getIpPort(), m_credits, m_pubKey, m_reqChallenge, sendSignature(), and TRACE_SECIDENT.

void Client::onPacket const ED2KPacket::Signature p  ) 
 

Definition at line 1571 of file clients.cpp.

References destroy(), CreditsDb::find(), Credits::getDownloaded(), getIpPort(), Credits::getPubKey(), getSecIdentVer(), Credits::getUploaded(), initTransfer(), CreditsDb::instance(), IP_LOCAL, IP_REMOTE, isHighId(), isLowId(), m_credits, m_pubKey, m_sentChallenge, m_socket, TRACE_SECIDENT, and CreditsDb::verifySignature().

void Client::onPacket const ED2KPacket::ReaskFilePing p  ) 
 

Definition at line 1808 of file clients.cpp.

References addOffered(), DownloadList::find(), getId(), getIpPort(), Download::getPartData(), getUdpPort(), getUdpVer(), DownloadList::instance(), isLowId(), m_queueInfo, m_uploadInfo, onUploadReq(), and s_clientUdpSocket.

void Client::onPacket const ED2KPacket::FileNotFound p  ) 
 

Definition at line 1906 of file clients.cpp.

References getIpPort(), m_failedUdpReasks, m_lastReaskTime, m_reaskInProgress, m_sourceInfo, and remOffered().

void Client::onPacket const ED2KPacket::ReaskAck p  ) 
 

Definition at line 1883 of file clients.cpp.

References EVT_REASKFILEPING, getIpPort(), m_failedUdpReasks, m_lastReaskTime, m_reaskInProgress, m_sourceInfo, and SOURCE_REASKTIME.

void Client::onPacket const ED2KPacket::QueueFull p  ) 
 

Definition at line 1921 of file clients.cpp.

References EVT_REASKFILEPING, getIpPort(), m_failedUdpReasks, m_lastReaskTime, m_reaskInProgress, m_sourceInfo, and SOURCE_REASKTIME.

Hash<MD4Hash> Client::getHash  )  const [inline]
 

Definition at line 151 of file clients.h.

References m_hash.

uint32_t Client::getId  )  const [inline]
 

Definition at line 152 of file clients.h.

References m_id.

Referenced by getIpPort(), onPacket(), reaskForDownload(), and sendSignature().

uint16_t Client::getTcpPort  )  const [inline]
 

Definition at line 153 of file clients.h.

References m_tcpPort.

Referenced by getIpPort().

uint16_t Client::getUdpPort  )  const [inline]
 

Definition at line 154 of file clients.h.

References m_udpPort.

Referenced by onPacket(), and reaskForDownload().

IPV4Address Client::getServerAddr  )  const [inline]
 

Definition at line 155 of file clients.h.

References m_serverAddr.

std::string Client::getNick  )  const [inline]
 

Definition at line 156 of file clients.h.

References m_nick.

bool Client::supportsPreview  )  const [inline]
 

Definition at line 157 of file clients.h.

References m_features.

bool Client::supportsMultiPacket  )  const [inline]
 

Definition at line 158 of file clients.h.

References m_features.

bool Client::supportsViewShared  )  const [inline]
 

Definition at line 159 of file clients.h.

References m_features.

bool Client::supportsPeerCache  )  const [inline]
 

Definition at line 160 of file clients.h.

References m_features.

uint8_t Client::getCommentVer  )  const [inline]
 

Definition at line 161 of file clients.h.

References m_features.

uint8_t Client::getExtReqVer  )  const [inline]
 

Definition at line 162 of file clients.h.

References m_features.

uint8_t Client::getSrcExchVer  )  const [inline]
 

Definition at line 163 of file clients.h.

References m_features.

Referenced by onPacket().

uint8_t Client::getSecIdentVer  )  const [inline]
 

Definition at line 164 of file clients.h.

References m_features.

Referenced by handshakeCompleted(), onPacket(), sendSignature(), and verifyIdent().

uint8_t Client::getComprVer  )  const [inline]
 

Definition at line 165 of file clients.h.

References m_features.

Referenced by sendNextChunk().

uint8_t Client::getUdpVer  )  const [inline]
 

Definition at line 166 of file clients.h.

References m_features.

Referenced by onPacket(), and reaskForDownload().

bool Client::supportsUnicode  )  const [inline]
 

Definition at line 167 of file clients.h.

References m_features.

uint8_t Client::getAICHVer  )  const [inline]
 

Definition at line 168 of file clients.h.

References m_features.

bool Client::isLowId  )  const [inline]
 

Definition at line 169 of file clients.h.

References m_id.

Referenced by establishConnection(), onPacket(), reaskForDownload(), and sendSignature().

bool Client::isHighId  )  const [inline]
 

Definition at line 170 of file clients.h.

References m_id.

Referenced by getIpPort(), onPacket(), and reaskForDownload().

uint8_t Client::getClientSoft  )  const [inline]
 

Definition at line 171 of file clients.h.

References m_clientSoft.

Referenced by getVerStr(), isMule(), and storeInfo().

uint32_t Client::getVerMjr  )  const [inline]
 

Definition at line 172 of file clients.h.

References m_clientSoft.

Referenced by getVerStr().

uint32_t Client::getVerMin  )  const [inline]
 

Definition at line 173 of file clients.h.

References m_clientSoft.

Referenced by getVerStr(), onPacket(), and processMuleInfo().

uint32_t Client::getVerPch  )  const [inline]
 

Definition at line 174 of file clients.h.

References m_clientSoft.

Referenced by getVerStr().

uint32_t Client::getVerBld  )  const [inline]
 

Definition at line 175 of file clients.h.

References m_clientSoft.

Referenced by getVerStr().

std::string Client::getSoftStr  )  const
 

Definition at line 542 of file clients.cpp.

References CS_AMULE, CS_CDONKEY, CS_DONKEY, CS_EMULE, CS_EMULEPLUS, CS_HYBRID, CS_HYDRANODE, CS_LPHANT, CS_LXMULE, CS_MLDONKEY, CS_MLDONKEY_NEW, CS_MLDONKEY_NEW2, CS_OLDEMULE, CS_SHAREAZA, CS_UNKNOWN, and m_clientSoft.

Referenced by processMuleInfo(), and storeInfo().

std::string Client::getVerStr  )  const
 

Definition at line 566 of file clients.cpp.

References CS_EMULE, getClientSoft(), getVerBld(), getVerMin(), getVerMjr(), and getVerPch().

Referenced by processMuleInfo(), and storeInfo().

bool Client::isMule  )  const
 

Definition at line 580 of file clients.cpp.

References CS_EMULE, getClientSoft(), and m_hash.

Referenced by onPacket(), processMuleInfo(), and sendQR().

ED2KClientSocket* Client::getSocket  )  const [inline]
 

Definition at line 183 of file clients.h.

References m_socket.

void Client::setSocket ED2KClientSocket s  )  [inline]
 

Definition at line 184 of file clients.h.

References m_socket.

void Client::setServerAddr IPV4Address  addr  )  [inline]
 

Definition at line 190 of file clients.h.

References m_serverAddr.

Referenced by ClientList::addSource().

void Client::startUpload  ) 
 

Start uploading to this client.

Precondition:
m_uploadClient member exists

Definition at line 815 of file clients.cpp.

References destroy(), establishConnection(), getIpPort(), isConnected(), m_queueInfo, m_socket, m_uploadInfo, sendNextChunk(), and TRACE_DEADSRC.

Referenced by initTransfer(), onUploadReq(), and ClientList::startNextUpload().

void Client::reqDownload  ) 
 

Request to download current requested file from this client (e.g.

sends ReqFile packet).

Definition at line 1268 of file clients.cpp.

References Download::getHash(), getIpPort(), Download::getPartData(), isConnected(), m_dnReqInProgress, m_lastReaskTime, m_socket, m_sourceInfo, and SOURCE_REASKTIME.

Referenced by addOffered(), initTransfer(), and onPacket().

void Client::sendQR  ) 
 

Send queue ranking to the remote client.

Precondition:
m_socket exists and is in connected state

m_uploadClient exists

Definition at line 847 of file clients.cpp.

References getIpPort(), isConnected(), isMule(), m_dnReqInProgress, m_downloadInfo, m_parser, m_queueInfo, m_socket, m_uploadInfo, and m_upReqInProgress.

float Client::getScore  )  const
 

Calculates client score, based on credits and wait time in queue (if applicaple).

Definition at line 271 of file clients.cpp.

References Credits::getScore(), m_credits, m_queueInfo, and s_curTick.

Referenced by scoreComp().

void Client::addOffered Download file,
bool  doConn = true
 

Add an offered file to this client's offered files list.

Parameters:
file Offered file
doConn Whether we are allowed to establish connection too

Definition at line 285 of file clients.cpp.

References establishConnection(), getIpPort(), isConnected(), m_downloadInfo, m_socket, m_sourceInfo, and reqDownload().

Referenced by ClientList::addSource(), Client(), and onPacket().

void Client::remOffered Download file,
bool  cleanUp = true
 

Remove an offered file.

Parameters:
file File this client is no longer offering
cleanUp If true, also cleanup our things from PartData

Definition at line 309 of file clients.cpp.

References checkDestroy(), m_downloadInfo, and m_sourceInfo.

Referenced by onPacket().

bool Client::isConnected  )  const
 

Check if the connection is currently established with this client.

Returns:
true if yes, false otherwise

Definition at line 263 of file clients.cpp.

References m_socket.

Referenced by addOffered(), initTransfer(), onPacket(), reaskForDownload(), reqDownload(), sendNextChunk(), sendPublicKey(), sendQR(), sendSignature(), startUpload(), and verifyIdent().

bool Client::callbackInProgress  )  const [inline]
 

Check whether there's LowID callback in progress.

Returns:
true if there's a LowID callback in progress, false otherwise

Definition at line 247 of file clients.h.

References m_callbackInProgress.

bool Client::reaskInProgress  )  const [inline]
 

Check whether we are currently in process of reasking the source.

Returns:
true if reasking is in progress, false otherwise

Definition at line 254 of file clients.h.

References m_reaskInProgress.

void Client::setOnQueue uint32_t  qr  ) 
 

Set the current client state to indicate that we are on remote client's queue, waiting for an upload.

This implies we have m_sourceInfo member alive, and no m_downloadInfo.

Don't confuse this with similar concept where the remote client is queued on our upload queue.

Parameters:
qr Remote queue rank

Definition at line 1231 of file clients.cpp.

References COL_COMP, getIpPort(), m_dnReqInProgress, m_downloadInfo, m_parser, m_socket, m_sourceInfo, m_uploadInfo, and m_upReqInProgress.

Referenced by onPacket().

void Client::removeFromQueue  ) 
 

Resets all queue-related data and emits EVT_CANCEL_UPLOADREQ to indicate that this client no longer wants anything from us.

Definition at line 1938 of file clients.cpp.

References checkDestroy(), EVT_CANCEL_UPLOADREQ, and m_queueInfo.

Referenced by ClientList::updateQueue().

void Client::verifyIdent  ) 
 

Attempt to verify this client's identity.

Definition at line 1691 of file clients.cpp.

References ED2KPacket::SecIdentState::getChallenge(), getIpPort(), getSecIdentVer(), isConnected(), m_pubKey, m_sentChallenge, m_socket, SI_KEYANDSIGNEEDED, SI_SIGNEEDED, and TRACE_SECIDENT.

Referenced by handshakeCompleted(), and onPacket().

std::string Client::getIpPort  )  const
 

Small helper function for retrieving client IP/ID/port combination in printable format.

Definition at line 193 of file clients.cpp.

References getId(), getTcpPort(), and isHighId().

Referenced by addOffered(), Detail::UploadInfo::bufferData(), establishConnection(), merge(), onPacket(), onSocketEvent(), processMuleInfo(), reaskForDownload(), Detail::SourceInfo::remOffered(), reqDownload(), sendNextChunk(), sendQR(), sendSignature(), setOnQueue(), startUpload(), storeInfo(), verifyIdent(), Detail::DownloadInfo::~DownloadInfo(), Detail::SourceInfo::~SourceInfo(), and Detail::UploadInfo::~UploadInfo().

Detail::SourceInfoPtr Client::getSourceInfo  )  const [inline]
 

Definition at line 289 of file clients.h.

References m_sourceInfo.

Detail::QueueInfoPtr Client::getQueueInfo  )  const [inline]
 

Definition at line 290 of file clients.h.

References m_queueInfo.

Detail::UploadInfoPtr Client::getUploadInfo  )  const [inline]
 

Definition at line 291 of file clients.h.

References m_uploadInfo.

Detail::DownloadInfoPtr Client::getDownloadInfo  )  const [inline]
 

Definition at line 292 of file clients.h.

References m_downloadInfo.

const Client& Client::operator= const Client  )  [private]
 

Copying forbidden.

void Client::onSocketEvent ED2KClientSocket c,
SocketEvent  evt
[private]
 

Event handler for socket events.

This is called from event loop.

Parameters:
c Socket causing the event. Must match m_socket member
evt The event that happened

Definition at line 397 of file clients.cpp.

References destroy(), EVT_CANCEL_UPLOADREQ, getIpPort(), m_dnReqInProgress, m_downloadInfo, m_failedUdpReasks, m_lastReaskTime, m_parser, m_queueInfo, m_socket, m_sourceInfo, m_uploadInfo, m_upReqInProgress, sendNextChunk(), SOCKET_TIMEOUT, and TRACE_DEADSRC.

Referenced by Client(), establishConnection(), and merge().

void Client::destroy  )  [private]
 

Scheduler the object for destruction.

Note that the actual destruction is performed by the owner of this object (ClientList).

Definition at line 177 of file clients.cpp.

References EVT_DESTROY, m_downloadInfo, m_queueInfo, m_socket, m_sourceInfo, and m_uploadInfo.

Referenced by checkDestroy(), establishConnection(), onPacket(), onSocketEvent(), sendNextChunk(), and startUpload().

void Client::storeInfo const ED2KPacket::Hello p  )  [private]
 

Copy client information from the hello packet to internal variables.

Parameters:
p Packet to copy the data from
Note:
This overwrites any existing information we might have stored for this client.

Definition at line 515 of file clients.cpp.

References Detail::changeId, CS_MLDONKEY_NEW2, getClientSoft(), Credits::getHash(), getIpPort(), getSoftStr(), getVerStr(), m_clientSoft, m_features, m_hash, m_nick, m_serverAddr, m_tcpPort, and m_udpPort.

Referenced by onPacket().

void Client::processMuleInfo const ED2KPacket::MuleInfo p  )  [private]
 

Processes, extracts and stores all useful information from this extinct packet, used by some older mule-based clients.

Parameters:
p MuleInfo packet to be processed

Definition at line 628 of file clients.cpp.

References getIpPort(), getSoftStr(), getVerMin(), getVerStr(), handshakeCompleted(), isMule(), and m_clientSoft.

Referenced by onPacket().

void Client::merge Client c  )  [private]
 

Merge sockets and parser from other client to this client, taking ownership of those two.

Parameters:
c Other client to merge data from

Definition at line 329 of file clients.cpp.

References getIpPort(), m_callbackInProgress, m_clientSoft, m_credits, m_downloadInfo, Credits::m_hash, m_hash, m_lastReaskTime, m_nick, m_parser, m_pubKey, m_queueInfo, m_reqChallenge, m_sentChallenge, m_serverAddr, m_socket, m_sourceInfo, m_udpPort, m_uploadInfo, and onSocketEvent().

void Client::onUploadReq const Hash< ED2KHash > &  hash  )  [private]
 

Generalized version of upload requests - constructs the neccesery members and emits the neccesery events, indicating the client wishes to download something from us.

Parameters:
hash Hash of the file the client is interested in.

Definition at line 743 of file clients.cpp.

References EVT_UPLOADREQ, m_queueInfo, m_uploadInfo, and startUpload().

Referenced by onPacket().

void Client::sendChunkReqs bool  onlyNew = false  )  [private]
 

Sends next three chunk requests to current downloadclient.

Parameters:
onlyNew If set true, only new requests are sent

Definition at line 1341 of file clients.cpp.

Referenced by onPacket().

void Client::sendNextChunk  )  [private]
 

Sends next chunk to socket (when uploading).

Definition at line 898 of file clients.cpp.

References Credits::addUploaded(), COL_COMP, COL_SEND, CreditsDb::create(), destroy(), EVT_CANCEL_UPLOADREQ, getComprVer(), getIpPort(), CreditsDb::instance(), isConnected(), m_credits, m_downloadInfo, m_hash, m_pubKey, m_queueInfo, m_socket, m_sourceInfo, m_uploadInfo, and TRACE_DEADSRC.

Referenced by onPacket(), onSocketEvent(), and startUpload().

void Client::establishConnection  )  [private]
 

Establish connection with the remote client either by directly connecting to it, or performing a low-id callback operation through server.

Definition at line 218 of file clients.cpp.

References CALLBACK_TIMEOUT, ServerList::connect(), CONNECT_TIMEOUT, destroy(), EVT_CALLBACK_T, ServerList::getCurServerAddr(), getIpPort(), ServerList::instance(), isLowId(), m_callbackInProgress, m_id, m_serverAddr, m_socket, m_tcpPort, onSocketEvent(), ServerList::reqCallback(), and TRACE_DEADSRC.

Referenced by ClientList::addClient(), addOffered(), ClientList::addSource(), reaskForDownload(), and startUpload().

void Client::reaskForDownload  )  [private]
 

Performs UDP reask for download.

Definition at line 1737 of file clients.cpp.

References establishConnection(), EVT_REASKTIMEOUT, Download::getHash(), getId(), getIpPort(), Download::getPartData(), Download::getSourceCount(), getUdpPort(), getUdpVer(), isConnected(), isHighId(), isLowId(), m_downloadInfo, m_lastReaskTime, m_reaskInProgress, m_sourceInfo, s_clientUdpSocket, SOURCE_REASKTIME, and UDP_TIMEOUT.

void Client::checkDestroy  )  [private]
 

Checks if this client is useful to us at all, and if not, emits EVT_DESTROY.

Definition at line 187 of file clients.cpp.

References destroy(), m_downloadInfo, m_queueInfo, m_sourceInfo, and m_uploadInfo.

Referenced by remOffered(), and removeFromQueue().

void Client::sendSignature  )  [private]
 

Send our signature to this client.

Precondition:
m_reqChallenge must be set to nonzero challenge value

m_pubKey must exist and be valid

Postcondition:
m_reqChallenge is set to 0

Definition at line 1660 of file clients.cpp.

References getId(), getIpPort(), getSecIdentVer(), IP_LOCAL, IP_REMOTE, isConnected(), isLowId(), m_pubKey, m_reqChallenge, m_socket, and TRACE_SECIDENT.

Referenced by onPacket().

void Client::sendPublicKey  )  [private]
 

Send our public key to this client.

Definition at line 1654 of file clients.cpp.

References isConnected(), and m_socket.

Referenced by onPacket().

void Client::initTransfer  )  [private]
 

Called after successful handshake (and optionally, SecIdent), starts actual data transfer.

Definition at line 1726 of file clients.cpp.

References isConnected(), m_downloadInfo, m_queueInfo, m_sourceInfo, m_uploadInfo, reqDownload(), and startUpload().

Referenced by handshakeCompleted(), and onPacket().

void Client::handshakeCompleted  )  [private]
 

Called by ClientList after received IDChange event from us, this indicates that merging (if any) with existing client has been completed, and we are ready to proceed, depending on context.

If supported, the identity of the client will be verified (SecIdent), and after that, depending on which extensions are present, operations performed, e.g. start uploading/downloading.

Definition at line 1712 of file clients.cpp.

References getSecIdentVer(), initTransfer(), m_sentChallenge, and verifyIdent().

Referenced by processMuleInfo().

void Client::verifyHashSet boost::shared_ptr< ED2KHashSet >  hs  )  [private]
 

Verify the contents of the passed hashset by re-calculating the file- hash from the chunkhashes.

Definition at line 1215 of file clients.cpp.

Referenced by onPacket().

ED2KUDPSocket *& Client::getUdpSocket  )  [static, private]
 

Returns reference to pointer to ClientUDPSocket; only allowed to be used by ClientList.

Definition at line 98 of file clients.cpp.

References s_clientUdpSocket.

Referenced by ClientList::exit(), and ClientList::init().


Friends And Related Function Documentation

friend class ClientList [friend]
 

Definition at line 295 of file clients.h.


Member Data Documentation

uint32_t Client::m_id [private]
 

Client ID ( <= 0x00fffff == LowID ).

Definition at line 442 of file clients.h.

Referenced by Client(), establishConnection(), getId(), isHighId(), and isLowId().

uint16_t Client::m_tcpPort [private]
 

TCP port.

Definition at line 443 of file clients.h.

Referenced by Client(), establishConnection(), getTcpPort(), and storeInfo().

uint16_t Client::m_udpPort [private]
 

UDP port.

Definition at line 444 of file clients.h.

Referenced by getUdpPort(), merge(), and storeInfo().

uint32_t Client::m_features [private]
 

Supported features.

Definition at line 445 of file clients.h.

Referenced by getAICHVer(), getCommentVer(), getComprVer(), getExtReqVer(), getSecIdentVer(), getSrcExchVer(), getUdpVer(), storeInfo(), supportsMultiPacket(), supportsPeerCache(), supportsPreview(), supportsUnicode(), and supportsViewShared().

Hash<MD4Hash> Client::m_hash [private]
 

Userhash.

Definition at line 446 of file clients.h.

Referenced by getHash(), isMule(), merge(), onPacket(), sendNextChunk(), and storeInfo().

PublicKey Client::m_pubKey [private]
 

Client's public key.

Definition at line 447 of file clients.h.

Referenced by merge(), onPacket(), sendNextChunk(), sendSignature(), and verifyIdent().

IPV4Address Client::m_serverAddr [private]
 

Server the client is connected to.

Definition at line 448 of file clients.h.

Referenced by establishConnection(), getServerAddr(), merge(), setServerAddr(), and storeInfo().

std::string Client::m_nick [private]
 

User nickname.

Definition at line 449 of file clients.h.

Referenced by getNick(), merge(), and storeInfo().

uint32_t Client::m_clientSoft [private]
 

Client soft and version.

Definition at line 450 of file clients.h.

Referenced by getClientSoft(), getSoftStr(), getVerBld(), getVerMin(), getVerMjr(), getVerPch(), merge(), processMuleInfo(), and storeInfo().

boost::shared_ptr<ED2KParser<Client> > Client::m_parser [private]
 

Stream parser.

Definition at line 457 of file clients.h.

Referenced by Client(), merge(), onSocketEvent(), sendQR(), and setOnQueue().

ED2KClientSocket* Client::m_socket [private]
 

Socket.

Definition at line 458 of file clients.h.

Referenced by addOffered(), destroy(), establishConnection(), getSocket(), isConnected(), merge(), onPacket(), onSocketEvent(), reqDownload(), sendNextChunk(), sendPublicKey(), sendQR(), sendSignature(), setOnQueue(), setSocket(), startUpload(), verifyIdent(), and ~Client().

Credits* Client::m_credits [private]
 

May be 0.

Definition at line 459 of file clients.h.

Referenced by getScore(), merge(), onPacket(), and sendNextChunk().

Detail::QueueInfoPtr Client::m_queueInfo [private]
 

If none of these exists, the client should be destroyed.

Definition at line 467 of file clients.h.

Referenced by checkDestroy(), destroy(), getQueueInfo(), getScore(), initTransfer(), merge(), onPacket(), onSocketEvent(), onUploadReq(), removeFromQueue(), sendNextChunk(), sendQR(), startUpload(), and ClientList::updateQueue().

Detail::UploadInfoPtr Client::m_uploadInfo [private]
 

Definition at line 468 of file clients.h.

Referenced by checkDestroy(), destroy(), getUploadInfo(), initTransfer(), merge(), onPacket(), onSocketEvent(), onUploadReq(), sendNextChunk(), sendQR(), setOnQueue(), and startUpload().

Detail::SourceInfoPtr Client::m_sourceInfo [private]
 

Definition at line 469 of file clients.h.

Referenced by addOffered(), checkDestroy(), destroy(), getSourceInfo(), initTransfer(), merge(), onPacket(), onSocketEvent(), reaskForDownload(), remOffered(), reqDownload(), sendNextChunk(), and setOnQueue().

Detail::DownloadInfoPtr Client::m_downloadInfo [private]
 

Definition at line 470 of file clients.h.

Referenced by addOffered(), checkDestroy(), destroy(), getDownloadInfo(), initTransfer(), merge(), onPacket(), onSocketEvent(), reaskForDownload(), remOffered(), sendNextChunk(), sendQR(), and setOnQueue().

bool Client::m_callbackInProgress [private]
 

TCP callback is in progress.

Definition at line 475 of file clients.h.

Referenced by callbackInProgress(), establishConnection(), and merge().

bool Client::m_reaskInProgress [private]
 

(UDP) reask is in progress

Definition at line 476 of file clients.h.

Referenced by onPacket(), reaskForDownload(), and reaskInProgress().

uint8_t Client::m_failedUdpReasks [private]
 

Number of failed UDP reasks (in row).

Definition at line 477 of file clients.h.

Referenced by onPacket(), and onSocketEvent().

uint64_t Client::m_lastReaskTime [private]
 

When was last source reask done.

Definition at line 478 of file clients.h.

Referenced by merge(), onPacket(), onSocketEvent(), reaskForDownload(), and reqDownload().

uint32_t Client::m_sentChallenge [private]
 

During identity verification, contains challenge sent TO the client.

Definition at line 483 of file clients.h.

Referenced by handshakeCompleted(), merge(), onPacket(), and verifyIdent().

uint32_t Client::m_reqChallenge [private]
 

During identity verification, contains challenge sent BY the client.

Definition at line 485 of file clients.h.

Referenced by merge(), onPacket(), and sendSignature().

bool Client::m_upReqInProgress [private]
 

State: Upload request is in progress.

Definition at line 487 of file clients.h.

Referenced by onPacket(), onSocketEvent(), sendQR(), and setOnQueue().

bool Client::m_dnReqInProgress [private]
 

State: Download request is in progress.

Definition at line 488 of file clients.h.

Referenced by onSocketEvent(), reqDownload(), sendQR(), and setOnQueue().


The documentation for this class was generated from the following files: