libktorrent  2.1.1
Public Types | Public Member Functions | Static Public Member Functions | List of all members
mse::EncryptedPacketSocket Class Reference

#include <encryptedpacketsocket.h>

Inheritance diagram for mse::EncryptedPacketSocket:
Inheritance graph
[legend]

Public Types

typedef QSharedPointer< EncryptedPacketSocketPtr
 

Public Member Functions

 EncryptedPacketSocket (int fd, int ip_version)
 
 EncryptedPacketSocket (int ip_version)
 
 EncryptedPacketSocket (net::SocketDevice *sock)
 
Uint32 bytesAvailable () const
 Get the number of bytes available to read.
 
void close ()
 Close the socket.
 
bool connecting () const
 Is this socket connecting to a remote host.
 
bool connectSuccesFull () const
 See if a connect was success full.
 
bool connectTo (const net::Address &addr)
 Connect the socket to a remote host.
 
bool connectTo (const QString &ip, Uint16 port)
 Connect the socket to a remote host.
 
void disableCrypt ()
 Disables encryption. All data will be sent over as plain text.
 
bool encrypted () const
 Are we using encryption.
 
net::Address getRemoteAddress () const
 Get the full address.
 
QString getRemoteIPAddress () const
 Get the IP address of the remote peer.
 
bt::Uint16 getRemotePort () const
 Get the port of the remote peer.
 
void initCrypt (const bt::SHA1Hash &dkey, const bt::SHA1Hash &ekey)
 
bool ok () const
 see if the socket is still OK
 
Uint32 readData (Uint8 *buf, Uint32 len)
 
void reinsert (const Uint8 *d, Uint32 size)
 
Uint32 sendData (const Uint8 *data, Uint32 len)
 
void setRC4Encryptor (RC4Encryptor *enc)
 Set the encryptor.
 
void setRemoteAddress (const net::Address &addr)
 
void startMonitoring (net::SocketReader *rdr)
 Start monitoring of this socket by the monitor thread.
 
void stopMonitoring ()
 Stop monitoring this socket.
 
- Public Member Functions inherited from net::PacketSocket
 PacketSocket (bool tcp, int ip_version)
 
 PacketSocket (int fd, int ip_version)
 
 PacketSocket (SocketDevice *sock)
 
void addPacket (bt::Packet::Ptr packet)
 
bool bytesReadyToWrite () const override
 See if the socket has something ready to write.
 
void clearPieces (bool reject)
 
Uint32 dataBytesUploaded ()
 Get the number of data bytes uploaded.
 
void doNotSendPiece (const bt::Request &req, bool reject)
 
Uint32 numPendingPieceUploads () const
 Get the number of pending piece uploads.
 
Uint32 write (Uint32 max, bt::TimeStamp now) override
 
- Public Member Functions inherited from net::TrafficShapedSocket
 TrafficShapedSocket (bool tcp, int ip_version)
 
 TrafficShapedSocket (int fd, int ip_version)
 
 TrafficShapedSocket (SocketDevice *sock)
 
Uint32 downloadGroupID () const
 Get the download group ID.
 
int getDownloadRate () const
 Get the current download rate.
 
int getUploadRate () const
 Get the current download rate.
 
virtual Uint32 read (Uint32 max_bytes_to_read, bt::TimeStamp now)
 
void setGroupID (Uint32 gid, bool upload)
 
void setReader (SocketReader *r)
 Set the reader.
 
SocketDevicesocketDevice ()
 Get the SocketDevice.
 
const SocketDevicesocketDevice () const
 Get the SocketDevice (const vesion)
 
void updateSpeeds (bt::TimeStamp now)
 Update up and down speed.
 
Uint32 uploadGroupID () const
 Get the upload group ID.
 

Static Public Member Functions

static void setTOS (Uint8 t)
 

Additional Inherited Members

- Protected Member Functions inherited from net::TrafficShapedSocket
virtual void postProcess (bt::Uint8 *data, bt::Uint32 size)
 
- Protected Attributes inherited from net::PacketSocket
std::deque< bt::Packet::Ptr > control_packets
 
Uint32 ctrl_packets_sent
 
bt::Packet::Ptr curr_packet
 
std::deque< bt::Packet::Ptr > data_packets
 
Uint32 uploaded_data_bytes
 
- Protected Attributes inherited from net::TrafficShapedSocket
Uint32 down_gid
 
Speeddown_speed
 
QMutex mutex
 
SocketReaderrdr
 
SocketDevicesock
 
Uint32 up_gid
 
Speedup_speed
 

Detailed Description

Author
Joris Guisson joris.nosp@m..gui.nosp@m.sson@.nosp@m.gmai.nosp@m.l.com

Wrapper around a TCP socket which handles RC4 encryption.

Definition at line 50 of file encryptedpacketsocket.h.

Member Function Documentation

◆ initCrypt()

void mse::EncryptedPacketSocket::initCrypt ( const bt::SHA1Hash dkey,
const bt::SHA1Hash ekey 
)

Initialize the RC4 encryption algorithm.

Parameters
dkey
ekey

◆ readData()

Uint32 mse::EncryptedPacketSocket::readData ( Uint8 *  buf,
Uint32  len 
)

Reads data from the peer.

Parameters
bufThe buffer to store the data
lenThe maximum number of bytes to read
Returns
The number of bytes read

◆ reinsert()

void mse::EncryptedPacketSocket::reinsert ( const Uint8 *  d,
Uint32  size 
)

Reinsert data, this is needed when we read to much during the crypto handshake. This data will be the first to read out. The data will be copied to a temporary buffer which will be destroyed when the reinserted data has been read.

◆ sendData()

Uint32 mse::EncryptedPacketSocket::sendData ( const Uint8 *  data,
Uint32  len 
)

Send a chunk of data. (Does not encrypt the data)

Parameters
dataThe data
lenThe length
Returns
Number of bytes written

◆ setRemoteAddress()

void mse::EncryptedPacketSocket::setRemoteAddress ( const net::Address addr)

Set the remote address of the socket. Used by Socks to set the actual address of the connection.

Parameters
addrThe address

◆ setTOS()

static void mse::EncryptedPacketSocket::setTOS ( Uint8  t)
inlinestatic

Set the TOS byte for new sockets.

Parameters
tTOS value

Definition at line 137 of file encryptedpacketsocket.h.


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