Class PEPeerControlImpl
java.lang.Object
com.biglybt.core.logging.LogRelation
com.biglybt.core.peer.impl.control.PEPeerControlImpl
- All Implemented Interfaces:
DiskManagerCheckRequestListener
,DiskManagerWriteRequestListener
,IPFilterListener
,PEPeerControl
,PEPeerManager
,PeerControlInstance
,PeerNATInitiator
public class PEPeerControlImpl
extends LogRelation
implements PEPeerControl, DiskManagerWriteRequestListener, PeerControlInstance, PeerNATInitiator, DiskManagerCheckRequestListener, IPFilterListener
manages all peer transports for a torrent
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
private class
(package private) static interface
(package private) static class
(package private) static class
(package private) static class
Nested classes/interfaces inherited from interface com.biglybt.core.disk.DiskManagerCheckRequestListener
DiskManagerCheckRequestListener.HashListener
Nested classes/interfaces inherited from interface com.biglybt.core.peer.PEPeerManager
PEPeerManager.StatsReceiver
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Average
private PeerIdentityDataID
private final byte[]
private final int
private int
private int
private int
private int
private int
private PEPeerManagerStatsImpl
private int
private int
private int
private long
private long
private long
private long
private long
protected final PEPeerManagerAdapter
private boolean
private int
private static int
private static float
private int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final Object
private final Map
<PEPeerControlImpl.PeerCacheKey, Long> private static final int
private int
private int
private int
private int
private final DiskManager
private final DiskManagerPiece[]
private boolean
private final LimitedRateGroup
private static int
private static final Object
private static final Object
private static boolean
private static boolean
private static final int
private static boolean
private static boolean
private boolean
private static boolean
private final PEPeerControlHashHandler
private int
private BloomFilter
private static final int
private static final IpFilter
private long
private boolean
private final boolean
private final boolean
private boolean
private long
private long
private long
private long
private long
private long
private long
private Boolean
private static final LogIDs
private static final int
private static final int
private long
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private int
private final PEPeerControlImpl.MyPeer
private final BloomFilter
private long
private int
private int
private static final NetworkAdmin
private int
private int
private int[]
private boolean[][]
private static final int
private int[]
private int
private final Map
<PEPeerControlImpl.PeerCacheKey, Integer> private static final int
private int
private final int
private final PeerDatabase
private ArrayList
<PEPeerManagerListener> private static final String
private ArrayList
<PEPeerTransport> private final AEMonitor
private static final int
private static final int
private final Map
<String, PEPeerTransport> private final PEPieceImpl[]
private final AEMonitor
private final PiecePicker
private final int
private boolean
private BloomFilter
private static final int
private static boolean
private static final int
private static final int
private static final long
private static final long
private static final long
private long
private static final long
private boolean
private static final int
private boolean
literally seeding as in 100% torrent completeprivate static int
private PEPeerManager.StatsReceiver
private int
private boolean
private int
private int
private SuperSeedPiece[]
private List
<PEPeerTransport> private static final boolean
private final AEMonitor
private final TOTorrent
private static boolean
private static boolean
private static boolean
private static final int
private static final int
private final Map
<String, PEPeerTransport> private int
private Unchoker
private boolean
private final UploadHelper
private final LimitedRateGroup
private static final AtomicInteger
private static final int
Fields inherited from interface com.biglybt.core.peer.impl.PEPeerControl
SNUB_MILLIS
-
Constructor Summary
ConstructorsConstructorDescriptionPEPeerControlImpl
(byte[] _peer_id, PEPeerManagerAdapter _adapter, DiskManager _diskManager, int _partition_id) -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
private void
addExtendedPeersFromTracker
(Map extensions) private void
addFastUnchokes
(ArrayList peers_to_unchoke) void
void
void
Add a new peer, using the default internal PEPeer implementation (like for peers given in announce reply), using the given address and port.private void
void
addPeerTransport
(PEPeerTransport transport) protected void
void
Don't pass a null to this method.void
addRateLimiter
(LimitedRateGroup group, boolean upload) private void
private int
addWarning
(String ip, PEPeerTransport peer) private void
analyseTrackerResponse
(TRTrackerAnnouncerResponse tracker_response) A private method that does analysis of the result sent by the tracker.private void
badPeerDetected
(String ip, int piece_number, String reason) void
badPieceReported
(PEPeerTransport originator, int piece_number) boolean
canIPBeBanned
(String ip) boolean
canIPBeBlocked
(String ip, byte[] torrent_hash) boolean
private void
private void
checkAutoSequentialFiles
(DiskManagerFileInfo done_file) private void
void
checkCancelled
(DiskManagerCheckRequest request) void
checkCompleted
(DiskManagerCheckRequest request, boolean passed) private void
A private method that checks if PEPieces being downloaded are finished If all blocks from a PEPiece are written to disk, this method will queue the piece for hash check.protected void
private boolean
checkEmptyPiece
(int pieceNumber) Checks given piece to see if it's active but empty, and if so deactivates it.void
checkFailed
(DiskManagerCheckRequest request, Throwable cause) private void
checkFinished
(boolean start_of_day) This method checks if the downloading process is finished.private void
private void
private void
This method will locate expired requests on peers, will cancel them, and mark the peer as snubbed if we haven't received useful data from them within the last 60 secondsprivate void
private void
void
checkSnubbing
(PEPeerTransport peer) private void
Check if a piece's Speed is too fast for it to be getting new data and if a reserved pieced failed to get data within 120 secondsprivate void
closeAndRemoveAllPeers
(String reason, int reason_code, boolean reconnect) private void
closeAndRemovePeer
(PEPeerTransport peer, String reason, int reason_code, boolean log_if_not_found) private byte[]
computeMd5Hash
(DirectByteBuffer buffer) createDiskManagerRequest
(int pieceNumber, int offset, int length) createPeerExchangeConnection
(PEPeerTransport base_peer) Register a peer connection for peer exchange handling.createPeerStats
(PEPeer owner) void
dataBytesReceived
(PEPeer peer, int length) Data bytes received.void
dataBytesSent
(PEPeer peer, int length) Data bytes sent.void
void
private boolean
private void
boolean
doOptimisticDisconnect
(boolean pending_lan_local_peer, boolean force, String network) private void
doTCPConnectionChecks
(int number) private void
doUDPConnectionChecks
(int number) private void
Do all peer choke/unchoke processing.void
generateEvidence
(IndentWriter writer) int[]
int
getAvailability
(int pieceNumber) long
int
Get the average completion percentage of connected peers.float
int
long
getConnectHealth
(boolean verbose) int
getConnectTimeout
(int ct_def) To retreive arbitrary objects against this object.Get the limited rate group used for download limiting.int
int
long
getETA
(boolean smoothed) Returns the ETA time in seconds.int
byte[]
getHash()
long
int
long
int
getMaxCompletionInThousandNotation
(boolean never_include_seeds) Max completion of connected peers (doesn't factor in our completion)int[]
private int
getMaxConnections
(String net) private int[]
returns number of whatever peers to connect and then extra ones that must be non-pub if availableint
getMaxNewConnectionsAllowed
(String network) returns the allowed connections for the given network -1 -> unlimitedint[]
private int
float
float
getMinAvailability
(int file_index) getName()
int
int
int
int
int
int
int
int
int
int
int
int
int
int
int[]
byte[]
getPeers()
int
getPendingPeers
(String address) getPiece
(int pieceNumber) int[]
int
getPieceLength
(int pieceNumber) PEPiece[]
Often better to use getPiece(pieceNumber)boolean
Object[]
Query this class for a reference to another class that it may holdA short description of what your class holds that can be printed by the loggerlong
int
byte[][]
getSecrets
(int crypto_level) getStats()
byte[]
Get torrent hash including any overridesint
long
getTimeStarted
(boolean mono) long
getTimeStartedSeeding
(boolean mono) protected byte[]
int
Locate an existing transport via [IP] Address.getTransportFromIdentity
(byte[] peer_id) Locate an existing transport via peer id byte identity.int
getUID()
Get the limited rate group used for upload limiting.int
int
void
handleCloseReason
(PEPeerTransport peer, boolean reason_outgoing, int reason) private void
boolean
boolean
hashRequest
(int piece_number, DiskManagerCheckRequestListener.HashListener listener) boolean
void
void
void
informFullyConnected
(PEPeer peer) private void
private void
void
void
IPBlockedListChanged
(IpFilter filter) void
IPFilterEnabledChanged
(boolean is_enabled) private boolean
isAlreadyConnected
(PeerItem peer_id) private boolean
isBlocked
(PEPeerTransport peer, String name, byte[] hash) boolean
boolean
isFastExtensionPermitted
(PEPeerTransport originator) boolean
isHolePunchOperationOK
(PEPeerTransport peer, boolean is_connect) boolean
Are we in end-game mode?boolean
boolean
isNetworkEnabled
(String net) boolean
boolean
isPeerSourceEnabled
(String peer_source) boolean
boolean
isRTA()
boolean
boolean
private boolean
boolean
isWritten
(int piece_number, int offset) private String
makeNewOutgoingConnection
(String peer_source, String address, int tcp_port, int udp_port, boolean use_tcp, boolean require_crypto, byte crypto_level, Map user_data) Request a new outgoing peer connection.private void
MD5CheckPiece
(PEPiece piece, boolean correct) boolean
needsMD5CheckOnCompletion
(int pieceNumber) private void
void
peerConnectionClosed
(PEPeerTransport peer, boolean connect_failed, boolean network_failed) Notify the manager that the given peer connection has been closed.void
peerDiscovered
(PEPeerTransport finder, PeerItem pi) void
peerDiscovered
(String peer_source, String ip_address, int tcp_port, int udp_port, boolean use_crypto) private void
void
Notify that the given peer connection represents our own client.private void
processPieceCheckResult
(DiskManagerCheckRequest request, int outcome) private void
Private method to process the results given by DiskManager's piece checking thread via asyncPieceChecked(..)void
void
protocolBytesReceived
(PEPeer peer, int length) Protocol bytes received.void
protocolBytesSent
(PEPeer peer, int length) Protocol bytes sent.void
removeAllPeers
(String reason, int reason_code) void
void
removePeer
(PEPeer _transport, String reason, int reason_code) void
removePiece
(PEPiece pePiece, int pieceNumber) Sends messages to listeners that the piece is no longer active.void
removeRateLimiter
(LimitedRateGroup group, boolean upload) void
reportBadFastExtensionUse
(PEPeerTransport originator) void
requestAdded
(PEPiece piece, PEPeerTransport peer, DiskManagerReadRequest request) void
requestCanceled
(DiskManagerReadRequest request) The way to unmark a request as being downloaded, or also called by Peer connections objects when connection is closed or chokedboolean
requestExists
(String peer_ip, int piece_number, int offset, int length) void
schedule()
boolean
private void
sendHave
(int pieceNumber) void
To store arbitrary objects against a control.void
void
setNbPeersSnubbed
(int n) void
setPreferUDP
(boolean prefer) void
setStatsReceiver
(PEPeerManager.StatsReceiver receiver) void
setSuperSeedMode
(boolean _superSeedMode) void
setTorrentInfoDictSize
(int size) void
start()
void
statsReply
(PEPeerTransport originator, Map reply) void
statsRequest
(PEPeerTransport originator, Map request) void
stopAll()
private void
private void
private void
void
updateSuperSeedPiece
(PEPeer peer, int pieceNumber) private void
boolean
validateHintRequest
(PEPeerTransport originator, int pieceNumber, int offset, int length) boolean
validatePieceReply
(PEPeerTransport originator, int pieceNumber, int offset, DirectByteBuffer data) boolean
validateReadRequest
(PEPeerTransport originator, int pieceNumber, int offset, int length) void
writeBlock
(int pieceNumber, int offset, DirectByteBuffer data, Object sender, boolean cancel) This method will queue up a dism manager write request for the block if the block is not already written.void
writeCompleted
(DiskManagerWriteRequest request) DiskManagerWriteRequestListener messagevoid
writeFailed
(DiskManagerWriteRequest request, Throwable cause) Methods inherited from class com.biglybt.core.logging.LogRelation
propogatedRelationText, queryForClass
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.biglybt.core.disk.DiskManagerCheckRequestListener
isFailureInteresting
Methods inherited from interface com.biglybt.core.ipfilter.IPFilterListener
IPBanListChanged
Methods inherited from interface com.biglybt.core.peer.PEPeerManager
removePeer
-
Field Details
-
LOGID
-
TEST_PERIODIC_SEEDING_SCAN_FAIL_HANDLING
private static final boolean TEST_PERIODIC_SEEDING_SCAN_FAIL_HANDLING- See Also:
-
WARNINGS_LIMIT
private static final int WARNINGS_LIMIT- See Also:
-
CHECK_REASON_DOWNLOADED
private static final int CHECK_REASON_DOWNLOADED- See Also:
-
CHECK_REASON_COMPLETE
private static final int CHECK_REASON_COMPLETE- See Also:
-
CHECK_REASON_SCAN
private static final int CHECK_REASON_SCAN- See Also:
-
CHECK_REASON_SEEDING_CHECK
private static final int CHECK_REASON_SEEDING_CHECK- See Also:
-
CHECK_REASON_BAD_PIECE_CHECK
private static final int CHECK_REASON_BAD_PIECE_CHECK- See Also:
-
SEED_CHECK_WAIT_MARKER
private static final int SEED_CHECK_WAIT_MARKER- See Also:
-
REQ_TIMEOUT_DATA_AGE_SEED_MILLIS
private static final long REQ_TIMEOUT_DATA_AGE_SEED_MILLIS- See Also:
-
REQ_TIMEOUT_DATA_AGE_LEECH_MILLIS
private static final long REQ_TIMEOUT_DATA_AGE_LEECH_MILLIS- See Also:
-
REQ_TIMEOUT_OLDEST_REQ_AGE_MILLIS
private static final long REQ_TIMEOUT_OLDEST_REQ_AGE_MILLIS- See Also:
-
RESERVED_PIECE_TIMEOUT_MILLIS
private static final long RESERVED_PIECE_TIMEOUT_MILLIS- See Also:
-
CON_HEALTH_DONE_KEY
-
DUP_PEER_CC_KEY
-
DUP_PEER_AS_KEY
-
global_disconnect_seeds_when_seeding
private static boolean global_disconnect_seeds_when_seeding -
enable_seeding_piece_rechecks
private static boolean enable_seeding_piece_rechecks -
stalled_piece_timeout
private static int stalled_piece_timeout -
fast_unchoke_new_peers
private static boolean fast_unchoke_new_peers -
ban_peer_discard_ratio
private static float ban_peer_discard_ratio -
ban_peer_discard_min_kb
private static int ban_peer_discard_min_kb -
udp_fallback_for_failed_connection
private static boolean udp_fallback_for_failed_connection -
udp_fallback_for_dropped_connection
private static boolean udp_fallback_for_dropped_connection -
udp_probe_enabled
private static boolean udp_probe_enabled -
global_hide_a_piece
private static boolean global_hide_a_piece -
global_hide_a_piece_ds
private static boolean global_hide_a_piece_ds -
prefer_udp_default
private static boolean prefer_udp_default -
dual_ipv4_ipv6_connection_action
private static int dual_ipv4_ipv6_connection_action -
auto_sequential_file_exts
-
network_admin
-
ip_filter
-
UUID_GEN
-
pm_uuid
private final int pm_uuid -
is_running
private volatile boolean is_running -
is_destroyed
private volatile boolean is_destroyed -
peer_transports_cow
-
peer_transports_mon
-
adapter
-
torrent
-
disk_mgr
-
dm_pieces
-
is_private_torrent
private final boolean is_private_torrent -
stats_receiver
-
piecePicker
-
lastNeededUndonePieceChange
private long lastNeededUndonePieceChange -
seeding_mode
private boolean seeding_modeliterally seeding as in 100% torrent complete -
restart_initiated
private boolean restart_initiated -
_nbPieces
private final int _nbPieces -
pePieces
-
nbPiecesActive
private int nbPiecesActive -
nbBytesRemaining
private long nbBytesRemaining -
nbPeersSnubbed
private int nbPeersSnubbed -
_hash
-
_myPeerId
private final byte[] _myPeerId -
_stats
-
hash_handler
-
stats_tick_count
private int stats_tick_count -
_seeds
private int _seeds -
_peers
private int _peers -
_remotesTCPNoLan
private int _remotesTCPNoLan -
_remotesUDPNoLan
private int _remotesUDPNoLan -
_remotesUTPNoLan
private int _remotesUTPNoLan -
_tcp_peers_transfering
private int _tcp_peers_transfering -
_tcpPendingConnections
private int _tcpPendingConnections -
_tcpConnectingConnections
private int _tcpConnectingConnections -
last_remote_time
private long last_remote_time -
_timeStarted
private long _timeStarted -
_timeStarted_mono
private long _timeStarted_mono -
_timeStartedSeeding
private long _timeStartedSeeding -
_timeStartedSeeding_mono
private long _timeStartedSeeding_mono -
_timeFinished_mono
private long _timeFinished_mono -
_averageReceptionSpeed
-
mainloop_loop_count
private long mainloop_loop_count -
MAINLOOP_ONE_SECOND_INTERVAL
private static final int MAINLOOP_ONE_SECOND_INTERVAL -
MAINLOOP_FIVE_SECOND_INTERVAL
private static final int MAINLOOP_FIVE_SECOND_INTERVAL -
MAINLOOP_TEN_SECOND_INTERVAL
private static final int MAINLOOP_TEN_SECOND_INTERVAL -
MAINLOOP_TWENTY_SECOND_INTERVAL
private static final int MAINLOOP_TWENTY_SECOND_INTERVAL -
MAINLOOP_THIRTY_SECOND_INTERVAL
private static final int MAINLOOP_THIRTY_SECOND_INTERVAL -
MAINLOOP_SIXTY_SECOND_INTERVAL
private static final int MAINLOOP_SIXTY_SECOND_INTERVAL -
MAINLOOP_FIVE_MINUTE_INTERVAL
private static final int MAINLOOP_FIVE_MINUTE_INTERVAL -
MAINLOOP_TEN_MINUTE_INTERVAL
private static final int MAINLOOP_TEN_MINUTE_INTERVAL -
peer_manager_listeners_cow
-
piece_check_result_list
-
piece_check_result_list_mon
-
superSeedMode
private boolean superSeedMode -
superSeedModeCurrentPiece
private int superSeedModeCurrentPiece -
superSeedModeNumberOfAnnounces
private int superSeedModeNumberOfAnnounces -
superSeedPieces
-
global_hide_a_piece_cached
private boolean global_hide_a_piece_cached -
local_hide_a_piece_opt
-
OB_PS_STATS_HISTORY_SIZE
private static final int OB_PS_STATS_HISTORY_SIZE- See Also:
-
ob_ps_stats_history
private boolean[][] ob_ps_stats_history -
ob_ps_stats
private int[] ob_ps_stats -
ob_ps_stats_pos
private int[] ob_ps_stats_pos -
this_mon
-
ip_filter_last_update_time
private long ip_filter_last_update_time -
user_data
-
unchoker
-
external_rate_limiters_cow
-
bytes_queued_for_upload
private int bytes_queued_for_upload -
connections_with_queued_data
private int connections_with_queued_data -
connections_with_queued_data_blocked
private int connections_with_queued_data_blocked -
connections_unchoked
private int connections_unchoked -
connections_unchoking
private int connections_unchoking -
outbound_message_count
private int outbound_message_count -
sweepList
-
nextPEXSweepIndex
private int nextPEXSweepIndex -
upload_helper
-
peer_database
-
bad_piece_reported
private int bad_piece_reported -
next_rescan_piece
private int next_rescan_piece -
rescan_piece_time
private long rescan_piece_time -
last_eta
private long last_eta -
last_eta_smoothed
private long last_eta_smoothed -
last_eta_calculation
private long last_eta_calculation -
MAX_UDP_CONNECTIONS
private static final int MAX_UDP_CONNECTIONS- See Also:
-
PENDING_NAT_TRAVERSAL_MAX
private static final int PENDING_NAT_TRAVERSAL_MAX- See Also:
-
MAX_UDP_TRAVERSAL_COUNT
private static final int MAX_UDP_TRAVERSAL_COUNT- See Also:
-
PEER_NAT_TRAVERSE_DONE_KEY
-
pending_nat_traversals
-
udp_traversal_count
private int udp_traversal_count -
PENDING_HOLE_PUNCH_MAX
private static final int PENDING_HOLE_PUNCH_MAX- See Also:
-
pending_hole_punches
-
OUTBOUND_IGNORE_ADDRESSES_MAX
private static final int OUTBOUND_IGNORE_ADDRESSES_MAX- See Also:
-
outbound_ignore_addresses
-
RECONNECT_SEEDING_MIN
private static final int RECONNECT_SEEDING_MIN- See Also:
-
RECONNECT_DOWNLOADING_MIN
private static final int RECONNECT_DOWNLOADING_MIN- See Also:
-
CONNECT_FAIL_HISTORY_MAX
private static final int CONNECT_FAIL_HISTORY_MAX- See Also:
-
connect_fail_history
-
UDP_RECONNECT_MAX
private static final int UDP_RECONNECT_MAX- See Also:
-
udp_reconnects
-
UDP_RECONNECT_MIN_MILLIS
private static final int UDP_RECONNECT_MIN_MILLIS- See Also:
-
last_udp_reconnect_mono
private long last_udp_reconnect_mono -
prefer_udp
private boolean prefer_udp -
PREFER_UDP_BLOOM_SIZE
private static final int PREFER_UDP_BLOOM_SIZE- See Also:
-
prefer_udp_bloom
-
upload_diabled
private volatile boolean upload_diabled -
download_diabled
private volatile boolean download_diabled -
upload_limited_rate_group
-
download_limited_rate_group
-
partition_id
private final int partition_id -
is_metadata_download
private final boolean is_metadata_download -
metadata_infodict_size
private int metadata_infodict_size -
finish_in_progress
-
last_seed_disconnect_time
private long last_seed_disconnect_time -
naughty_fast_extension_bloom
-
asfe_activated
private volatile boolean asfe_activated -
my_peer
-
HP_BLOOM_FILTER_SIZE
private static final int HP_BLOOM_FILTER_SIZE- See Also:
-
hp_bloom
-
FE_EVENT_LIMIT
private static final int FE_EVENT_LIMIT- See Also:
-
optimisticDisconnectCount
private int optimisticDisconnectCount
-
-
Constructor Details
-
PEPeerControlImpl
public PEPeerControlImpl(byte[] _peer_id, PEPeerManagerAdapter _adapter, DiskManager _diskManager, int _partition_id)
-
-
Method Details
-
getUID
public int getUID()- Specified by:
getUID
in interfacePEPeerManager
-
start
public void start()- Specified by:
start
in interfacePEPeerManager
-
stopAll
public void stopAll()- Specified by:
stopAll
in interfacePEPeerManager
-
removeAllPeers
- Specified by:
removeAllPeers
in interfacePEPeerManager
-
getPartitionID
public int getPartitionID()- Specified by:
getPartitionID
in interfacePEPeerManager
-
getTCPListeningPortNumber
public int getTCPListeningPortNumber()- Specified by:
getTCPListeningPortNumber
in interfacePEPeerControl
-
getTargetHash
public byte[] getTargetHash()Description copied from interface:PEPeerControl
Get torrent hash including any overrides- Specified by:
getTargetHash
in interfacePEPeerControl
- Returns:
-
isDestroyed
public boolean isDestroyed()- Specified by:
isDestroyed
in interfacePEPeerManager
-
getDiskManager
- Specified by:
getDiskManager
in interfacePEPeerManager
-
getPiecePicker
- Specified by:
getPiecePicker
in interfacePEPeerManager
-
getAdapter
- Specified by:
getAdapter
in interfacePEPeerManager
-
getDisplayName
- Specified by:
getDisplayName
in interfacePeerNATInitiator
- Specified by:
getDisplayName
in interfacePEPeerManager
-
getName
- Specified by:
getName
in interfacePeerControlInstance
-
schedule
public void schedule()- Specified by:
schedule
in interfacePeerControlInstance
-
analyseTrackerResponse
A private method that does analysis of the result sent by the tracker. It will mainly open new connections with peers provided and set the timeToWait variable according to the tracker response.- Parameters:
tracker_response
-
-
processTrackerResponse
- Specified by:
processTrackerResponse
in interfacePEPeerManager
-
addExtendedPeersFromTracker
-
getMyPeer
- Specified by:
getMyPeer
in interfacePEPeerManager
-
getPeers
- Specified by:
getPeers
in interfacePEPeerManager
-
getPeers
- Specified by:
getPeers
in interfacePEPeerManager
-
getPendingPeerCount
public int getPendingPeerCount()- Specified by:
getPendingPeerCount
in interfacePEPeerManager
-
getPendingPeers
- Specified by:
getPendingPeers
in interfacePEPeerManager
-
getPendingPeers
- Specified by:
getPendingPeers
in interfacePEPeerManager
-
addPeer
- Specified by:
addPeer
in interfacePEPeerManager
-
getTorrentHash
protected byte[] getTorrentHash() -
removePeer
- Specified by:
removePeer
in interfacePEPeerManager
-
closeAndRemovePeer
private void closeAndRemovePeer(PEPeerTransport peer, String reason, int reason_code, boolean log_if_not_found) -
closeAndRemoveAllPeers
-
addPeer
public void addPeer(String ip_address, int tcp_port, int udp_port, boolean use_crypto, Map user_data) throws Exception Description copied from interface:PEPeerManager
Add a new peer, using the default internal PEPeer implementation (like for peers given in announce reply), using the given address and port.- Specified by:
addPeer
in interfacePEPeerManager
- Parameters:
ip_address
- of peer to injecttcp_port
- of peer to injectudp_port
- of peer to inject (0 if unknown)use_crypto
- use encrypted transport- Throws:
Exception
-
peerDiscovered
public void peerDiscovered(String peer_source, String ip_address, int tcp_port, int udp_port, boolean use_crypto) - Specified by:
peerDiscovered
in interfacePEPeerManager
-
addPeersFromTracker
-
makeNewOutgoingConnection
private String makeNewOutgoingConnection(String peer_source, String address, int tcp_port, int udp_port, boolean use_tcp, boolean require_crypto, byte crypto_level, Map user_data) Request a new outgoing peer connection.- Parameters:
address
- ip of remote peerport
- remote peer listen port- Returns:
- null if the connection was added to the transport list, reason if rejected
-
checkCompletedPieces
private void checkCompletedPieces()A private method that checks if PEPieces being downloaded are finished If all blocks from a PEPiece are written to disk, this method will queue the piece for hash check. Elsewhere, if it passes sha-1 check, it will be marked as downloaded, otherwise, it will unmark it as fully downloaded, so blocks can be retreived again. -
hashRequest
- Specified by:
hashRequest
in interfaceDiskManagerCheckRequestListener
-
checkEmptyPiece
private boolean checkEmptyPiece(int pieceNumber) Checks given piece to see if it's active but empty, and if so deactivates it.- Parameters:
pieceNumber
- to check- Returns:
- true if the piece was removed and is no longer active (pePiece ==null)
-
checkSpeedAndReserved
private void checkSpeedAndReserved()Check if a piece's Speed is too fast for it to be getting new data and if a reserved pieced failed to get data within 120 seconds -
check99PercentBug
private void check99PercentBug() -
checkInterested
private void checkInterested() -
processPieceChecks
private void processPieceChecks()Private method to process the results given by DiskManager's piece checking thread via asyncPieceChecked(..) -
checkBadPieces
private void checkBadPieces() -
checkRescan
private void checkRescan() -
badPieceReported
- Specified by:
badPieceReported
in interfacePEPeerControl
-
isFastExtensionPermitted
- Specified by:
isFastExtensionPermitted
in interfacePEPeerControl
-
reportBadFastExtensionUse
- Specified by:
reportBadFastExtensionUse
in interfacePEPeerControl
-
setStatsReceiver
- Specified by:
setStatsReceiver
in interfacePEPeerManager
-
statsRequest
- Specified by:
statsRequest
in interfacePEPeerControl
-
statsReply
- Specified by:
statsReply
in interfacePEPeerControl
-
checkFinished
private void checkFinished(boolean start_of_day) This method checks if the downloading process is finished. -
checkCompletionState
protected void checkCompletionState() -
checkRequests
private void checkRequests()This method will locate expired requests on peers, will cancel them, and mark the peer as snubbed if we haven't received useful data from them within the last 60 seconds -
checkSnubbing
- Specified by:
checkSnubbing
in interfacePEPeerControl
-
updateTrackerAnnounceInterval
private void updateTrackerAnnounceInterval() -
hasDownloadablePiece
public boolean hasDownloadablePiece()- Specified by:
hasDownloadablePiece
in interfacePEPeerManager
-
getBytesQueuedForUpload
public int getBytesQueuedForUpload()- Specified by:
getBytesQueuedForUpload
in interfacePEPeerManager
-
getNbPeersWithUploadQueued
public int getNbPeersWithUploadQueued()- Specified by:
getNbPeersWithUploadQueued
in interfacePEPeerManager
-
getNbPeersWithUploadBlocked
public int getNbPeersWithUploadBlocked()- Specified by:
getNbPeersWithUploadBlocked
in interfacePEPeerManager
-
getNbPeersUnchoked
public int getNbPeersUnchoked()- Specified by:
getNbPeersUnchoked
in interfacePEPeerManager
-
getNbPeersUnchoking
public int getNbPeersUnchoking()- Specified by:
getNbPeersUnchoking
in interfacePEPeerManager
-
getAvailability
public int[] getAvailability()- Specified by:
getAvailability
in interfacePEPeerManager
-
getMinAvailability
public float getMinAvailability()- Specified by:
getMinAvailability
in interfacePEPeerManager
-
getMinAvailability
public float getMinAvailability(int file_index) - Specified by:
getMinAvailability
in interfacePEPeerManager
-
getAvgAvail
public float getAvgAvail()- Specified by:
getAvgAvail
in interfacePEPeerManager
-
getAvailWentBadTime
public long getAvailWentBadTime()- Specified by:
getAvailWentBadTime
in interfacePEPeerManager
- Returns:
- 0: hasn't transitioned from good to bad this session OR known to be good; >0: time availability went from good to bad
-
addPeerTransport
- Specified by:
addPeerTransport
in interfacePEPeerControl
-
doUnchokes
private void doUnchokes()Do all peer choke/unchoke processing. -
addFastUnchokes
-
sendHave
private void sendHave(int pieceNumber) -
checkSeeds
private void checkSeeds() -
isUploadOnly
private boolean isUploadOnly() -
updateStats
private void updateStats() -
requestCanceled
The way to unmark a request as being downloaded, or also called by Peer connections objects when connection is closed or choked- Specified by:
requestCanceled
in interfacePEPeerManager
- Parameters:
request
- a DiskManagerReadRequest holding details of what was canceled
-
requestAdded
- Specified by:
requestAdded
in interfacePEPeerControl
-
getControl
-
getSecrets
public byte[][] getSecrets(int crypto_level) - Specified by:
getSecrets
in interfacePEPeerControl
-
getHash
public byte[] getHash()- Specified by:
getHash
in interfacePEPeerManager
-
getPeerIdentityDataID
- Specified by:
getPeerIdentityDataID
in interfacePEPeerManager
-
getPeerId
public byte[] getPeerId()- Specified by:
getPeerId
in interfacePEPeerManager
-
getRemaining
public long getRemaining()- Specified by:
getRemaining
in interfacePEPeerManager
-
discarded
- Specified by:
discarded
in interfacePEPeerManager
-
dataBytesReceived
Description copied from interface:PEPeerManager
Data bytes received.- Specified by:
dataBytesReceived
in interfacePEPeerManager
- Parameters:
length
-
-
protocolBytesReceived
Description copied from interface:PEPeerManager
Protocol bytes received.- Specified by:
protocolBytesReceived
in interfacePEPeerManager
- Parameters:
length
-
-
dataBytesSent
Description copied from interface:PEPeerManager
Data bytes sent.- Specified by:
dataBytesSent
in interfacePEPeerManager
- Parameters:
length
-
-
protocolBytesSent
Description copied from interface:PEPeerManager
Protocol bytes sent.- Specified by:
protocolBytesSent
in interfacePEPeerManager
- Parameters:
length
-
-
writeCompleted
DiskManagerWriteRequestListener message- Specified by:
writeCompleted
in interfaceDiskManagerWriteRequestListener
- See Also:
-
writeFailed
- Specified by:
writeFailed
in interfaceDiskManagerWriteRequestListener
-
writeBlock
public void writeBlock(int pieceNumber, int offset, DirectByteBuffer data, Object sender, boolean cancel) This method will queue up a dism manager write request for the block if the block is not already written. It will send out cancels for the block to all peer either if in end-game mode, or per cancel param- Specified by:
writeBlock
in interfacePEPeerManager
- Parameters:
pieceNumber
- to potentially write tooffset
- within piece to queue write fordata
- to be writtensender
- peer that sent this datacancel
- if cancels definitely need to be sent to all peers for this request
-
isWritten
public boolean isWritten(int piece_number, int offset) - Specified by:
isWritten
in interfacePEPeerManager
-
validateReadRequest
public boolean validateReadRequest(PEPeerTransport originator, int pieceNumber, int offset, int length) - Specified by:
validateReadRequest
in interfacePEPeerControl
-
validateHintRequest
public boolean validateHintRequest(PEPeerTransport originator, int pieceNumber, int offset, int length) - Specified by:
validateHintRequest
in interfacePEPeerControl
-
validatePieceReply
public boolean validatePieceReply(PEPeerTransport originator, int pieceNumber, int offset, DirectByteBuffer data) - Specified by:
validatePieceReply
in interfacePEPeerManager
-
getAvailability
public int getAvailability(int pieceNumber) - Specified by:
getAvailability
in interfacePEPeerManager
-
havePiece
- Specified by:
havePiece
in interfacePEPeerControl
-
getPieceLength
public int getPieceLength(int pieceNumber) - Specified by:
getPieceLength
in interfacePEPeerManager
-
getNbPeers
public int getNbPeers()- Specified by:
getNbPeers
in interfacePEPeerManager
-
getNbSeeds
public int getNbSeeds()- Specified by:
getNbSeeds
in interfacePEPeerManager
-
getNbRemoteTCPConnections
public int getNbRemoteTCPConnections()- Specified by:
getNbRemoteTCPConnections
in interfacePEPeerManager
-
getNbRemoteUDPConnections
public int getNbRemoteUDPConnections()- Specified by:
getNbRemoteUDPConnections
in interfacePEPeerManager
-
getNbRemoteUTPConnections
public int getNbRemoteUTPConnections()- Specified by:
getNbRemoteUTPConnections
in interfacePEPeerManager
-
getLastRemoteConnectionTime
public long getLastRemoteConnectionTime()- Specified by:
getLastRemoteConnectionTime
in interfacePEPeerManager
-
getStats
- Specified by:
getStats
in interfacePEPeerManager
-
getNbPeersStalledPendingLoad
public int getNbPeersStalledPendingLoad()- Specified by:
getNbPeersStalledPendingLoad
in interfacePEPeerControl
-
getETA
public long getETA(boolean smoothed) Returns the ETA time in seconds. 0 = download is complete. invalid input: '<' 0 = download is complete and it took -xxx time to complete. Constants.CRAPPY_INFINITE_AS_LONG = incomplete and 0 average speed- Specified by:
getETA
in interfacePEPeerManager
-
isRTA
public boolean isRTA()- Specified by:
isRTA
in interfacePEPeerControl
-
addToPeerTransports
-
addRateLimiter
- Specified by:
addRateLimiter
in interfacePEPeerManager
-
removeRateLimiter
- Specified by:
removeRateLimiter
in interfacePEPeerManager
-
getEffectiveUploadRateLimitBytesPerSecond
public int getEffectiveUploadRateLimitBytesPerSecond()- Specified by:
getEffectiveUploadRateLimitBytesPerSecond
in interfacePEPeerManager
-
getUploadRateLimitBytesPerSecond
public int getUploadRateLimitBytesPerSecond()- Specified by:
getUploadRateLimitBytesPerSecond
in interfacePEPeerManager
-
getDownloadRateLimitBytesPerSecond
public int getDownloadRateLimitBytesPerSecond()- Specified by:
getDownloadRateLimitBytesPerSecond
in interfacePEPeerManager
-
peerConnectionClosed
public void peerConnectionClosed(PEPeerTransport peer, boolean connect_failed, boolean network_failed) Description copied from interface:PEPeerManager
Notify the manager that the given peer connection has been closed.- Specified by:
peerConnectionClosed
in interfacePEPeerManager
- Parameters:
peer
- closed
-
informFullyConnected
- Specified by:
informFullyConnected
in interfacePEPeerManager
-
updateConnectHealth
-
getConnectHealth
- Specified by:
getConnectHealth
in interfacePEPeerManager
-
peerAdded
-
peerRemoved
-
addPiece
Don't pass a null to this method. All activations of pieces must go through here.- Specified by:
addPiece
in interfacePEPeerManager
- Parameters:
piece
- PEPiece invoked; notifications of it's invocation need to be donepieceNumber
- of the PEPiece
-
addPiece
-
removePiece
Sends messages to listeners that the piece is no longer active. All closing out (deactivation) of pieces must go through here. The piece will be null upon return.- Parameters:
pePiece
- PEPiece to removepieceNumber
- int
-
getNbActivePieces
public int getNbActivePieces()- Specified by:
getNbActivePieces
in interfacePEPeerControl
-
getElapsedTime
- Specified by:
getElapsedTime
in interfacePEPeerManager
-
getTimeStarted
public long getTimeStarted(boolean mono) - Specified by:
getTimeStarted
in interfacePEPeerManager
-
getTimeStartedSeeding
public long getTimeStartedSeeding(boolean mono) - Specified by:
getTimeStartedSeeding
in interfacePEPeerManager
-
computeMd5Hash
-
MD5CheckPiece
-
checkCompleted
- Specified by:
checkCompleted
in interfaceDiskManagerCheckRequestListener
-
checkCancelled
- Specified by:
checkCancelled
in interfaceDiskManagerCheckRequestListener
-
checkFailed
- Specified by:
checkFailed
in interfaceDiskManagerCheckRequestListener
-
needsMD5CheckOnCompletion
public boolean needsMD5CheckOnCompletion(int pieceNumber) - Specified by:
needsMD5CheckOnCompletion
in interfacePEPeerManager
-
processPieceCheckResult
-
badPeerDetected
-
getNbPieces
public int getNbPieces()- Specified by:
getNbPieces
in interfacePEPeerManager
-
getPieces
Description copied from interface:PEPeerManager
Often better to use getPiece(pieceNumber)- Specified by:
getPieces
in interfacePEPeerManager
-
getPiece
- Specified by:
getPiece
in interfacePEPeerManager
- Returns:
- PEPiece or null if piece not currently active
-
createPeerStats
- Specified by:
createPeerStats
in interfacePEPeerManager
-
createDiskManagerRequest
- Specified by:
createDiskManagerRequest
in interfacePEPeerManager
-
requestExists
- Specified by:
requestExists
in interfacePEPeerManager
-
seedPieceRecheck
public boolean seedPieceRecheck()- Specified by:
seedPieceRecheck
in interfacePEPeerManager
-
addListener
- Specified by:
addListener
in interfacePEPeerManager
-
removeListener
- Specified by:
removeListener
in interfacePEPeerManager
-
checkForBannedConnections
private void checkForBannedConnections() -
isBlocked
-
addWarning
-
addBan
-
isSeeding
public boolean isSeeding()- Specified by:
isSeeding
in interfacePEPeerManager
-
isMetadataDownload
public boolean isMetadataDownload()- Specified by:
isMetadataDownload
in interfacePEPeerManager
-
getTorrentInfoDictSize
public int getTorrentInfoDictSize()- Specified by:
getTorrentInfoDictSize
in interfacePEPeerManager
-
setTorrentInfoDictSize
public void setTorrentInfoDictSize(int size) - Specified by:
setTorrentInfoDictSize
in interfacePEPeerManager
-
isInEndGameMode
public boolean isInEndGameMode()Description copied from interface:PEPeerManager
Are we in end-game mode?- Specified by:
isInEndGameMode
in interfacePEPeerManager
- Returns:
- true if in end game mode, false if not
-
isSuperSeedMode
public boolean isSuperSeedMode()- Specified by:
isSuperSeedMode
in interfacePEPeerManager
-
canToggleSuperSeedMode
public boolean canToggleSuperSeedMode()- Specified by:
canToggleSuperSeedMode
in interfacePEPeerManager
-
setSuperSeedMode
public void setSuperSeedMode(boolean _superSeedMode) - Specified by:
setSuperSeedMode
in interfacePEPeerManager
-
initialiseSuperSeedMode
private void initialiseSuperSeedMode() -
updatePeersInSuperSeedMode
private void updatePeersInSuperSeedMode() -
updateSuperSeedPiece
- Specified by:
updateSuperSeedPiece
in interfacePEPeerControl
-
isPrivateTorrent
public boolean isPrivateTorrent()- Specified by:
isPrivateTorrent
in interfacePEPeerControl
-
getExtendedMessagingMode
public int getExtendedMessagingMode()- Specified by:
getExtendedMessagingMode
in interfacePEPeerControl
-
isPeerExchangeEnabled
public boolean isPeerExchangeEnabled()- Specified by:
isPeerExchangeEnabled
in interfacePEPeerControl
-
getUploadLimitedRateGroup
Description copied from interface:PEPeerManager
Get the limited rate group used for upload limiting.- Specified by:
getUploadLimitedRateGroup
in interfacePEPeerManager
- Returns:
- upload limit group
-
getDownloadLimitedRateGroup
Description copied from interface:PEPeerManager
Get the limited rate group used for download limiting.- Specified by:
getDownloadLimitedRateGroup
in interfacePEPeerManager
- Returns:
- download limit group
-
getData
To retreive arbitrary objects against this object.- Specified by:
getData
in interfacePEPeerManager
-
setData
To store arbitrary objects against a control.- Specified by:
setData
in interfacePEPeerManager
-
getConnectTimeout
public int getConnectTimeout(int ct_def) - Specified by:
getConnectTimeout
in interfacePEPeerControl
-
doConnectionChecks
private void doConnectionChecks() -
isHolePunchOperationOK
- Specified by:
isHolePunchOperationOK
in interfacePEPeerControl
-
doTCPConnectionChecks
private void doTCPConnectionChecks(int number) -
doUDPConnectionChecks
private void doUDPConnectionChecks(int number) -
doOptimisticDisconnect
public boolean doOptimisticDisconnect(boolean pending_lan_local_peer, boolean force, String network) - Specified by:
doOptimisticDisconnect
in interfacePEPeerControl
-
createPeerExchangeConnection
Description copied from interface:PEPeerManager
Register a peer connection for peer exchange handling. NOTE: Creation could fail if the peer is not eligible for peer exchange (like if it's remote port is unknown).- Specified by:
createPeerExchangeConnection
in interfacePEPeerManager
- Parameters:
base_peer
- exchanging with- Returns:
- peer database connection item, or null if creation failed
-
isAlreadyConnected
-
peerVerifiedAsSelf
Description copied from interface:PEPeerManager
Notify that the given peer connection represents our own client.- Specified by:
peerVerifiedAsSelf
in interfacePEPeerManager
- Parameters:
self
- peer
-
IPFilterEnabledChanged
public void IPFilterEnabledChanged(boolean is_enabled) - Specified by:
IPFilterEnabledChanged
in interfaceIPFilterListener
-
canIPBeBanned
- Specified by:
canIPBeBanned
in interfaceIPFilterListener
-
canIPBeBlocked
- Specified by:
canIPBeBlocked
in interfaceIPFilterListener
-
IPBlockedListChanged
- Specified by:
IPBlockedListChanged
in interfaceIPFilterListener
-
IPBanned
- Specified by:
IPBanned
in interfaceIPFilterListener
-
disconnectSeedsWhenSeeding
private boolean disconnectSeedsWhenSeeding() -
initHiddenPiece
private void initHiddenPiece() -
setMaskDownloadCompletion
- Specified by:
setMaskDownloadCompletion
in interfacePEPeerManager
-
getHiddenBytes
public long getHiddenBytes()- Specified by:
getHiddenBytes
in interfacePEPeerManager
-
getHiddenPiece
public int getHiddenPiece()- Specified by:
getHiddenPiece
in interfacePEPeerManager
-
getUploadPriority
public int getUploadPriority()- Specified by:
getUploadPriority
in interfacePEPeerControl
-
getAverageCompletionInThousandNotation
public int getAverageCompletionInThousandNotation()Description copied from interface:PEPeerManager
Get the average completion percentage of connected peers.- Specified by:
getAverageCompletionInThousandNotation
in interfacePEPeerManager
- Returns:
- average percent complete in thousand notation
-
getMaxCompletionInThousandNotation
public int getMaxCompletionInThousandNotation(boolean never_include_seeds) Description copied from interface:PEPeerManager
Max completion of connected peers (doesn't factor in our completion)- Specified by:
getMaxCompletionInThousandNotation
in interfacePEPeerManager
- Returns:
-
getMaxConnections
public int[] getMaxConnections()- Specified by:
getMaxConnections
in interfacePEPeerControl
-
getMaxConnections
-
getMaxSeedConnections
public int[] getMaxSeedConnections() -
getMaxSeedConnections
-
getMaxNewConnectionsAllowed
returns the allowed connections for the given network -1 -> unlimited- Specified by:
getMaxNewConnectionsAllowed
in interfacePEPeerManager
-
getMaxNewConnectionsAllowed
private int[] getMaxNewConnectionsAllowed()returns number of whatever peers to connect and then extra ones that must be non-pub if available- Returns:
- -1 -> unlimited
-
getPeerCount
public int[] getPeerCount()- Specified by:
getPeerCount
in interfacePeerControlInstance
-
getPieceCount
public int[] getPieceCount()- Specified by:
getPieceCount
in interfacePeerControlInstance
-
getSchedulePriority
public int getSchedulePriority()- Specified by:
getSchedulePriority
in interfacePeerControlInstance
-
hasPotentialConnections
public boolean hasPotentialConnections()- Specified by:
hasPotentialConnections
in interfacePEPeerManager
-
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
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.
-
getTransportFromIdentity
Description copied from interface:PEPeerManager
Locate an existing transport via peer id byte identity.- Specified by:
getTransportFromIdentity
in interfacePEPeerManager
- Parameters:
peer_id
- to look for- Returns:
- transport with matching identity, or null if no match is found
-
getTransportFromAddress
Description copied from interface:PEPeerManager
Locate an existing transport via [IP] Address.- Specified by:
getTransportFromAddress
in interfacePEPeerManager
- Parameters:
peer
- String to look for- Returns:
- PEPeerTransport with matching address String, or null if no match is found
-
incNbPeersSnubbed
public void incNbPeersSnubbed()- Specified by:
incNbPeersSnubbed
in interfacePEPeerControl
-
decNbPeersSnubbed
public void decNbPeersSnubbed()- Specified by:
decNbPeersSnubbed
in interfacePEPeerControl
-
setNbPeersSnubbed
public void setNbPeersSnubbed(int n) - Specified by:
setNbPeersSnubbed
in interfacePEPeerControl
-
getNbPeersSnubbed
public int getNbPeersSnubbed()- Specified by:
getNbPeersSnubbed
in interfacePEPeerControl
-
getPreferUDP
public boolean getPreferUDP()- Specified by:
getPreferUDP
in interfacePEPeerManager
-
setPreferUDP
public void setPreferUDP(boolean prefer) - Specified by:
setPreferUDP
in interfacePEPeerManager
-
isPeerSourceEnabled
- Specified by:
isPeerSourceEnabled
in interfacePEPeerManager
-
isNetworkEnabled
- Specified by:
isNetworkEnabled
in interfacePEPeerManager
-
peerDiscovered
- Specified by:
peerDiscovered
in interfacePEPeerControl
-
getTrackerPeerSource
- Specified by:
getTrackerPeerSource
in interfacePEPeerManager
-
checkAutoSequentialFiles
-
handleFilePriorityChanged
private void handleFilePriorityChanged() -
handleCloseReason
- Specified by:
handleCloseReason
in interfacePEPeerControl
-
getHashHandler
- Specified by:
getHashHandler
in interfacePEPeerControl
-
generateEvidence
- Specified by:
generateEvidence
in interfacePEPeerManager
-