Class PEPeerTransportProtocol
- java.lang.Object
-
- com.biglybt.core.logging.LogRelation
-
- com.biglybt.core.peer.impl.transport.PEPeerTransportProtocol
-
- All Implemented Interfaces:
PEPeerTransport
,PEPeer
,Taggable
,Taggable
public class PEPeerTransportProtocol extends LogRelation implements PEPeerTransport
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
PEPeerTransportProtocol.DisconnectedTransportQueue
protected static class
PEPeerTransportProtocol.MutableInteger
-
Field Summary
-
Fields inherited from interface com.biglybt.core.peer.PEPeer
CLOSING, CONNECTING, DISCONNECTED, HANDSHAKING, MESSAGING_AZMP, MESSAGING_BT_ONLY, MESSAGING_EXTERN, MESSAGING_LTEP, StateNames, TRANSFERING
-
Fields inherited from interface com.biglybt.core.peer.impl.PEPeerTransport
CONNECTION_CONNECTING, CONNECTION_FULLY_ESTABLISHED, CONNECTION_PENDING, CONNECTION_WAITING_FOR_HANDSHAKE, CP_CONNECT_FAILED, CP_CONNECT_OK, CP_CONNECTING, CP_RECEIVED_DATA, CP_UNKNOWN
-
Fields inherited from interface com.biglybt.core.tag.Taggable
TT_DOWNLOAD, TT_PEER
-
-
Constructor Summary
Constructors Constructor Description PEPeerTransportProtocol(PEPeerControl _manager, java.lang.String _peer_source, NetworkConnection _connection, java.util.Map _initial_user_data)
PEPeerTransportProtocol(PEPeerControl _manager, java.lang.String _peer_source, java.lang.String _ip, int _tcp_port, int _udp_port, boolean _use_tcp, boolean _require_crypto_handshake, byte _crypto_level, java.util.Map _initial_user_data)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addAvailability()
void
addListener(PEPeerListener listener)
Add peer listener.void
addRateLimiter(LimitedRateGroup limiter, boolean upload)
void
addReservedPieceNumber(int piece_number)
adds the reserved piece for piece picking by this peerprotected void
calculatePiecePriorities()
private boolean
canBePeerExchanged()
private void
cancelRequests()
private void
changePeerState(int new_state)
private void
checkAllowedFast()
protected void
checkFast(BitFlags flags)
private void
checkForReconnect(HashWrapper oldID)
void
checkInterested()
Global checkInterested method.private void
checkSeed()
Checks if this peer is a seed or not by trivially checking if thier Have bitflags exisits and shows a number of bits set equal to the torrent # of pieces (and the torrent # of pieces is >0)void
clearRequestHint()
void
closeConnection(java.lang.String reason)
Close the peer connection from the PEPeerControl manager side.protected void
closeConnectionInternally(java.lang.String reason)
protected void
closeConnectionInternally(java.lang.String reason, boolean connect_failed, boolean network_failure)
Close the peer connection from within the PEPeerTransport object.private void
createPieceMessageHandler()
private int
decideExtensionProtocol(BTHandshake handshake)
private void
decodeAllowedFast(BTAllowedFast allowed)
protected void
decodeAZBadPiece(AZBadPiece bad_piece)
protected void
decodeAZHandshake(AZHandshake handshake)
protected void
decodeAZHave(AZHave have)
protected void
decodeAZRequestHint(AZRequestHint hint)
protected void
decodeAZStatsReply(AZStatReply reply)
protected void
decodeAZStatsRequest(AZStatRequest request)
protected void
decodeBitfield(BTBitfield bitfield)
protected void
decodeBTHandshake(BTHandshake handshake)
protected void
decodeCancel(BTCancel cancel)
protected void
decodeChoke(BTChoke choke)
private void
decodeHashes(BTHashes hashes)
private void
decodeHashReject(BTHashReject reject)
private void
decodeHashRequest(BTHashRequest request)
protected void
decodeHave(BTHave have)
protected void
decodeHaveAll(BTHaveAll have_all)
protected void
decodeHaveNone(BTHaveNone have_none)
protected void
decodeInterested(BTInterested interested)
protected void
decodeLTHandshake(LTHandshake handshake)
protected void
decodeMainlineDHTPort(BTDHTPort port)
protected void
decodeMetaData(AZUTMetaData metadata)
protected void
decodePeerExchange(AZStylePeerExchange exchange)
protected void
decodePiece(BTPiece piece)
protected void
decodeRejectRequest(BTRejectRequest reject)
protected void
decodeRequest(BTRequest request)
protected void
decodeSuggestPiece(BTSuggestPiece hint)
protected void
decodeUnchoke(BTUnchoke unchoke)
protected void
decodeUninterested(BTUninterested uninterested)
protected void
decodeUploadOnly(UTUploadOnly message)
private void
destroyPieceMessageHandler()
void
doKeepAliveCheck()
Check if we need to send a keep-alive message.void
doPerformanceTuningCheck()
Perform checks related to performance optimizations, i.e.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 consequencesboolean
doTimeoutChecks()
Check for possible connection timeouts.void
generateEvidence(IndentWriter writer)
protected java.util.List<java.lang.Integer>
generateFastSet(byte[] hash, java.lang.String ip, int num_pieces, int num_required)
protected java.util.List<java.lang.Integer>
generateFastSet(int num)
private void
generateSessionId()
java.net.InetAddress
getAlternativeIPv6()
BitFlags
getAvailable()
protected long
getBytesDownloaded()
long
getBytesRemaining()
java.lang.String
getClient()
java.lang.String
getClientNameFromExtensionHandshake()
java.lang.String
getClientNameFromPeerID()
int
getConnectionState()
Get the specific peer connection state.int
getConsecutiveNoRequestCount()
PEPeerControl
getControl()
java.lang.Object
getData(java.lang.String key)
To retreive arbitrary objects against a peer.private static MainlineDHTProvider
getDHTProvider()
int
getDownloadRateLimitBytesPerSecond()
java.lang.String
getEncryption()
Returns name of encryption used by the peerjava.util.List
getExpiredRequests()
byte[]
getHandshakeReservedBytes()
byte[]
getId()
int
getIncomingRequestCount()
int
getIncomingRequestedPieceNumberCount()
int[]
getIncomingRequestedPieceNumbers()
get a list of piece numbers the peer has requestedjava.lang.String
getIp()
java.lang.String
getIPHostName()
Gets the host name for the IP, if possible, IP as string otherwiselong
getLastMessageSentTime()
int
getLastPiece()
long
getLatency()
PEPeerManager
getManager()
int
getMaxNbRequests()
peer-specific request max.int
getMessagingMode()
int
getNbRequests()
java.lang.String
getNetwork()
NetworkConnectionBase
getNetworkConnection()
int
getOutboundConnectionProgress()
int
getOutgoingRequestCount()
int[]
getOutgoingRequestedPieceNumbers()
get a list of piece numbers the we have requested from peerPeerItem
getPeerItemIdentity()
Get the peer's address + port identification item.java.lang.String
getPeerSource()
int
getPeerState()
int
getPercentDoneInThousandNotation()
Get the peer's torrent completion percentage in thousand-notation, i.e.int
getPercentDoneOfCurrentIncomingRequest()
int
getPercentDoneOfCurrentOutgoingRequest()
Connection
getPluginConnection()
Get the connection that backs this peer.int
getPort()
Get the peer's local TCP connection port.int[]
getPriorityOffsets()
Any priority offsets this peer has, or null if nonejava.lang.String
getProtocol()
java.lang.String
getProtocolQualifier()
java.lang.Object[]
getQueryableInterfaces()
Query this class for a reference to another class that it may holdLimitedRateGroup[]
getRateLimiters(boolean upload)
DiskManagerReadRequest[]
getRecentPiecesSent()
java.lang.String
getRelationText()
A short description of what your class holds that can be printed by the loggerint[]
getRequestHint()
Get current request hint for a given piece for this peer.int
getRequestIndex(DiskManagerReadRequest request)
Returns the index of this request in the peer's queue or -1 if not foundint[]
getReservedPieceNumbers()
Get the reserved pieces for piece picking by this peerlong
getSnubbedTime()
PEPeerStats
getStats()
java.lang.String
getString()
Message[]
getSupportedMessages()
Get the list of messages that this peer and us both understand.java.lang.String
getTaggableID()
java.lang.String
getTaggableName()
TaggableResolver
getTaggableResolver()
java.lang.Object
getTaggableTransientProperty(java.lang.String key)
int
getTaggableType()
int
getTCPListenPort()
Get the TCP port this peer is listening for incoming connections on.long
getTimeSinceConnectionEstablished()
Get the time since this connection was first established.long
getTimeSinceGoodDataReceived()
Get the time since the most-recent data that was actually written to disk was received.long
getTimeSinceLastDataMessageReceived()
Get the time since the last (most-recent) data (payload) message was received.long
getTimeSinceLastDataMessageSent()
Get the time since the last (most-recent) data (payload) message was sent.int
getUDPListenPort()
Get the UDP port this peer is listening for incoming connections on.int
getUDPNonDataListenPort()
Get the UDP port this peer is listening on for non-data connectionslong
getUnchokedForMillis()
int
getUniqueAnnounce()
int
getUploadHint()
int
getUploadRateLimitBytesPerSecond()
java.lang.Object
getUserData(java.lang.Object key)
To retreive arbitrary objects against a peer.private boolean
hasBeenRequested(DiskManagerReadRequest request)
boolean
hasReceivedBitField()
protected void
initializeConnection()
private void
initPostConnection(Message handshake)
boolean
isChokedByMe()
Am I choking the peer.boolean
isChokingMe()
Is the peer choking me.boolean
isClosed()
boolean
isDownloadDisabled()
boolean
isDownloadDisabled(java.lang.Object key)
boolean
isDownloadPossible()
checks several factors within the object so the caller wouldn't need to for convienience and speed.boolean
isIncoming()
boolean
isInterested()
Is the peer Interested in me.boolean
isInteresting()
Am I Interested in the peer.boolean
isLANLocal()
Is the connection within the local LAN network.boolean
isMyPeer()
Whether or not this is a 'dummy' peer that represents our presence in a swarmboolean
isOptimisticUnchoke()
boolean
isPieceAvailable(int pieceNumber)
boolean
isPriorityConnection()
boolean
isRelativeSeed()
boolean
isSafeForReconnect()
This method is called to check if it is safe to reconnect to a peer, i.e.boolean
isSeed()
boolean
isSnubbed()
boolean
isStalledPendingLoad()
is peer waiting for a disk read with no network writes queuedboolean
isTCP()
boolean
isUnchokeOverride()
boolean
isUploadDisabled()
boolean
isUploadDisabled(java.lang.Object key)
private DiskManagerReadRequest
lookupRequest(int piece_number, int piece_offset, int length)
private boolean
peerSupportsMessageType(java.lang.String message_id)
private void
performClose(java.lang.String reason, boolean connect_failed, boolean externally_closed, boolean network_failure)
private void
printRequestStats()
PEPeerTransport
reconnect(boolean tryUDP, boolean tryIPv6)
Attempts to reconnect to the same peerprivate void
registerForMessageHandling()
private void
removeAvailability()
void
removeListener(PEPeerListener listener)
Remove peer listener.void
removeRateLimiter(LimitedRateGroup limiter, boolean upload)
protected void
removeRequest(DiskManagerReadRequest request)
void
removeReservedPieceNumber(int piece_number)
DiskManagerReadRequest
request(int pieceNumber, int pieceOffset, int pieceLength, boolean return_duplicates)
void
requestAllocationComplete()
boolean
requestAllocationStarts(int[] base_priorities)
Two methods that allow a peer to aggregate the individual requests generated during an allocation cycle if so desiredvoid
resetLANLocalStatus()
private void
resetRequestsTime(long now)
private void
sendAllowFast(int number)
private void
sendAZHandshake()
void
sendBadPiece(int piece_number)
private void
sendBitField()
Private method to send the bitfield.protected void
sendBTHandshake()
void
sendCancel(DiskManagerReadRequest request)
void
sendChoke()
void
sendHashRequest(TOTorrentFileHashTree.HashRequest req)
void
sendHave(int pieceNumber)
private void
sendHaveNone()
private void
sendKeepAlive()
protected void
sendLazyHaves(int[] lazy_haves, boolean immediate)
private void
sendLTHandshake()
private void
sendMainlineDHTPort()
private void
sendRejectRequest(int number, int offset, int length)
void
sendRejectRequest(DiskManagerReadRequest request)
boolean
sendRequestHint(int piece_number, int offset, int length, int life)
Send a request hint to the peer.void
sendStatsReply(java.util.Map reply)
void
sendStatsRequest(java.util.Map request)
void
sendUnChoke()
void
setConsecutiveNoRequestCount(int num)
void
setData(java.lang.String key, java.lang.Object value)
To store arbitrary objects against a peer.void
setDownloadDisabled(java.lang.Object key, boolean disabled)
void
setDownloadRateLimitBytesPerSecond(int bytes)
void
setHaveAggregationEnabled(boolean enabled)
void
setLastPiece(int pieceNumber)
void
setOptimisticUnchoke(boolean is_optimistic)
void
setPriorityConnection(boolean is_priority)
private void
setSeed(boolean s)
void
setSnubbed(boolean b)
void
setSuspendedLazyBitFieldEnabled(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 completedvoid
setTaggableTransientProperty(java.lang.String key, java.lang.Object value)
void
setUniqueAnnounce(int _uniquePiece)
void
setUploadDisabled(java.lang.Object key, boolean disabled)
void
setUploadHint(int spreadTime)
void
setUploadRateLimitBytesPerSecond(int bytes)
void
setUserData(java.lang.Object key, java.lang.Object value)
To store arbitrary objects against a peer.private void
spoofMDAvailability(int mds)
void
start()
Start message processing for the peerboolean
supportsMessaging()
Whether or not this peer supports the advanced messaging API.java.lang.String
toString()
boolean
transferAvailable()
void
updateAutoUploadPriority(java.lang.Object key, boolean inc)
void
updatePeerExchange()
Do any peer exchange processing/updating.-
Methods inherited from class com.biglybt.core.logging.LogRelation
propogatedRelationText, queryForClass
-
-
-
-
Field Detail
-
LOGID
protected static final LogIDs LOGID
-
_lastPiece
private volatile int _lastPiece
-
manager
protected final PEPeerControl manager
-
diskManager
protected final DiskManager diskManager
-
piecePicker
protected final PiecePicker piecePicker
-
nbPieces
protected final int nbPieces
-
peer_source
private final java.lang.String peer_source
-
peer_id
private byte[] peer_id
-
ip
private final java.lang.String ip
-
network
private final java.lang.String network
-
ip_resolved
protected java.lang.String ip_resolved
-
ip_resolver_request
private IPToHostNameResolverRequest ip_resolver_request
-
port
private final int port
-
peer_item_identity
private PeerItem 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
private java.net.InetAddress alternativeAddress
-
crypto_level
private byte crypto_level
-
peer_stats
protected PEPeerStats peer_stats
-
requested
private final java.util.ArrayList<DiskManagerReadRequest> requested
-
requested_mon
private final AEMonitor requested_mon
-
data
private java.util.Map 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
-
snubbed
private long snubbed
-
peerHavePieces
private volatile BitFlags 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:
- Constant Field Values
-
RELATIVE_SEEDING_UPLOAD_ONLY_INDICATED
private static final byte RELATIVE_SEEDING_UPLOAD_ONLY_INDICATED
- See Also:
- Constant Field Values
-
RELATIVE_SEEDING_UPLOAD_ONLY_SEED
private static final byte RELATIVE_SEEDING_UPLOAD_ONLY_SEED
- See Also:
- Constant Field Values
-
relativeSeeding
private byte relativeSeeding
-
incoming
private final boolean incoming
-
closing
protected volatile boolean closing
-
current_peer_state
private volatile int current_peer_state
-
connection
private final NetworkConnection connection
-
outgoing_piece_message_handler
private OutgoingBTPieceMessageHandler outgoing_piece_message_handler
-
outgoing_have_message_aggregator
private OutgoingBTHaveMessageAggregator outgoing_have_message_aggregator
-
plugin_connection
private Connection plugin_connection
-
identityAdded
private boolean identityAdded
-
connection_state
private int connection_state
-
outbound_connection_progress
private int outbound_connection_progress
-
client
private java.lang.String client
-
client_peer_id
private java.lang.String client_peer_id
-
client_handshake
private java.lang.String client_handshake
-
client_handshake_version
private java.lang.String client_handshake_version
-
uniquePiece
private int uniquePiece
-
reserved_pieces
private int[] reserved_pieces
-
spreadTimeHint
private int spreadTimeHint
-
last_message_sent_time
private long last_message_sent_time
-
last_message_received_time
private long last_message_received_time
-
last_data_message_received_time
private long last_data_message_received_time
-
last_good_data_time
private long last_good_data_time
-
last_data_message_sent_time
private long last_data_message_sent_time
-
connection_established_time
private long connection_established_time
-
consecutive_no_request_count
private int consecutive_no_request_count
-
messaging_mode
private int messaging_mode
-
supported_messages
private Message[] 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:
- Constant Field Values
-
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:
- Constant Field Values
-
ut_pex_enabled
private boolean ut_pex_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:
- Constant Field Values
-
ALLOWED_FAST_OTHER_PEER_PIECE_MAX
private static final int ALLOWED_FAST_OTHER_PEER_PIECE_MAX
- See Also:
- Constant Field Values
-
KEY_ALLOWED_FAST_RECEIVED
private static final java.lang.Object KEY_ALLOWED_FAST_RECEIVED
-
KEY_ALLOWED_FAST_SENT
private static final java.lang.Object KEY_ALLOWED_FAST_SENT
-
closing_mon
private final AEMonitor closing_mon
-
general_mon
private final AEMonitor general_mon
-
handshake_reserved_bytes
private byte[] handshake_reserved_bytes
-
recent_outgoing_requests
private java.util.LinkedHashMap recent_outgoing_requests
-
recent_outgoing_requests_mon
private AEMonitor 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:
- Constant Field Values
-
request_hint
private int[] request_hint
-
peer_listeners_cow
private java.util.List peer_listeners_cow
-
peer_listeners_mon
private final AEMonitor 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
-
recentlyDisconnected
private static final PEPeerTransportProtocol.DisconnectedTransportQueue recentlyDisconnected
-
fast_unchoke_new_peers
private static boolean fast_unchoke_new_peers
-
rnd
private static final java.util.Random rnd
-
sessionSecret
private static final byte[] sessionSecret
-
enable_upload_bias
private static boolean enable_upload_bias
-
enable_public_tcp_peers
private static boolean enable_public_tcp_peers
-
enable_public_udp_peers
private static boolean enable_public_udp_peers
-
prefer_ipv6
private static boolean prefer_ipv6
-
peerSessionID
private HashWrapper peerSessionID
-
mySessionID
private HashWrapper mySessionID
-
allowReconnect
private boolean allowReconnect
-
upload_disabled_set
private java.util.Set<java.lang.Object> upload_disabled_set
-
download_disabled_set
private java.util.Set<java.lang.Object> 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
private PeerExchangerItem peer_exchange_item
-
peer_exchange_supported
private boolean peer_exchange_supported
-
message_limiter
protected PeerMessageLimiter 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
-
-
Constructor Detail
-
PEPeerTransportProtocol
public PEPeerTransportProtocol(PEPeerControl _manager, java.lang.String _peer_source, NetworkConnection _connection, java.util.Map _initial_user_data)
-
PEPeerTransportProtocol
public PEPeerTransportProtocol(PEPeerControl _manager, java.lang.String _peer_source, java.lang.String _ip, int _tcp_port, int _udp_port, boolean _use_tcp, boolean _require_crypto_handshake, byte _crypto_level, java.util.Map _initial_user_data)
-
-
Method Detail
-
start
public void start()
Description copied from interface:PEPeerTransport
Start message processing for the peer- Specified by:
start
in interfacePEPeerTransport
-
initializeConnection
protected void initializeConnection()
-
isMyPeer
public boolean isMyPeer()
Description copied from interface:PEPeer
Whether or not this is a 'dummy' peer that represents our presence in a swarm
-
getPeerSource
public java.lang.String getPeerSource()
- Specified by:
getPeerSource
in interfacePEPeer
-
getOutboundConnectionProgress
public int getOutboundConnectionProgress()
- Specified by:
getOutboundConnectionProgress
in interfacePEPeerTransport
-
closeConnectionInternally
protected void closeConnectionInternally(java.lang.String reason, boolean connect_failed, boolean network_failure)
Close the peer connection from within the PEPeerTransport object.- Parameters:
reason
-
-
closeConnectionInternally
protected void closeConnectionInternally(java.lang.String reason)
-
closeConnection
public void closeConnection(java.lang.String reason)
Close the peer connection from the PEPeerControl manager side. NOTE: This method assumes PEPeerControl already knows about the close. This method is inteded to be only invoked by select administrative methods. You probably should not invoke this directly.- Specified by:
closeConnection
in interfacePEPeerTransport
- Parameters:
reason
- for closure
-
performClose
private void performClose(java.lang.String reason, boolean connect_failed, boolean externally_closed, boolean network_failure)
-
reconnect
public PEPeerTransport reconnect(boolean tryUDP, boolean tryIPv6)
Description copied from interface:PEPeerTransport
Attempts to reconnect to the same peer- Specified by:
reconnect
in interfacePEPeerTransport
- Parameters:
tryUDP
- try to initate 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:PEPeerTransport
This 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:
isSafeForReconnect
in interfacePEPeerTransport
- Returns:
- true if we exchanged payload data with the peer during the current connection
-
checkForReconnect
private void checkForReconnect(HashWrapper oldID)
-
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:
getPeerState
in interfacePEPeer
-
isDownloadPossible
public boolean isDownloadPossible()
Description copied from interface:PEPeer
checks several factors within the object so the caller wouldn't need to for convienience and speed.- Specified by:
isDownloadPossible
in 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:PEPeer
Get the peer's torrent completion percentage in thousand-notation, i.e. 53.7% is returned as the value 0537.- Specified by:
getPercentDoneInThousandNotation
in interfacePEPeer
- Returns:
- the percentage the peer has complete
-
transferAvailable
public boolean transferAvailable()
- Specified by:
transferAvailable
in interfacePEPeer
- Specified by:
transferAvailable
in interfacePEPeerTransport
-
printRequestStats
private void printRequestStats()
-
checkSeed
private void checkSeed()
Checks if this peer is a seed or not by trivially checking if thier Have bitflags exisits 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:
request
in interfacePEPeerTransport
return_duplicates
- - if true and request already exists it will be returned, if false -> null- Returns:
- request if actually requested, null otherwise
-
getRequestIndex
public int getRequestIndex(DiskManagerReadRequest request)
Description copied from interface:PEPeerTransport
Returns the index of this request in the peer's queue or -1 if not found- Specified by:
getRequestIndex
in interfacePEPeerTransport
- Returns:
-
sendCancel
public void sendCancel(DiskManagerReadRequest request)
- Specified by:
sendCancel
in interfacePEPeerTransport
-
sendHaveNone
private void sendHaveNone()
-
sendHave
public void sendHave(int pieceNumber)
- Specified by:
sendHave
in interfacePEPeerTransport
-
sendChoke
public void sendChoke()
- Specified by:
sendChoke
in interfacePEPeer
- Specified by:
sendChoke
in interfacePEPeerTransport
-
sendUnChoke
public void sendUnChoke()
- Specified by:
sendUnChoke
in interfacePEPeer
- Specified by:
sendUnChoke
in 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:
checkInterested
in interfacePEPeerTransport
-
sendBitField
private void sendBitField()
Private method to send the bitfield.
-
sendLazyHaves
protected void sendLazyHaves(int[] lazy_haves, boolean immediate)
-
getAlternativeIPv6
public java.net.InetAddress getAlternativeIPv6()
- Specified by:
getAlternativeIPv6
in interfacePEPeer
- Returns:
- an ipv6 address under which the peer should be connectable if it announced one, null otherwise
-
getPort
public int getPort()
Description copied from interface:PEPeer
Get the peer's local TCP connection port.
-
getTCPListenPort
public int getTCPListenPort()
Description copied from interface:PEPeer
Get the TCP port this peer is listening for incoming connections on.- Specified by:
getTCPListenPort
in interfacePEPeer
- Returns:
- TCP port, or 0 if port is unknown
-
getUDPListenPort
public int getUDPListenPort()
Description copied from interface:PEPeer
Get the UDP port this peer is listening for incoming connections on.- Specified by:
getUDPListenPort
in interfacePEPeer
- Returns:
- UDP port, or 0 if port is unknown
-
getUDPNonDataListenPort
public int getUDPNonDataListenPort()
Description copied from interface:PEPeer
Get the UDP port this peer is listening on for non-data connections- Specified by:
getUDPNonDataListenPort
in interfacePEPeer
- Returns:
-
isIncoming
public boolean isIncoming()
- Specified by:
isIncoming
in interfacePEPeer
-
isOptimisticUnchoke
public boolean isOptimisticUnchoke()
- Specified by:
isOptimisticUnchoke
in interfacePEPeer
-
setOptimisticUnchoke
public void setOptimisticUnchoke(boolean is_optimistic)
- Specified by:
setOptimisticUnchoke
in interfacePEPeer
-
getControl
public PEPeerControl getControl()
- Specified by:
getControl
in interfacePEPeerTransport
-
getManager
public PEPeerManager getManager()
- Specified by:
getManager
in interfacePEPeer
-
getStats
public PEPeerStats getStats()
-
getPriorityOffsets
public int[] getPriorityOffsets()
Description copied from interface:PEPeerTransport
Any priority offsets this peer has, or null if none- Specified by:
getPriorityOffsets
in interfacePEPeerTransport
- Returns:
-
requestAllocationStarts
public boolean requestAllocationStarts(int[] base_priorities)
Description copied from interface:PEPeerTransport
Two methods that allow a peer to aggregate the individual requests generated during an allocation cycle if so desired- Specified by:
requestAllocationStarts
in 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:
requestAllocationComplete
in interfacePEPeerTransport
-
getAvailable
public BitFlags getAvailable()
- Specified by:
getAvailable
in interfacePEPeer
- Returns:
- null if no bitfield has been recieved yet else returns BitFlags indicating what pieces the peer has
-
isPieceAvailable
public boolean isPieceAvailable(int pieceNumber)
- Specified by:
isPieceAvailable
in interfacePEPeer
- Parameters:
pieceNumber
- int- Returns:
- true if this peers makes this piece available
-
isChokingMe
public boolean isChokingMe()
Description copied from interface:PEPeer
Is the peer choking me.- Specified by:
isChokingMe
in interfacePEPeer
- Returns:
- true if I am choked by the peer, false if not
-
isUnchokeOverride
public boolean isUnchokeOverride()
- Specified by:
isUnchokeOverride
in interfacePEPeer
-
isChokedByMe
public boolean isChokedByMe()
Description copied from interface:PEPeer
Am I choking the peer.- Specified by:
isChokedByMe
in interfacePEPeer
- Returns:
- true if the peer is choked, false if not
-
isInteresting
public boolean isInteresting()
Description copied from interface:PEPeer
Am I Interested in the peer.- Specified by:
isInteresting
in interfacePEPeer
- Returns:
- true if the peer is interesting to us
-
isInterested
public boolean isInterested()
Description copied from interface:PEPeer
Is the peer Interested in me.- Specified by:
isInterested
in interfacePEPeer
- Returns:
- true if the peer is interested in what we're offering
-
isRelativeSeed
public boolean isRelativeSeed()
- Specified by:
isRelativeSeed
in 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)
-
getSnubbedTime
public long getSnubbedTime()
- Specified by:
getSnubbedTime
in interfacePEPeer
-
setSnubbed
public void setSnubbed(boolean b)
- Specified by:
setSnubbed
in interfacePEPeer
-
setUploadHint
public void setUploadHint(int spreadTime)
- Specified by:
setUploadHint
in interfacePEPeer
-
getUploadHint
public int getUploadHint()
- Specified by:
getUploadHint
in interfacePEPeer
-
setUniqueAnnounce
public void setUniqueAnnounce(int _uniquePiece)
- Specified by:
setUniqueAnnounce
in interfacePEPeer
-
getUniqueAnnounce
public int getUniqueAnnounce()
- Specified by:
getUniqueAnnounce
in interfacePEPeer
-
getData
public java.lang.Object getData(java.lang.String key)
Description copied from interface:PEPeer
To retreive arbitrary objects against a peer.
-
setData
public void setData(java.lang.String key, java.lang.Object value)
Description copied from interface:PEPeer
To store arbitrary objects against a peer.
-
getUserData
public java.lang.Object getUserData(java.lang.Object key)
To retreive arbitrary objects against a peer.- Specified by:
getUserData
in interfacePEPeer
-
setUserData
public void setUserData(java.lang.Object key, java.lang.Object value)
To store arbitrary objects against a peer.- Specified by:
setUserData
in interfacePEPeer
-
getIPHostName
public java.lang.String getIPHostName()
Description copied from interface:PEPeer
Gets the host name for the IP, if possible, IP as string otherwise- Specified by:
getIPHostName
in interfacePEPeer
- Returns:
- hostname or IP
-
cancelRequests
private void cancelRequests()
-
getMaxNbRequests
public int getMaxNbRequests()
Description copied from interface:PEPeerTransport
peer-specific request max. return -1 to use the default piece-picker allocation method- Specified by:
getMaxNbRequests
in interfacePEPeerTransport
- Returns:
-
getNbRequests
public int getNbRequests()
- Specified by:
getNbRequests
in interfacePEPeerTransport
-
getExpiredRequests
public java.util.List getExpiredRequests()
- Specified by:
getExpiredRequests
in interfacePEPeerTransport
- Returns:
- may be null for performance purposes
-
lookupRequest
private DiskManagerReadRequest lookupRequest(int piece_number, int piece_offset, int length)
-
hasBeenRequested
private boolean hasBeenRequested(DiskManagerReadRequest request)
-
removeRequest
protected void removeRequest(DiskManagerReadRequest request)
-
resetRequestsTime
private void resetRequestsTime(long now)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getString
public java.lang.String getString()
-
doKeepAliveCheck
public void doKeepAliveCheck()
Description copied from interface:PEPeerTransport
Check 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:
doKeepAliveCheck
in interfacePEPeerTransport
-
updateAutoUploadPriority
public void updateAutoUploadPriority(java.lang.Object key, boolean inc)
- Specified by:
updateAutoUploadPriority
in interfacePEPeer
-
doTimeoutChecks
public boolean doTimeoutChecks()
Description copied from interface:PEPeerTransport
Check for possible connection timeouts.- Specified by:
doTimeoutChecks
in interfacePEPeerTransport
- Returns:
- true if the connection has been timed-out, false if not
-
doPerformanceTuningCheck
public void doPerformanceTuningCheck()
Description copied from interface:PEPeerTransport
Perform checks related to performance optimizations, i.e. tune buffering related to send/receive speed.- Specified by:
doPerformanceTuningCheck
in interfacePEPeerTransport
-
getConnectionState
public int getConnectionState()
Description copied from interface:PEPeerTransport
Get the specific peer connection state.- Specified by:
getConnectionState
in interfacePEPeerTransport
- Returns:
- connection state
-
getTimeSinceLastDataMessageReceived
public long getTimeSinceLastDataMessageReceived()
Description copied from interface:PEPeerTransport
Get the time since the last (most-recent) data (payload) message was received.- Specified by:
getTimeSinceLastDataMessageReceived
in 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:PEPeerTransport
Get the time since the most-recent data that was actually written to disk was received.- Specified by:
getTimeSinceGoodDataReceived
in interfacePEPeerTransport
- Returns:
- time count in ms, or -1 if we've never received usefull data from them
-
getTimeSinceLastDataMessageSent
public long getTimeSinceLastDataMessageSent()
Description copied from interface:PEPeerTransport
Get the time since the last (most-recent) data (payload) message was sent.- Specified by:
getTimeSinceLastDataMessageSent
in interfacePEPeerTransport
- Returns:
- time count in ms, or -1 if we've never sent them a data message
-
getTimeSinceConnectionEstablished
public long getTimeSinceConnectionEstablished()
Description copied from interface:PEPeer
Get the time since this connection was first established. NOTE: This method will always return 0 at any time before the underlying transport is fully connected, i.e. before handshaking begins.- Specified by:
getTimeSinceConnectionEstablished
in interfacePEPeer
- Returns:
- time count in ms
-
getConsecutiveNoRequestCount
public int getConsecutiveNoRequestCount()
- Specified by:
getConsecutiveNoRequestCount
in interfacePEPeer
-
setConsecutiveNoRequestCount
public void setConsecutiveNoRequestCount(int num)
- Specified by:
setConsecutiveNoRequestCount
in interfacePEPeer
-
decodeBTHandshake
protected void decodeBTHandshake(BTHandshake handshake)
-
decideExtensionProtocol
private int decideExtensionProtocol(BTHandshake handshake)
-
decodeLTHandshake
protected void decodeLTHandshake(LTHandshake handshake)
-
decodeAZHandshake
protected void decodeAZHandshake(AZHandshake handshake)
-
spoofMDAvailability
private void spoofMDAvailability(int mds)
-
initPostConnection
private void initPostConnection(Message handshake)
-
decodeHaveAll
protected void decodeHaveAll(BTHaveAll have_all)
-
decodeHaveNone
protected void decodeHaveNone(BTHaveNone have_none)
-
decodeBitfield
protected void decodeBitfield(BTBitfield bitfield)
-
setSuspendedLazyBitFieldEnabled
public void setSuspendedLazyBitFieldEnabled(boolean enable)
Description copied from interface:PEPeer
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 completed- Specified by:
setSuspendedLazyBitFieldEnabled
in interfacePEPeer
-
decodeMainlineDHTPort
protected void decodeMainlineDHTPort(BTDHTPort port)
-
decodeChoke
protected void decodeChoke(BTChoke choke)
-
decodeUnchoke
protected void decodeUnchoke(BTUnchoke unchoke)
-
decodeInterested
protected void decodeInterested(BTInterested interested)
-
decodeUninterested
protected void decodeUninterested(BTUninterested uninterested)
-
decodeHave
protected void decodeHave(BTHave have)
-
decodeAZHave
protected void decodeAZHave(AZHave have)
-
getBytesDownloaded
protected long getBytesDownloaded()
-
getBytesRemaining
public long getBytesRemaining()
- Specified by:
getBytesRemaining
in interfacePEPeer
-
sendBadPiece
public void sendBadPiece(int piece_number)
- Specified by:
sendBadPiece
in interfacePEPeerTransport
-
decodeAZBadPiece
protected void decodeAZBadPiece(AZBadPiece bad_piece)
-
sendStatsRequest
public void sendStatsRequest(java.util.Map request)
- Specified by:
sendStatsRequest
in interfacePEPeer
- Specified by:
sendStatsRequest
in interfacePEPeerTransport
-
decodeAZStatsRequest
protected void decodeAZStatsRequest(AZStatRequest request)
-
sendStatsReply
public void sendStatsReply(java.util.Map reply)
- Specified by:
sendStatsReply
in interfacePEPeerTransport
-
decodeAZStatsReply
protected void decodeAZStatsReply(AZStatReply reply)
-
decodeRequest
protected void decodeRequest(BTRequest request)
-
sendRejectRequest
public void sendRejectRequest(DiskManagerReadRequest request)
- Specified by:
sendRejectRequest
in interfacePEPeer
-
sendRejectRequest
private void sendRejectRequest(int number, int offset, int length)
-
decodePiece
protected void decodePiece(BTPiece piece)
-
decodeCancel
protected void decodeCancel(BTCancel cancel)
-
decodeRejectRequest
protected void decodeRejectRequest(BTRejectRequest reject)
-
sendHashRequest
public void sendHashRequest(TOTorrentFileHashTree.HashRequest req)
- Specified by:
sendHashRequest
in interfacePEPeerTransport
-
decodeHashRequest
private void decodeHashRequest(BTHashRequest request)
-
decodeHashes
private void decodeHashes(BTHashes hashes)
-
decodeHashReject
private void decodeHashReject(BTHashReject reject)
-
decodeAllowedFast
private void decodeAllowedFast(BTAllowedFast allowed)
-
sendAllowFast
private void sendAllowFast(int number)
-
calculatePiecePriorities
protected void calculatePiecePriorities()
-
checkFast
protected void checkFast(BitFlags flags)
-
checkAllowedFast
private void checkAllowedFast()
-
registerForMessageHandling
private void registerForMessageHandling()
-
addRateLimiter
public void addRateLimiter(LimitedRateGroup limiter, boolean upload)
- Specified by:
addRateLimiter
in interfacePEPeer
-
getRateLimiters
public LimitedRateGroup[] getRateLimiters(boolean upload)
- Specified by:
getRateLimiters
in interfacePEPeer
-
removeRateLimiter
public void removeRateLimiter(LimitedRateGroup limiter, boolean upload)
- Specified by:
removeRateLimiter
in interfacePEPeer
-
setUploadDisabled
public void setUploadDisabled(java.lang.Object key, boolean disabled)
- Specified by:
setUploadDisabled
in interfacePEPeer
-
setDownloadDisabled
public void setDownloadDisabled(java.lang.Object key, boolean disabled)
- Specified by:
setDownloadDisabled
in interfacePEPeer
-
isUploadDisabled
public boolean isUploadDisabled()
- Specified by:
isUploadDisabled
in interfacePEPeer
-
isUploadDisabled
public boolean isUploadDisabled(java.lang.Object key)
-
isDownloadDisabled
public boolean isDownloadDisabled()
- Specified by:
isDownloadDisabled
in interfacePEPeer
-
isDownloadDisabled
public boolean isDownloadDisabled(java.lang.Object key)
-
getNetworkConnection
public NetworkConnectionBase getNetworkConnection()
- Specified by:
getNetworkConnection
in interfacePEPeer
-
getPluginConnection
public Connection getPluginConnection()
Description copied from interface:PEPeer
Get the connection that backs this peer.- Specified by:
getPluginConnection
in interfacePEPeer
- Returns:
- connection
-
getSupportedMessages
public Message[] getSupportedMessages()
Description copied from interface:PEPeer
Get the list of messages that this peer and us both understand.- Specified by:
getSupportedMessages
in interfacePEPeer
- Returns:
- messages available for use, or null of supported is yet unknown or unavailable
-
supportsMessaging
public boolean supportsMessaging()
Description copied from interface:PEPeer
Whether or not this peer supports the advanced messaging API.- Specified by:
supportsMessaging
in interfacePEPeer
- Returns:
- true if extended messaging is supported, false if not
-
getMessagingMode
public int getMessagingMode()
- Specified by:
getMessagingMode
in interfacePEPeer
-
getHandshakeReservedBytes
public byte[] getHandshakeReservedBytes()
- Specified by:
getHandshakeReservedBytes
in interfacePEPeer
-
setHaveAggregationEnabled
public void setHaveAggregationEnabled(boolean enabled)
- Specified by:
setHaveAggregationEnabled
in interfacePEPeer
-
hasReceivedBitField
public boolean hasReceivedBitField()
- Specified by:
hasReceivedBitField
in interfacePEPeer
-
getUnchokedForMillis
public long getUnchokedForMillis()
- Specified by:
getUnchokedForMillis
in interfacePEPeerTransport
-
getLatency
public long getLatency()
- Specified by:
getLatency
in interfacePEPeerTransport
-
getEncryption
public java.lang.String getEncryption()
Description copied from interface:PEPeer
Returns name of encryption used by the peer- Specified by:
getEncryption
in interfacePEPeer
- Returns:
-
getProtocol
public java.lang.String getProtocol()
- Specified by:
getProtocol
in interfacePEPeer
-
getProtocolQualifier
public java.lang.String getProtocolQualifier()
- Specified by:
getProtocolQualifier
in interfacePEPeer
-
addListener
public void addListener(PEPeerListener listener)
Description copied from interface:PEPeer
Add peer listener.- Specified by:
addListener
in interfacePEPeer
-
removeListener
public void removeListener(PEPeerListener listener)
Description copied from interface:PEPeer
Remove peer listener.- Specified by:
removeListener
in interfacePEPeer
-
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
private boolean peerSupportsMessageType(java.lang.String message_id)
-
updatePeerExchange
public void updatePeerExchange()
Description copied from interface:PEPeerTransport
Do any peer exchange processing/updating.- Specified by:
updatePeerExchange
in interfacePEPeerTransport
-
decodePeerExchange
protected void decodePeerExchange(AZStylePeerExchange exchange)
-
decodeMetaData
protected void decodeMetaData(AZUTMetaData metadata)
-
decodeUploadOnly
protected void decodeUploadOnly(UTUploadOnly message)
-
sendRequestHint
public boolean sendRequestHint(int piece_number, int offset, int length, int life)
Description copied from interface:PEPeer
Send a request hint to the peer.- Specified by:
sendRequestHint
in interfacePEPeer
- Returns:
- true if sent, false otherwise
-
decodeSuggestPiece
protected void decodeSuggestPiece(BTSuggestPiece hint)
-
decodeAZRequestHint
protected void decodeAZRequestHint(AZRequestHint hint)
-
getRequestHint
public int[] getRequestHint()
Description copied from interface:PEPeer
Get current request hint for a given piece for this peer.- Specified by:
getRequestHint
in interfacePEPeer
- Returns:
- null if no hint int[]{ piece_number, offset, length } if hint found
-
clearRequestHint
public void clearRequestHint()
- Specified by:
clearRequestHint
in interfacePEPeer
-
getPeerItemIdentity
public PeerItem getPeerItemIdentity()
Description copied from interface:PEPeerTransport
Get the peer's address + port identification item.- Specified by:
getPeerItemIdentity
in interfacePEPeerTransport
- Returns:
- id
-
getReservedPieceNumbers
public int[] getReservedPieceNumbers()
Description copied from interface:PEPeer
Get the reserved pieces for piece picking by this peer- Specified by:
getReservedPieceNumbers
in interfacePEPeer
-
addReservedPieceNumber
public void addReservedPieceNumber(int piece_number)
Description copied from interface:PEPeer
adds the reserved piece for piece picking by this peer- Specified by:
addReservedPieceNumber
in interfacePEPeer
-
removeReservedPieceNumber
public void removeReservedPieceNumber(int piece_number)
- Specified by:
removeReservedPieceNumber
in interfacePEPeer
-
getIncomingRequestCount
public int getIncomingRequestCount()
- Specified by:
getIncomingRequestCount
in interfacePEPeer
-
getOutgoingRequestCount
public int getOutgoingRequestCount()
- Specified by:
getOutgoingRequestCount
in interfacePEPeer
-
isStalledPendingLoad
public boolean isStalledPendingLoad()
Description copied from interface:PEPeerTransport
is peer waiting for a disk read with no network writes queued- Specified by:
isStalledPendingLoad
in interfacePEPeerTransport
- Returns:
-
getIncomingRequestedPieceNumbers
public int[] getIncomingRequestedPieceNumbers()
Description copied from interface:PEPeer
get a list of piece numbers the peer has requested- Specified by:
getIncomingRequestedPieceNumbers
in interfacePEPeer
- Returns:
- list of Long() representing the piece number requested, in order
-
getIncomingRequestedPieceNumberCount
public int getIncomingRequestedPieceNumberCount()
- Specified by:
getIncomingRequestedPieceNumberCount
in interfacePEPeerTransport
-
getRecentPiecesSent
public DiskManagerReadRequest[] getRecentPiecesSent()
- Specified by:
getRecentPiecesSent
in interfacePEPeer
-
getOutgoingRequestedPieceNumbers
public int[] getOutgoingRequestedPieceNumbers()
Description copied from interface:PEPeer
get a list of piece numbers the we have requested from peer- Specified by:
getOutgoingRequestedPieceNumbers
in interfacePEPeer
- Returns:
- list of Long() representing the piece number requested, oldest to newest
-
getPercentDoneOfCurrentIncomingRequest
public int getPercentDoneOfCurrentIncomingRequest()
- Specified by:
getPercentDoneOfCurrentIncomingRequest
in interfacePEPeer
-
getPercentDoneOfCurrentOutgoingRequest
public int getPercentDoneOfCurrentOutgoingRequest()
- Specified by:
getPercentDoneOfCurrentOutgoingRequest
in interfacePEPeer
-
getLastMessageSentTime
public long getLastMessageSentTime()
- Specified by:
getLastMessageSentTime
in interfacePEPeerTransport
-
getRelationText
public java.lang.String getRelationText()
Description copied from class:LogRelation
A short description of what your class holds that can be printed by the logger- Overrides:
getRelationText
in classLogRelation
- Returns:
-
getQueryableInterfaces
public java.lang.Object[] getQueryableInterfaces()
Description copied from class:LogRelation
Query this class for a reference to another class that it may hold- Overrides:
getQueryableInterfaces
in classLogRelation
- Returns:
- If found, the class desired. Otherwise, null.
-
getLastPiece
public int getLastPiece()
- Specified by:
getLastPiece
in interfacePEPeer
-
setLastPiece
public void setLastPiece(int pieceNumber)
- Specified by:
setLastPiece
in interfacePEPeer
-
isLANLocal
public boolean isLANLocal()
Description copied from interface:PEPeerTransport
Is the connection within the local LAN network.- Specified by:
isLANLocal
in interfacePEPeer
- Specified by:
isLANLocal
in interfacePEPeerTransport
- Returns:
- true if within LAN, false of outside the LAN segment
-
resetLANLocalStatus
public void resetLANLocalStatus()
- Specified by:
resetLANLocalStatus
in interfacePEPeer
-
isTCP
public boolean isTCP()
- Specified by:
isTCP
in interfacePEPeerTransport
-
getNetwork
public java.lang.String getNetwork()
- Specified by:
getNetwork
in interfacePEPeerTransport
-
setUploadRateLimitBytesPerSecond
public void setUploadRateLimitBytesPerSecond(int bytes)
- Specified by:
setUploadRateLimitBytesPerSecond
in interfacePEPeer
-
getUploadRateLimitBytesPerSecond
public int getUploadRateLimitBytesPerSecond()
- Specified by:
getUploadRateLimitBytesPerSecond
in interfacePEPeer
-
setDownloadRateLimitBytesPerSecond
public void setDownloadRateLimitBytesPerSecond(int bytes)
- Specified by:
setDownloadRateLimitBytesPerSecond
in interfacePEPeer
-
getDownloadRateLimitBytesPerSecond
public int getDownloadRateLimitBytesPerSecond()
- Specified by:
getDownloadRateLimitBytesPerSecond
in interfacePEPeer
-
getClientNameFromPeerID
public java.lang.String getClientNameFromPeerID()
- Specified by:
getClientNameFromPeerID
in interfacePEPeer
-
getClientNameFromExtensionHandshake
public java.lang.String getClientNameFromExtensionHandshake()
- Specified by:
getClientNameFromExtensionHandshake
in interfacePEPeer
-
getDHTProvider
private static MainlineDHTProvider getDHTProvider()
-
setPriorityConnection
public void setPriorityConnection(boolean is_priority)
- Specified by:
setPriorityConnection
in interfacePEPeer
-
isPriorityConnection
public boolean isPriorityConnection()
- Specified by:
isPriorityConnection
in interfacePEPeer
-
generateFastSet
protected java.util.List<java.lang.Integer> generateFastSet(byte[] hash, java.lang.String ip, int num_pieces, int num_required)
-
generateFastSet
protected java.util.List<java.lang.Integer> generateFastSet(int num)
-
getTaggableType
public int getTaggableType()
- Specified by:
getTaggableType
in interfaceTaggable
-
getTaggableID
public java.lang.String getTaggableID()
- Specified by:
getTaggableID
in interfaceTaggable
-
getTaggableName
public java.lang.String getTaggableName()
- Specified by:
getTaggableName
in interfaceTaggable
-
getTaggableResolver
public TaggableResolver getTaggableResolver()
- Specified by:
getTaggableResolver
in interfaceTaggable
-
getTaggableTransientProperty
public java.lang.Object getTaggableTransientProperty(java.lang.String key)
- Specified by:
getTaggableTransientProperty
in interfaceTaggable
-
setTaggableTransientProperty
public void setTaggableTransientProperty(java.lang.String key, java.lang.Object value)
- Specified by:
setTaggableTransientProperty
in interfaceTaggable
-
generateEvidence
public void generateEvidence(IndentWriter writer)
- Specified by:
generateEvidence
in interfacePEPeerTransport
-
-