A single, possibly encrypted, connection to a peer.
The BitTorrent handshake is in the order: header, options, download id
(info hash), peer id, [length, message], ....
|
|
__init__(self,
Encoder,
connection,
dns,
id,
ext_handshake=True,
encrypted=None,
options=None)
Initialize the instance and start handling the connection. |
source code
|
|
|
|
|
|
|
|
string
|
|
string
|
|
string
|
|
boolean
|
|
boolean
|
|
boolean
|
|
int, method
|
|
|
|
_start_crypto(self)
Setup the connection for encrypted communication. |
source code
|
|
|
|
_end_crypto(self)
Return the connection back to unencrypted communication. |
source code
|
|
int, method
|
|
boolean
|
|
int, method
|
|
int, method
|
|
boolean
|
|
boolean
|
|
int, method
|
|
int, method
|
|
int, method
|
|
int, method
|
|
int, method
|
|
int, method
|
|
int, method
|
|
int, method
|
|
int, method
|
|
int, method
|
|
int, method
|
|
int, method
|
|
int, method
|
|
|
None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_switch_to_read2(self)
Switch from _read to the more efficient _read2 method. |
source code
|
|
|
|
|
|
|
_auto_close(self)
Close the connection if the handshake is not yet complete. |
source code
|
|
|
|
|
|
|
sever(self)
Clean up the connection for closing. |
source code
|
|
|
|
|
|
|
|
|
Encoder
|
Encoder
the collection of all connections
|
method
|
_logwritefunc
the saved write method for intercepting connection writes for
logging purposes
|
int
|
_max_search
the number of remaining bytes to search for the pattern
|
string
|
buffer
the buffer of received data from the connection
|
int
|
bufferlen
the length of the buffer
|
boolean
|
closed
whether the connection has been closed
|
boolean
|
complete
whether the handshake is complete
|
|
Connecter.Connecter
|
connecter
the Connecter instance to use
|
|
DebTorrent.SocketHandler.SingleSocket
|
connection
the low-level connection to the peer
|
int
|
cryptmode
the type of encryption being used
|
(string, int)
|
dns
the IP address and port to connect to
|
boolean
|
encrypted
whether the connection is encrypted (will be None if that is not
yet known)
|
|
DebTorrent.BTcrypto.Crypto
|
encrypter
the already created Crypto instance, if the connection was
externally handshaked (optional, defaults to creating a new one)
|
string
|
id
the peer ID of the peer
|
method
|
keepalive
the method to call to send a keepalive message on the
connection
|
boolean
|
locally_initiated
whether the connectio was initiated locally
|
file
|
log
the log file to write to
|
method
|
next_func
the next method to use to process incoming data on the
connection
|
int
|
next_len
the next amount of data to read from the connection
|
string
|
options
the options read from the externally handshaked connection
(optional, defaults to None)
|
method
|
read
the method to use to read from the connection
|
string
|
readable_id
the human-readable ID of the peer
|
method
|
write
the method to use to write to the connection
|