Class PEPeerTransportProtocol
java.lang.Object
com.biglybt.core.logging.LogRelation
com.biglybt.core.peer.impl.transport.PEPeerTransportProtocol
- All Implemented Interfaces:
PEPeerTransport, PEPeer, Taggable, Taggable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate static final intprivate static final intprivate booleanprivate InetAddressprivate booleanprivate booleanprivate booleanprotected booleanprivate Stringprivate Stringprivate Stringprivate Stringprotected booleanprivate final AEMonitorprivate final NetworkConnectionprivate longprivate intprivate intprivate byteprivate intprivate Mapprivate static final booleanprotected final DiskManagerprivate booleanprivate longprotected static booleanprivate static booleanprivate booleanprivate static booleanprivate final AEMonitorprivate byte[]private booleanprivate booleanprivate booleanprivate InetAddressprivate longprivate booleanprivate booleanprivate final booleanprivate booleanprivate Stringprivate static final IpFilterprotected Stringprivate IPToHostNameResolverRequestprivate booleanprivate final booleanprivate booleanprivate booleanprivate booleanprivate static final Objectprivate static final Objectprivate longprivate longprivate longprivate longprivate longprivate longprotected static final LogIDsprotected final PEPeerControlprivate booleanprivate int[]protected PeerMessageLimiterprivate intprivate booleanprivate HashWrapperprotected final intprivate final Stringprivate byteprivate byteprivate byteprivate byteprivate byteprivate byteprivate byteprivate byteprivate byteprivate final byteprivate byteprivate byteprivate byteprivate byteprivate byteprivate byteprivate byteprivate byteprivate booleanprivate byteprivate byteprivate byteprivate byteprivate byteprivate byteprivate byteprivate byteprivate byteprivate intprivate longprivate OutgoingBTHaveMessageAggregatorprivate OutgoingBTPieceMessageHandlerprivate PeerExchangerItemprivate booleanprivate byte[]private PeerItemprivate Listprivate final AEMonitorprivate final Stringprotected PEPeerStatsprivate BitFlagslazy allocation; null until neededprivate HashWrapperprivate int[]protected final PiecePickerprivate Connectionprivate final intprivate static booleanprivate booleanprivate booleanprivate booleanprivate LinkedHashMapprivate AEMonitorprivate static final PEPeerTransportProtocol.DisconnectedTransportQueueprivate static final byteprivate static final byteprivate static final byteprivate byteprivate int[]private static final intprivate booleanprivate longprivate final ArrayList<DiskManagerReadRequest> private static intprivate static intprivate static intprivate static intprivate int[]private static final Randomprivate booleanprivate static final byte[]private static final booleanprivate longprivate intprivate booleanprivate booleanprivate Message[]private AtomicLongprivate intprivate intprivate intprivate intprivate intprivate booleanprivate booleanFields inherited from interface PEPeer
CLOSING, CONNECTING, DISCONNECTED, HANDSHAKING, MESSAGING_AZMP, MESSAGING_BT_ONLY, MESSAGING_EXTERN, MESSAGING_LTEP, StateNames, TRANSFERINGFields inherited from interface PEPeerTransport
CONNECTION_CONNECTING, CONNECTION_FULLY_ESTABLISHED, CONNECTION_PENDING, CONNECTION_WAITING_FOR_HANDSHAKE, CP_CONNECT_FAILED, CP_CONNECT_OK, CP_CONNECTING, CP_RECEIVED_DATA, CP_UNKNOWNFields inherited from interface Taggable
TT_DOWNLOAD, TT_NONE, TT_PEER -
Constructor Summary
ConstructorsConstructorDescriptionPEPeerTransportProtocol(PEPeerControl _manager, String _peer_source, NetworkConnection _connection, Map _initial_user_data) PEPeerTransportProtocol(PEPeerControl _manager, String _peer_source, String _ip, int _tcp_port, int _udp_port, boolean _use_tcp, boolean _require_crypto_handshake, byte _crypto_level, Map _initial_user_data) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidvoidaddListener(PEPeerListener listener) Add peer listener.voidaddRateLimiter(LimitedRateGroup limiter, boolean upload) voidaddReservedPieceNumber(int piece_number) adds the reserved piece for piece picking by this peerprotected voidprivate booleanprivate voidbooleanprivate voidchangePeerState(int new_state) private voidprotected voidprivate voidcheckForReconnect(HashWrapper oldID) voidGlobal checkInterested method.private voidChecks if this peer is a seed or not by trivially checking if their Have bitflags exists and shows a number of bits set equal to the torrent # of pieces (and the torrent # of pieces is >0)voidvoidcloseConnection(String reason, int reason_code) Close the peer connection from the PEPeerControl manager side.protected voidcloseConnectionInternally(String reason, int reason_code) protected voidcloseConnectionInternally(String reason, int reason_code, boolean connect_failed, boolean network_failure) Close the peer connection from within the PEPeerTransport object.private voidprivate intdecideExtensionProtocol(BTHandshake handshake) private voiddecodeAllowedFast(BTAllowedFast allowed) protected voiddecodeAZBadPiece(AZBadPiece bad_piece) protected voiddecodeAZHandshake(AZHandshake handshake) protected voiddecodeAZHave(AZHave have) protected voidprotected voiddecodeAZStatsReply(AZStatReply reply) protected voiddecodeAZStatsRequest(AZStatRequest request) protected voiddecodeBitfield(BTBitfield bitfield) protected voiddecodeBTHandshake(BTHandshake handshake) protected voiddecodeCancel(BTCancel cancel) protected voiddecodeChoke(BTChoke choke) private voiddecodeHashes(BTHashes hashes) private voiddecodeHashReject(BTHashReject reject) private voiddecodeHashRequest(BTHashRequest request) protected voiddecodeHave(BTHave have) protected voiddecodeHaveAll(BTHaveAll have_all) protected voiddecodeHaveNone(BTHaveNone have_none) protected voiddecodeHolePunch(UTHolePunch message) protected voiddecodeInterested(BTInterested interested) protected voiddecodeLTHandshake(LTHandshake handshake) protected voidprotected voiddecodeMetaData(AZUTMetaData metadata) protected voiddecodePeerExchange(AZStylePeerExchange exchange) protected voiddecodePiece(BTPiece piece) protected voiddecodeRejectRequest(BTRejectRequest reject) protected voiddecodeRequest(BTRequest request) protected voidprotected voiddecodeUnchoke(BTUnchoke unchoke) protected voiddecodeUninterested(BTUninterested uninterested) protected voiddecodeUploadOnly(UTUploadOnly message) private voidvoidCheck if we need to send a keep-alive message.voidPerform checks related to performance optimizations, i.e.private voidthis method might be called repeatedly since LTEP allows headers to be sent more than once make sure that multiple invokations do not have unintended consequencesbooleanCheck for possible connection timeouts.voidgenerateEvidence(IndentWriter writer) generateFastSet(byte[] hash, String ip, int num_pieces, int num_required) generateFastSet(int num) private voidprotected longlonglongGet the time this connection was first established.intGet the specific peer connection state.intint[]int[]To retreive arbitrary objects against a peer.private static MainlineDHTProviderintReturns name of encryption used by the peerbyte[]byte[]getId()intintint[]get a list of piece numbers the peer has requestedgetIp()Gets the host name for the IP, if possible, IP as string otherwiselongintlongintpeer-specific request max.intintintintint[]get a list of piece numbers the we have requested from peerGet the peer's address + port identification item.intintGet the peer's torrent completion percentage in thousand-notation, i.e.Get the connection that backs this peer.intgetPort()Get the peer's local TCP connection port.int[]Any priority offsets this peer has, or null if noneObject[]Query this class for a reference to another class that it may holdgetRateLimiters(boolean upload) A short description of what your class holds that can be printed by the loggerint[]Get current request hint for a given piece for this peer.intgetRequestIndex(DiskManagerReadRequest request) Returns the index of this request in the peer's queue or -1 if not foundint[]Get the reserved pieces for piece picking by this peerlonggetStats()Message[]Get the list of messages that this peer and us both understand.intlongintGet the TCP port this peer is listening for incoming connections on.longGet the time since the most-recent data that was actually written to disk was received.longGet the time since the last (most-recent) data (payload) message was received.longGet the time since the last (most-recent) data (payload) message was sent.intGet the UDP port this peer is listening for incoming connections on.intGet the UDP port this peer is listening on for non-data connectionslongintintintgetUserData(Object key) To retreive arbitrary objects against a peer.private booleanhasBeenRequested(DiskManagerReadRequest request) booleanprotected voidprivate voidinitPostConnection(Message handshake) booleanAm I choking the peer.booleanIs the peer choking me.booleanisClosed()booleanbooleanisDownloadDisabled(Object key) booleanchecks several factors within the object so the caller wouldn't need to for convenience and speed.private booleanbooleanbooleanIs the peer Interested in me.booleanAm I Interested in the peer.booleanIs the connection within the local LAN network.booleanisMyPeer()Whether or not this is a 'dummy' peer that represents our presence in a swarmbooleanbooleanisPieceAvailable(int pieceNumber) booleanbooleanbooleanbooleanThis method is called to check if it is safe to reconnect to a peer, i.e.booleanisSeed()booleanbooleanis peer waiting for a disk read with no network writes queuedbooleanisTCP()booleanbooleanbooleanisUploadDisabled(Object key) private DiskManagerReadRequestlookupRequest(int piece_number, int piece_offset, int length) private booleanpeerSupportsMessageType(String message_id) private voidperformClose(String reason, int close_reason_out, boolean connect_failed, boolean externally_closed, boolean network_failure) private voidAttempts to reconnect to the same peerprivate voidprivate voidvoidremoveListener(PEPeerListener listener) Remove peer listener.voidremoveRateLimiter(LimitedRateGroup limiter, boolean upload) protected voidremoveRequest(DiskManagerReadRequest request) voidremoveReservedPieceNumber(int piece_number) request(int pieceNumber, int pieceOffset, int pieceLength, boolean return_duplicates) voidbooleanrequestAllocationStarts(int[] base_priorities) Two methods that allow a peer to aggregate the individual requests generated during an allocation cycle if so desiredvoidprivate voidresetRequestsTimeMono(long mono_now) private voidsendAllowFast(int number) private voidvoidsendBadPiece(int piece_number) private voidPrivate method to send the bitfield.protected voidvoidsendCancel(DiskManagerReadRequest request) voidvoidvoidsendHave(int pieceNumber) private voidvoidsendHolePunch(InetAddress address, int port) private voidprotected voidsendLazyHaves(int[] lazy_haves, boolean immediate) private voidprivate voidprivate voidsendRejectRequest(int number, int offset, int length) voidsendRejectRequest(DiskManagerReadRequest request) booleansendRequestHint(int piece_number, int offset, int length, int life) Send a request hint to the peer.voidsendStatsReply(Map reply) voidsendStatsRequest(Map request) voidvoidsetConsecutiveNoRequestCount(int num) voidTo store arbitrary objects against a peer.voidsetDownloadDisabled(Object key, boolean disabled) voidsetDownloadRateLimitBytesPerSecond(int bytes) voidsetHaveAggregationEnabled(boolean enabled) voidsetLastPiece(int pieceNumber) voidsetOptimisticUnchoke(boolean is_optimistic) voidsetPriorityConnection(boolean is_priority) private voidsetSeed(boolean s) voidsetSnubbed(boolean b) voidsetSuspendedLazyBitFieldEnabled(boolean enable) Enable suspended lazy bitfield for this peer - we will appear incomplete until this is disabled, at which point (well, fairly soon after) the bitfield will be completedvoidsetTaggableTransientProperty(String key, Object value) voidsetUniqueAnnounce(int _uniquePiece) voidsetUploadDisabled(Object key, boolean disabled) voidsetUploadHint(int spreadTime) voidsetUploadRateLimitBytesPerSecond(int bytes) voidsetUserData(Object key, Object value) To store arbitrary objects against a peer.private voidspoofMDAvailability(int mds) voidstart()Start message processing for the peerbooleanWhether or not this peer supports the advanced messaging API.toString()booleanvoidupdateAutoUploadPriority(Object key, boolean inc) voidDo any peer exchange processing/updating.voidMethods inherited from class LogRelation
propogatedRelationText, queryForClassMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface PEPeer
getPercentDoneOfCurrentIncomingRequest, getPercentDoneOfCurrentOutgoingRequest
-
Field Details
-
LOGID
-
ip_filter
-
_lastPiece
private volatile int _lastPiece -
manager
-
diskManager
-
piecePicker
-
nbPieces
protected final int nbPieces -
peer_source
-
peer_id
private byte[] peer_id -
ip
-
network
-
ip_resolved
-
ip_resolver_request
-
port
private final int port -
peer_item_identity
-
tcp_listen_port
private int tcp_listen_port -
udp_listen_port
private int udp_listen_port -
udp_non_data_port
private int udp_non_data_port -
alternativeAddress
-
crypto_level
private byte crypto_level -
peer_stats
-
requested
-
data
-
lastNeededUndonePieceChange
private long lastNeededUndonePieceChange -
really_choked_by_other_peer
private boolean really_choked_by_other_peer -
effectively_choked_by_other_peer
private boolean effectively_choked_by_other_peer -
effectively_unchoked_time
private long effectively_unchoked_time -
choking_other_peer
protected boolean choking_other_peer -
interested_in_other_peer
private boolean interested_in_other_peer -
other_peer_interested_in_me
private boolean other_peer_interested_in_me -
peerHavePieces
lazy allocation; null until needed -
availabilityAdded
private volatile boolean availabilityAdded -
received_bitfield
private volatile boolean received_bitfield -
piece_priority_offsets
private int[] piece_priority_offsets -
handshake_sent
private boolean handshake_sent -
seeding
private boolean seeding -
RELATIVE_SEEDING_NONE
private static final byte RELATIVE_SEEDING_NONE- See Also:
-
RELATIVE_SEEDING_UPLOAD_ONLY_INDICATED
private static final byte RELATIVE_SEEDING_UPLOAD_ONLY_INDICATED- See Also:
-
RELATIVE_SEEDING_UPLOAD_ONLY_SEED
private static final byte RELATIVE_SEEDING_UPLOAD_ONLY_SEED- See Also:
-
relativeSeeding
private byte relativeSeeding -
incoming_raw
private final boolean incoming_raw -
incoming_effective
private boolean incoming_effective -
closing
protected volatile boolean closing -
current_peer_state
private volatile int current_peer_state -
connection
-
outgoing_piece_message_handler
-
outgoing_have_message_aggregator
-
plugin_connection
-
identityAdded
private boolean identityAdded -
connection_state
private int connection_state -
outbound_connection_start
private long outbound_connection_start -
outbound_connection_progress
private int outbound_connection_progress -
client
-
client_peer_id
-
client_handshake
-
client_handshake_version
-
uniquePiece
private int uniquePiece -
reserved_pieces
private int[] reserved_pieces -
spreadTimeHint
private int spreadTimeHint -
snubbed_time_mono
private long snubbed_time_mono -
last_message_sent_time_mono
private long last_message_sent_time_mono -
last_message_received_time_mono
private long last_message_received_time_mono -
last_data_message_received_time_mono
private long last_data_message_received_time_mono -
last_good_data_time_mono
private long last_good_data_time_mono -
last_data_message_sent_time_mono
private long last_data_message_sent_time_mono -
connection_established_time_mono
private long connection_established_time_mono -
consecutive_no_request_count
private int consecutive_no_request_count -
messaging_mode
private int messaging_mode -
supported_messages
-
other_peer_bitfield_version
private byte other_peer_bitfield_version -
other_peer_cancel_version
private byte other_peer_cancel_version -
other_peer_choke_version
private byte other_peer_choke_version -
other_peer_handshake_version
private byte other_peer_handshake_version -
other_peer_bt_have_version
private byte other_peer_bt_have_version -
other_peer_az_have_version
private byte other_peer_az_have_version -
other_peer_interested_version
private byte other_peer_interested_version -
other_peer_keep_alive_version
private byte other_peer_keep_alive_version -
other_peer_pex_version
private byte other_peer_pex_version -
other_peer_piece_version
private byte other_peer_piece_version -
other_peer_unchoke_version
private byte other_peer_unchoke_version -
other_peer_uninterested_version
private byte other_peer_uninterested_version -
other_peer_request_version
private byte other_peer_request_version -
other_peer_suggest_piece_version
private byte other_peer_suggest_piece_version -
other_peer_have_all_version
private byte other_peer_have_all_version -
other_peer_have_none_version
private byte other_peer_have_none_version -
other_peer_reject_request_version
private byte other_peer_reject_request_version -
other_peer_allowed_fast_version
private byte other_peer_allowed_fast_version -
other_peer_bt_lt_ext_version
private final byte other_peer_bt_lt_ext_version- See Also:
-
other_peer_hash_request_version
private byte other_peer_hash_request_version -
other_peer_hashes_version
private byte other_peer_hashes_version -
other_peer_hash_reject_version
private byte other_peer_hash_reject_version -
other_peer_az_request_hint_version
private byte other_peer_az_request_hint_version -
other_peer_az_bad_piece_version
private byte other_peer_az_bad_piece_version -
other_peer_az_stats_request_version
private byte other_peer_az_stats_request_version -
other_peer_az_stats_reply_version
private byte other_peer_az_stats_reply_version -
other_peer_az_metadata_version
private byte other_peer_az_metadata_version -
DEBUG_FAST
private static final boolean DEBUG_FAST- See Also:
-
ut_pex_enabled
private boolean ut_pex_enabled -
ut_holepunch_enabled
private boolean ut_holepunch_enabled -
fast_extension_enabled
private boolean fast_extension_enabled -
ml_dht_enabled
private boolean ml_dht_enabled -
ALLOWED_FAST_PIECE_OFFERED_NUM
private static final int ALLOWED_FAST_PIECE_OFFERED_NUM- See Also:
-
ALLOWED_FAST_OTHER_PEER_PIECE_MAX
private static final int ALLOWED_FAST_OTHER_PEER_PIECE_MAX- See Also:
-
KEY_ALLOWED_FAST_RECEIVED
-
KEY_ALLOWED_FAST_SENT
-
closing_mon
-
general_mon
-
handshake_reserved_bytes
private byte[] handshake_reserved_bytes -
recent_outgoing_requests
-
recent_outgoing_requests_mon
-
has_received_initial_pex
private boolean has_received_initial_pex -
SHOW_DISCARD_RATE_STATS
private static final boolean SHOW_DISCARD_RATE_STATS -
requests_discarded
private static int requests_discarded -
requests_discarded_endgame
private static int requests_discarded_endgame -
requests_recovered
private static int requests_recovered -
requests_completed
private static int requests_completed -
REQUEST_HINT_MAX_LIFE
private static final int REQUEST_HINT_MAX_LIFE- See Also:
-
request_hint
private int[] request_hint -
peer_listeners_cow
-
peer_listeners_mon
-
ENABLE_LAZY_BITFIELD
protected static boolean ENABLE_LAZY_BITFIELD -
priority_connection
private boolean priority_connection -
upload_priority_auto
private int upload_priority_auto -
tagMutationCounter
-
recentlyDisconnected
-
fast_unchoke_new_peers
private static boolean fast_unchoke_new_peers -
rnd
-
sessionSecret
private static final byte[] sessionSecret -
enable_upload_bias
private static boolean enable_upload_bias -
prefer_ipv6
private static boolean prefer_ipv6 -
peerSessionID
-
mySessionID
-
allowReconnect
private boolean allowReconnect -
isReconnect
private boolean isReconnect -
upload_disabled_set
-
download_disabled_set
-
is_upload_disabled
private boolean is_upload_disabled -
is_download_disabled
private boolean is_download_disabled -
is_optimistic_unchoke
private boolean is_optimistic_unchoke -
peer_exchange_item
-
peer_exchange_supported
private boolean peer_exchange_supported -
message_limiter
-
request_hint_supported
private boolean request_hint_supported -
bad_piece_supported
private boolean bad_piece_supported -
stats_request_supported
private boolean stats_request_supported -
stats_reply_supported
private boolean stats_reply_supported -
az_metadata_supported
private boolean az_metadata_supported -
have_aggregation_disabled
private boolean have_aggregation_disabled -
manual_lazy_bitfield_control
private volatile boolean manual_lazy_bitfield_control -
manual_lazy_haves
private volatile int[] manual_lazy_haves -
is_metadata_download
private final boolean is_metadata_download -
request_latency
private long request_latency -
hp_last_send
private volatile long hp_last_send -
hp_last_address
-
-
Constructor Details
-
PEPeerTransportProtocol
public PEPeerTransportProtocol(PEPeerControl _manager, String _peer_source, NetworkConnection _connection, Map _initial_user_data) -
PEPeerTransportProtocol
public PEPeerTransportProtocol(PEPeerControl _manager, String _peer_source, String _ip, int _tcp_port, int _udp_port, boolean _use_tcp, boolean _require_crypto_handshake, byte _crypto_level, Map _initial_user_data)
-
-
Method Details
-
start
public void start()Description copied from interface:PEPeerTransportStart message processing for the peer- Specified by:
startin interfacePEPeerTransport
-
initializeConnection
protected void initializeConnection() -
isMyPeer
-
getPeerSource
- Specified by:
getPeerSourcein interfacePEPeer
-
getOutboundConnectionProgress
public int getOutboundConnectionProgress()- Specified by:
getOutboundConnectionProgressin interfacePEPeerTransport
-
closeConnectionInternally
protected void closeConnectionInternally(String reason, int reason_code, boolean connect_failed, boolean network_failure) Close the peer connection from within the PEPeerTransport object.- Parameters:
reason-
-
closeConnectionInternally
-
closeConnection
Close the peer connection from the PEPeerControl manager side. NOTE: This method assumes PEPeerControl already knows about the close. This method is intended to be only invoked by select administrative methods. You probably should not invoke this directly.- Specified by:
closeConnectionin interfacePEPeerTransport- Parameters:
reason- for closure
-
performClose
private void performClose(String reason, int close_reason_out, boolean connect_failed, boolean externally_closed, boolean network_failure) -
isClosed
-
reconnect
Description copied from interface:PEPeerTransportAttempts to reconnect to the same peer- Specified by:
reconnectin interfacePEPeerTransport- Parameters:
tryUDP- try to initiate a UDP connection if true, just reestablish the previous state otherwisetryIPv6- TODO- Returns:
- null if reconnect not possible, reconnected peer otherwise
-
isSafeForReconnect
public boolean isSafeForReconnect()Description copied from interface:PEPeerTransportThis method is called to check if it is safe to reconnect to a peer, i.e. avoid hammering exchanging data with a peer should work as it takes time to setup the connection and negotiate things before that happens- Specified by:
isSafeForReconnectin interfacePEPeerTransport- Returns:
- true if we exchanged payload data with the peer during the current connection
-
isReconnect
public boolean isReconnect()- Specified by:
isReconnectin interfacePEPeerTransport
-
checkForReconnect
-
generateSessionId
private void generateSessionId() -
addAvailability
private void addAvailability() -
removeAvailability
private void removeAvailability() -
sendBTHandshake
protected void sendBTHandshake() -
sendLTHandshake
private void sendLTHandshake() -
sendAZHandshake
private void sendAZHandshake() -
getPeerState
public int getPeerState()- Specified by:
getPeerStatein interfacePEPeer
-
isDownloadPossible
public boolean isDownloadPossible()Description copied from interface:PEPeerchecks several factors within the object so the caller wouldn't need to for convenience and speed.- Specified by:
isDownloadPossiblein interfacePEPeer- Returns:
- true if none of several criteria indicate a request can't be made of the peer
-
getPercentDoneInThousandNotation
public int getPercentDoneInThousandNotation()Description copied from interface:PEPeerGet the peer's torrent completion percentage in thousand-notation, i.e. 53.7% is returned as the value 0537.- Specified by:
getPercentDoneInThousandNotationin interfacePEPeer- Returns:
- the percentage the peer has complete
-
transferAvailable
public boolean transferAvailable()- Specified by:
transferAvailablein interfacePEPeer- Specified by:
transferAvailablein interfacePEPeerTransport
-
printRequestStats
private void printRequestStats() -
checkSeed
private void checkSeed()Checks if this peer is a seed or not by trivially checking if their Have bitflags exists and shows a number of bits set equal to the torrent # of pieces (and the torrent # of pieces is >0) -
request
public DiskManagerReadRequest request(int pieceNumber, int pieceOffset, int pieceLength, boolean return_duplicates) - Specified by:
requestin interfacePEPeerTransport- Parameters:
pieceNumber-pieceOffset-pieceLength-return_duplicates- - if true and request already exists it will be returned, if false -> null- Returns:
- request if actually requested, null otherwise
-
getRequestIndex
Description copied from interface:PEPeerTransportReturns the index of this request in the peer's queue or -1 if not found- Specified by:
getRequestIndexin interfacePEPeerTransport- Returns:
-
sendCancel
- Specified by:
sendCancelin interfacePEPeerTransport
-
sendHaveNone
private void sendHaveNone() -
sendHave
public void sendHave(int pieceNumber) - Specified by:
sendHavein interfacePEPeerTransport
-
sendChoke
public void sendChoke()- Specified by:
sendChokein interfacePEPeer- Specified by:
sendChokein interfacePEPeerTransport
-
sendUnChoke
public void sendUnChoke()- Specified by:
sendUnChokein interfacePEPeer- Specified by:
sendUnChokein interfacePEPeerTransport
-
createPieceMessageHandler
private void createPieceMessageHandler() -
destroyPieceMessageHandler
private void destroyPieceMessageHandler() -
sendKeepAlive
private void sendKeepAlive() -
sendMainlineDHTPort
private void sendMainlineDHTPort() -
checkInterested
public void checkInterested()Global checkInterested method. Early-out scan of pieces to determine if the peer is interesting or not. They're interesting if they have a piece that we Need and isn't Done- Specified by:
checkInterestedin interfacePEPeerTransport
-
sendBitField
private void sendBitField()Private method to send the bitfield. -
sendLazyHaves
protected void sendLazyHaves(int[] lazy_haves, boolean immediate) -
getId
-
getIp
-
getAlternativeIPv6
- Specified by:
getAlternativeIPv6in interfacePEPeer- Returns:
- an ipv6 address under which the peer should be connectable if it announced one, null otherwise
-
getPort
-
getTCPListenPort
public int getTCPListenPort()Description copied from interface:PEPeerGet the TCP port this peer is listening for incoming connections on.- Specified by:
getTCPListenPortin interfacePEPeer- Returns:
- TCP port, or 0 if port is unknown
-
getUDPListenPort
public int getUDPListenPort()Description copied from interface:PEPeerGet the UDP port this peer is listening for incoming connections on.- Specified by:
getUDPListenPortin interfacePEPeer- Returns:
- UDP port, or 0 if port is unknown
-
getUDPNonDataListenPort
public int getUDPNonDataListenPort()Description copied from interface:PEPeerGet the UDP port this peer is listening on for non-data connections- Specified by:
getUDPNonDataListenPortin interfacePEPeer- Returns:
-
getClient
-
isIncoming
public boolean isIncoming()- Specified by:
isIncomingin interfacePEPeer
-
isOptimisticUnchoke
public boolean isOptimisticUnchoke()- Specified by:
isOptimisticUnchokein interfacePEPeer
-
setOptimisticUnchoke
public void setOptimisticUnchoke(boolean is_optimistic) - Specified by:
setOptimisticUnchokein interfacePEPeer
-
getControl
- Specified by:
getControlin interfacePEPeerTransport
-
getManager
- Specified by:
getManagerin interfacePEPeer
-
getStats
-
getPriorityOffsets
public int[] getPriorityOffsets()Description copied from interface:PEPeerTransportAny priority offsets this peer has, or null if none- Specified by:
getPriorityOffsetsin interfacePEPeerTransport- Returns:
-
requestAllocationStarts
public boolean requestAllocationStarts(int[] base_priorities) Description copied from interface:PEPeerTransportTwo methods that allow a peer to aggregate the individual requests generated during an allocation cycle if so desired- Specified by:
requestAllocationStartsin interfacePEPeerTransport- Returns:
- true if the peer is managing request priorities and doesn't want end-game random allocation behaviour
-
requestAllocationComplete
public void requestAllocationComplete()- Specified by:
requestAllocationCompletein interfacePEPeerTransport
-
getAvailable
- Specified by:
getAvailablein interfacePEPeer- Returns:
- null if no bitfield has been received yet else returns BitFlags indicating what pieces the peer has
-
isPieceAvailable
public boolean isPieceAvailable(int pieceNumber) - Specified by:
isPieceAvailablein interfacePEPeer- Parameters:
pieceNumber- int- Returns:
- true if this peers makes this piece available
-
isChokingMe
public boolean isChokingMe()Description copied from interface:PEPeerIs the peer choking me.- Specified by:
isChokingMein interfacePEPeer- Returns:
- true if I am choked by the peer, false if not
-
isUnchokeOverride
public boolean isUnchokeOverride()- Specified by:
isUnchokeOverridein interfacePEPeer
-
isChokedByMe
public boolean isChokedByMe()Description copied from interface:PEPeerAm I choking the peer.- Specified by:
isChokedByMein interfacePEPeer- Returns:
- true if the peer is choked, false if not
-
isInteresting
public boolean isInteresting()Description copied from interface:PEPeerAm I Interested in the peer.- Specified by:
isInterestingin interfacePEPeer- Returns:
- true if the peer is interesting to us
-
isInterested
public boolean isInterested()Description copied from interface:PEPeerIs the peer Interested in me.- Specified by:
isInterestedin interfacePEPeer- Returns:
- true if the peer is interested in what we're offering
-
isSeed
-
isRelativeSeed
public boolean isRelativeSeed()- Specified by:
isRelativeSeedin interfacePEPeer- Returns:
- true if the peer is only uploading and can't use the data we have to offer (we're seeding) or we can't use the data he has to offer (we're downloading)
-
setSeed
private void setSeed(boolean s) -
isSnubbed
-
getSnubbedTime
public long getSnubbedTime()- Specified by:
getSnubbedTimein interfacePEPeer
-
setSnubbed
public void setSnubbed(boolean b) - Specified by:
setSnubbedin interfacePEPeer
-
setUploadHint
public void setUploadHint(int spreadTime) - Specified by:
setUploadHintin interfacePEPeer
-
getUploadHint
public int getUploadHint()- Specified by:
getUploadHintin interfacePEPeer
-
setUniqueAnnounce
public void setUniqueAnnounce(int _uniquePiece) - Specified by:
setUniqueAnnouncein interfacePEPeer
-
getUniqueAnnounce
public int getUniqueAnnounce()- Specified by:
getUniqueAnnouncein interfacePEPeer
-
getData
-
setData
-
getUserData
To retreive arbitrary objects against a peer.- Specified by:
getUserDatain interfacePEPeer
-
setUserData
To store arbitrary objects against a peer.- Specified by:
setUserDatain interfacePEPeer
-
getIPHostName
Description copied from interface:PEPeerGets the host name for the IP, if possible, IP as string otherwise- Specified by:
getIPHostNamein interfacePEPeer- Returns:
- hostname or IP
-
cancelRequests
private void cancelRequests() -
getMaxNbRequests
public int getMaxNbRequests()Description copied from interface:PEPeerTransportpeer-specific request max. return -1 to use the default piece-picker allocation method- Specified by:
getMaxNbRequestsin interfacePEPeerTransport- Returns:
-
getNbRequests
public int getNbRequests()- Specified by:
getNbRequestsin interfacePEPeerTransport
-
getExpiredRequests
- Specified by:
getExpiredRequestsin interfacePEPeerTransport- Returns:
- may be null for performance purposes
-
lookupRequest
-
hasBeenRequested
-
removeRequest
-
resetRequestsTimeMono
private void resetRequestsTimeMono(long mono_now) -
toString
-
getString
-
doKeepAliveCheck
public void doKeepAliveCheck()Description copied from interface:PEPeerTransportCheck if we need to send a keep-alive message. A keep-alive is sent if no other message has been sent within the last 2min.- Specified by:
doKeepAliveCheckin interfacePEPeerTransport
-
updateAutoUploadPriority
- Specified by:
updateAutoUploadPriorityin interfacePEPeer
-
doTimeoutChecks
public boolean doTimeoutChecks()Description copied from interface:PEPeerTransportCheck for possible connection timeouts.- Specified by:
doTimeoutChecksin interfacePEPeerTransport- Returns:
- true if the connection has been timed-out, false if not
-
doPerformanceTuningCheck
public void doPerformanceTuningCheck()Description copied from interface:PEPeerTransportPerform checks related to performance optimizations, i.e. tune buffering related to send/receive speed.- Specified by:
doPerformanceTuningCheckin interfacePEPeerTransport
-
getConnectionState
public int getConnectionState()Description copied from interface:PEPeerTransportGet the specific peer connection state.- Specified by:
getConnectionStatein interfacePEPeerTransport- Returns:
- connection state
-
getTimeSinceLastDataMessageReceived
public long getTimeSinceLastDataMessageReceived()Description copied from interface:PEPeerTransportGet the time since the last (most-recent) data (payload) message was received.- Specified by:
getTimeSinceLastDataMessageReceivedin interfacePEPeerTransport- Returns:
- time count in ms, or -1 if we've never received a data message from them
-
getTimeSinceGoodDataReceived
public long getTimeSinceGoodDataReceived()Description copied from interface:PEPeerTransportGet the time since the most-recent data that was actually written to disk was received.- Specified by:
getTimeSinceGoodDataReceivedin interfacePEPeerTransport- Returns:
- time count in ms, or -1 if we've never received useful data from them
-
getTimeSinceLastDataMessageSent
public long getTimeSinceLastDataMessageSent()Description copied from interface:PEPeerTransportGet the time since the last (most-recent) data (payload) message was sent.- Specified by:
getTimeSinceLastDataMessageSentin interfacePEPeerTransport- Returns:
- time count in ms, or -1 if we've never sent them a data message
-
getConnectionEstablishedMonoTime
public long getConnectionEstablishedMonoTime()Description copied from interface:PEPeerGet the time this connection was first established. NOTE: This method will always return -1 at any time before the underlying transport is fully connected, i.e. before handshaking begins.- Specified by:
getConnectionEstablishedMonoTimein interfacePEPeer- Returns:
- mono time in ms
-
getConsecutiveNoRequestCount
public int getConsecutiveNoRequestCount()- Specified by:
getConsecutiveNoRequestCountin interfacePEPeer
-
setConsecutiveNoRequestCount
public void setConsecutiveNoRequestCount(int num) - Specified by:
setConsecutiveNoRequestCountin interfacePEPeer
-
decodeBTHandshake
-
decideExtensionProtocol
-
decodeLTHandshake
-
decodeAZHandshake
-
spoofMDAvailability
private void spoofMDAvailability(int mds) -
initPostConnection
-
decodeHaveAll
-
decodeHaveNone
-
decodeBitfield
-
setSuspendedLazyBitFieldEnabled
public void setSuspendedLazyBitFieldEnabled(boolean enable) Description copied from interface:PEPeerEnable suspended lazy bitfield for this peer - we will appear incomplete until this is disabled, at which point (well, fairly soon after) the bitfield will be completed- Specified by:
setSuspendedLazyBitFieldEnabledin interfacePEPeer- Parameters:
enable-
-
decodeMainlineDHTPort
-
decodeChoke
-
decodeUnchoke
-
decodeInterested
-
decodeUninterested
-
decodeHave
-
decodeAZHave
-
getBytesDownloaded
protected long getBytesDownloaded() -
getBytesRemaining
public long getBytesRemaining()- Specified by:
getBytesRemainingin interfacePEPeer
-
sendBadPiece
public void sendBadPiece(int piece_number) - Specified by:
sendBadPiecein interfacePEPeerTransport
-
decodeAZBadPiece
-
sendStatsRequest
- Specified by:
sendStatsRequestin interfacePEPeer- Specified by:
sendStatsRequestin interfacePEPeerTransport
-
decodeAZStatsRequest
-
sendStatsReply
- Specified by:
sendStatsReplyin interfacePEPeerTransport
-
decodeAZStatsReply
-
decodeRequest
-
sendRejectRequest
- Specified by:
sendRejectRequestin interfacePEPeer
-
sendRejectRequest
private void sendRejectRequest(int number, int offset, int length) -
decodePiece
-
decodeCancel
-
decodeRejectRequest
-
sendHashRequest
- Specified by:
sendHashRequestin interfacePEPeerTransport
-
decodeHashRequest
-
decodeHashes
-
decodeHashReject
-
decodeAllowedFast
-
sendAllowFast
private void sendAllowFast(int number) -
calculatePiecePriorities
protected void calculatePiecePriorities() -
checkFast
-
checkAllowedFast
private void checkAllowedFast() -
registerForMessageHandling
private void registerForMessageHandling() -
addRateLimiter
- Specified by:
addRateLimiterin interfacePEPeer
-
getRateLimiters
- Specified by:
getRateLimitersin interfacePEPeer
-
removeRateLimiter
- Specified by:
removeRateLimiterin interfacePEPeer
-
setUploadDisabled
- Specified by:
setUploadDisabledin interfacePEPeer
-
setDownloadDisabled
- Specified by:
setDownloadDisabledin interfacePEPeer
-
isUploadDisabled
public boolean isUploadDisabled()- Specified by:
isUploadDisabledin interfacePEPeer
-
isUploadDisabled
-
isDownloadDisabled
public boolean isDownloadDisabled()- Specified by:
isDownloadDisabledin interfacePEPeer
-
isDownloadDisabled
-
getNetworkConnection
- Specified by:
getNetworkConnectionin interfacePEPeer
-
getPluginConnection
Description copied from interface:PEPeerGet the connection that backs this peer.- Specified by:
getPluginConnectionin interfacePEPeer- Returns:
- connection
-
getSupportedMessages
Description copied from interface:PEPeerGet the list of messages that this peer and us both understand.- Specified by:
getSupportedMessagesin interfacePEPeer- Returns:
- messages available for use, or null of supported is yet unknown or unavailable
-
supportsMessaging
public boolean supportsMessaging()Description copied from interface:PEPeerWhether or not this peer supports the advanced messaging API.- Specified by:
supportsMessagingin interfacePEPeer- Returns:
- true if extended messaging is supported, false if not
-
getMessagingMode
public int getMessagingMode()- Specified by:
getMessagingModein interfacePEPeer
-
getHandshakeReservedBytes
public byte[] getHandshakeReservedBytes()- Specified by:
getHandshakeReservedBytesin interfacePEPeer
-
setHaveAggregationEnabled
public void setHaveAggregationEnabled(boolean enabled) - Specified by:
setHaveAggregationEnabledin interfacePEPeer
-
hasReceivedBitField
public boolean hasReceivedBitField()- Specified by:
hasReceivedBitFieldin interfacePEPeer
-
getUnchokedForMillis
public long getUnchokedForMillis()- Specified by:
getUnchokedForMillisin interfacePEPeerTransport
-
getLatency
public long getLatency()- Specified by:
getLatencyin interfacePEPeerTransport
-
getEncryption
Description copied from interface:PEPeerReturns name of encryption used by the peer- Specified by:
getEncryptionin interfacePEPeer- Returns:
-
getProtocol
- Specified by:
getProtocolin interfacePEPeer
-
getProtocolQualifier
- Specified by:
getProtocolQualifierin interfacePEPeer
-
addListener
Description copied from interface:PEPeerAdd peer listener.- Specified by:
addListenerin interfacePEPeer- Parameters:
listener-
-
removeListener
Description copied from interface:PEPeerRemove peer listener.- Specified by:
removeListenerin interfacePEPeer- Parameters:
listener-
-
changePeerState
private void changePeerState(int new_state) -
doPostHandshakeProcessing
private void doPostHandshakeProcessing()this method might be called repeatedly since LTEP allows headers to be sent more than once make sure that multiple invokations do not have unintended consequences -
canBePeerExchanged
private boolean canBePeerExchanged() -
peerSupportsMessageType
-
updatePeerExchange
public void updatePeerExchange()Description copied from interface:PEPeerTransportDo any peer exchange processing/updating.- Specified by:
updatePeerExchangein interfacePEPeerTransport
-
decodePeerExchange
-
decodeMetaData
-
decodeUploadOnly
-
isHolePunchSupported
private boolean isHolePunchSupported() -
canSendHolePunch
public boolean canSendHolePunch()- Specified by:
canSendHolePunchin interfacePEPeerTransport
-
sendHolePunch
- Specified by:
sendHolePunchin interfacePEPeerTransport
-
decodeHolePunch
-
sendRequestHint
public boolean sendRequestHint(int piece_number, int offset, int length, int life) Description copied from interface:PEPeerSend a request hint to the peer.- Specified by:
sendRequestHintin interfacePEPeer- Parameters:
piece_number-offset-length-life-- Returns:
- true if sent, false otherwise
-
decodeSuggestPiece
-
decodeAZRequestHint
-
getRequestHint
public int[] getRequestHint()Description copied from interface:PEPeerGet current request hint for a given piece for this peer.- Specified by:
getRequestHintin interfacePEPeer- Returns:
- null if no hint int[]{ piece_number, offset, length } if hint found
-
clearRequestHint
public void clearRequestHint()- Specified by:
clearRequestHintin interfacePEPeer
-
getPeerItemIdentity
Description copied from interface:PEPeerTransportGet the peer's address + port identification item.- Specified by:
getPeerItemIdentityin interfacePEPeerTransport- Returns:
- id
-
getReservedPieceNumbers
public int[] getReservedPieceNumbers()Description copied from interface:PEPeerGet the reserved pieces for piece picking by this peer- Specified by:
getReservedPieceNumbersin interfacePEPeer
-
addReservedPieceNumber
public void addReservedPieceNumber(int piece_number) Description copied from interface:PEPeeradds the reserved piece for piece picking by this peer- Specified by:
addReservedPieceNumberin interfacePEPeer
-
removeReservedPieceNumber
public void removeReservedPieceNumber(int piece_number) - Specified by:
removeReservedPieceNumberin interfacePEPeer
-
getIncomingRequestCount
public int getIncomingRequestCount()- Specified by:
getIncomingRequestCountin interfacePEPeer
-
getOutgoingRequestCount
public int getOutgoingRequestCount()- Specified by:
getOutgoingRequestCountin interfacePEPeer
-
isStalledPendingLoad
public boolean isStalledPendingLoad()Description copied from interface:PEPeerTransportis peer waiting for a disk read with no network writes queued- Specified by:
isStalledPendingLoadin interfacePEPeerTransport- Returns:
-
getIncomingRequestedPieceNumbers
public int[] getIncomingRequestedPieceNumbers()Description copied from interface:PEPeerget a list of piece numbers the peer has requested- Specified by:
getIncomingRequestedPieceNumbersin interfacePEPeer- Returns:
- list of Long() representing the piece number requested, in order
-
getIncomingRequestedPieceNumberCount
public int getIncomingRequestedPieceNumberCount()- Specified by:
getIncomingRequestedPieceNumberCountin interfacePEPeerTransport
-
getRecentPiecesSent
- Specified by:
getRecentPiecesSentin interfacePEPeer
-
getOutgoingRequestedPieceNumbers
public int[] getOutgoingRequestedPieceNumbers()Description copied from interface:PEPeerget a list of piece numbers the we have requested from peer- Specified by:
getOutgoingRequestedPieceNumbersin interfacePEPeer- Returns:
- list of Long() representing the piece number requested, oldest to newest
-
getCurrentIncomingRequestProgress
public int[] getCurrentIncomingRequestProgress()- Specified by:
getCurrentIncomingRequestProgressin interfacePEPeer- Returns:
- null or { size, done }
-
getCurrentOutgoingRequestProgress
public int[] getCurrentOutgoingRequestProgress()- Specified by:
getCurrentOutgoingRequestProgressin interfacePEPeer
-
getLastMessageSentTimeMono
public long getLastMessageSentTimeMono()- Specified by:
getLastMessageSentTimeMonoin interfacePEPeerTransport
-
getRelationText
Description copied from class:LogRelationA short description of what your class holds that can be printed by the logger- Overrides:
getRelationTextin classLogRelation- Returns:
-
getQueryableInterfaces
Description copied from class:LogRelationQuery this class for a reference to another class that it may hold- Overrides:
getQueryableInterfacesin classLogRelation- Returns:
- If found, the class desired. Otherwise, null.
-
getLastPiece
public int getLastPiece()- Specified by:
getLastPiecein interfacePEPeer
-
setLastPiece
public void setLastPiece(int pieceNumber) - Specified by:
setLastPiecein interfacePEPeer
-
isLANLocal
public boolean isLANLocal()Description copied from interface:PEPeerTransportIs the connection within the local LAN network.- Specified by:
isLANLocalin interfacePEPeer- Specified by:
isLANLocalin interfacePEPeerTransport- Returns:
- true if within LAN, false of outside the LAN segment
-
resetLANLocalStatus
public void resetLANLocalStatus()- Specified by:
resetLANLocalStatusin interfacePEPeer
-
isTCP
public boolean isTCP()- Specified by:
isTCPin interfacePEPeerTransport
-
getNetwork
- Specified by:
getNetworkin interfacePEPeerTransport
-
setUploadRateLimitBytesPerSecond
public void setUploadRateLimitBytesPerSecond(int bytes) - Specified by:
setUploadRateLimitBytesPerSecondin interfacePEPeer
-
getUploadRateLimitBytesPerSecond
public int getUploadRateLimitBytesPerSecond()- Specified by:
getUploadRateLimitBytesPerSecondin interfacePEPeer
-
setDownloadRateLimitBytesPerSecond
public void setDownloadRateLimitBytesPerSecond(int bytes) - Specified by:
setDownloadRateLimitBytesPerSecondin interfacePEPeer
-
getDownloadRateLimitBytesPerSecond
public int getDownloadRateLimitBytesPerSecond()- Specified by:
getDownloadRateLimitBytesPerSecondin interfacePEPeer
-
getClientNameFromPeerID
- Specified by:
getClientNameFromPeerIDin interfacePEPeer
-
getClientNameFromExtensionHandshake
- Specified by:
getClientNameFromExtensionHandshakein interfacePEPeer
-
getDHTProvider
-
setPriorityConnection
public void setPriorityConnection(boolean is_priority) - Specified by:
setPriorityConnectionin interfacePEPeer
-
isPriorityConnection
public boolean isPriorityConnection()- Specified by:
isPriorityConnectionin interfacePEPeer
-
generateFastSet
-
generateFastSet
-
getTaggableType
public int getTaggableType()- Specified by:
getTaggableTypein interfaceTaggable
-
getTaggableID
- Specified by:
getTaggableIDin interfaceTaggable
-
getTaggableName
- Specified by:
getTaggableNamein interfaceTaggable
-
getTaggableResolver
- Specified by:
getTaggableResolverin interfaceTaggable
-
getTagMutationCount
public long getTagMutationCount()- Specified by:
getTagMutationCountin interfaceTaggable
-
updateTagMutationCount
public void updateTagMutationCount()- Specified by:
updateTagMutationCountin interfaceTaggable
-
getTaggableTransientProperty
- Specified by:
getTaggableTransientPropertyin interfaceTaggable
-
setTaggableTransientProperty
- Specified by:
setTaggableTransientPropertyin interfaceTaggable
-
getDescriptor
- Specified by:
getDescriptorin interfacePEPeer
-
generateEvidence
- Specified by:
generateEvidencein interfacePEPeerTransport
-