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 classprivate class(package private) static interface(package private) static class(package private) static class(package private) static classNested classes/interfaces inherited from interface DiskManagerCheckRequestListener
DiskManagerCheckRequestListener.HashListenerNested classes/interfaces inherited from interface PEPeerManager
PEPeerManager.StatsReceiver -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Averageprivate PeerIdentityDataIDprivate final byte[]private final intprivate intprivate intprivate intprivate intprivate intprivate PEPeerManagerStatsImplprivate intprivate intprivate intprivate longprivate longprivate longprivate longprivate longprotected final PEPeerManagerAdapterprivate booleanprivate intprivate static intprivate static floatprivate intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final Objectprivate final Map<PEPeerControlImpl.PeerCacheKey, Long> private static final intprivate intprivate intprivate intprivate intprivate final DiskManagerprivate final DiskManagerPiece[]private booleanprivate final LimitedRateGroupprivate static intprivate static final Objectprivate static final Objectprivate static booleanprivate static booleanprivate static final intprivate static booleanprivate static booleanprivate booleanprivate static booleanprivate final PEPeerControlHashHandlerprivate intprivate BloomFilterprivate static final intprivate static booleanprivate static booleanprivate static final IpFilterprivate longprivate booleanprivate final booleanprivate final booleanprivate booleanprivate longprivate longprivate longprivate longprivate longprivate longprivate longprivate Booleanprivate static final LogIDsprivate static final intprivate static final intprivate longprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate intprivate final PEPeerControlImpl.MyPeerprivate final BloomFilterprivate longprivate intprivate intprivate static final NetworkAdminprivate intprivate intprivate int[]private boolean[][]private static final intprivate int[]private intprivate final Map<PEPeerControlImpl.PeerCacheKey, Integer> private static final intprivate intprivate final intprivate final PeerDatabaseprivate ArrayList<PEPeerManagerListener> private static final Stringprivate ArrayList<PEPeerTransport> private final AEMonitorprivate static final intprivate static final intprivate final Map<String, PEPeerTransport> private final PEPieceImpl[]private final AEMonitorprivate final PiecePickerprivate final intprivate booleanprivate BloomFilterprivate static final intprivate static booleanprivate static final intprivate static final intprivate static final longprivate static final longprivate static final longprivate longprivate static final longprivate booleanprivate static final intprivate booleanliterally seeding as in 100% torrent completeprivate static intprivate PEPeerManager.StatsReceiverprivate intprivate booleanprivate intprivate intprivate SuperSeedPiece[]private List<PEPeerTransport> private static final booleanprivate final AEMonitorprivate final TOTorrentprivate static booleanprivate static booleanprivate static booleanprivate static final intprivate static final intprivate final Map<String, PEPeerTransport> private intprivate Unchokerprivate booleanprivate final UploadHelperprivate final LimitedRateGroupprivate static final AtomicIntegerprivate static final intFields inherited from interface PEPeerControl
SNUB_MILLIS, TEST_PERMIT_PEER_CONNECTIONS -
Constructor Summary
ConstructorsConstructorDescriptionPEPeerControlImpl(byte[] _peer_id, PEPeerManagerAdapter _adapter, DiskManager _diskManager, int _partition_id) -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanprivate voidaddExtendedPeersFromTracker(Map extensions) private voidaddFastUnchokes(ArrayList peers_to_unchoke) voidvoidvoidAdd a new peer, using the default internal PEPeer implementation (like for peers given in announce reply), using the given address and port.private voidvoidaddPeerTransport(PEPeerTransport transport) protected voidvoidDon't pass a null to this method.voidaddRateLimiter(LimitedRateGroup group, boolean upload) private voidprivate intaddWarning(String ip, PEPeerTransport peer) private voidanalyseTrackerResponse(TRTrackerAnnouncerResponse tracker_response) A private method that does analysis of the result sent by the tracker.private voidbadPeerDetected(String ip, int piece_number, String reason) voidbadPieceReported(PEPeerTransport originator, int piece_number) booleancanIPBeBanned(String ip) booleancanIPBeBlocked(String ip, byte[] torrent_hash) booleanprivate voidprivate voidcheckAutoSequentialFiles(DiskManagerFileInfo done_file) private voidvoidcheckCancelled(DiskManagerCheckRequest request) voidcheckCompleted(DiskManagerCheckRequest request, boolean passed) private voidA 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 voidprivate booleancheckEmptyPiece(int pieceNumber) Checks given piece to see if it's active but empty, and if so deactivates it.voidcheckFailed(DiskManagerCheckRequest request, Throwable cause) private voidcheckFinished(boolean start_of_day) This method checks if the downloading process is finished.private voidprivate voidprivate voidThis 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 voidprivate voidvoidcheckSnubbing(PEPeerTransport peer) private voidCheck 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 voidcloseAndRemoveAllPeers(String reason, int reason_code, boolean reconnect) private voidcloseAndRemovePeer(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) voiddataBytesReceived(PEPeer peer, long length) Data bytes received.voiddataBytesSent(PEPeer peer, long length) Data bytes sent.voidvoidprivate booleanprivate voidbooleandoOptimisticDisconnect(boolean pending_lan_local_peer, boolean force, String network) private voiddoTCPConnectionChecks(int number) private voiddoUDPConnectionChecks(int number) private voidDo all peer choke/unchoke processing.voidgenerateEvidence(IndentWriter writer) int[]intgetAvailability(int pieceNumber) longintGet the average completion percentage of connected peers.floatintlonggetConnectHealth(boolean verbose) intgetConnectTimeout(int ct_def) To retreive arbitrary objects against this object.Get the limited rate group used for download limiting.intintlonggetETA(boolean smoothed) Returns the ETA time in seconds.intbyte[]getHash()longintlongintgetMaxCompletionInThousandNotation(boolean never_include_seeds) Max completion of connected peers (doesn't factor in our completion)int[]private intgetMaxConnections(String net) private int[]returns number of whatever peers to connect and then extra ones that must be non-pub if availableintgetMaxNewConnectionsAllowed(String network) returns the allowed connections for the given network -1 -> unlimitedint[]private intfloatfloatgetMinAvailability(int file_index) getName()intintintintintintintintintintintintintintint[]byte[]getPeers()intgetPendingPeers(String address) getPiece(int pieceNumber) int[]intgetPieceLength(int pieceNumber) PEPiece[]Often better to use getPiece(pieceNumber)booleanObject[]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 loggerlongintbyte[][]getSecrets(int crypto_level) getStats()byte[]Get torrent hash including any overridesintlonggetTimeStarted(boolean mono) longgetTimeStartedSeeding(boolean mono) protected byte[]intLocate an existing transport via [IP] Address.getTransportFromIdentity(byte[] peer_id) Locate an existing transport via peer id byte identity.intgetUID()Get the limited rate group used for upload limiting.intintvoidhandleCloseReason(PEPeerTransport peer, boolean reason_outgoing, int reason) private voidbooleanbooleanhashRequest(int piece_number, DiskManagerCheckRequestListener.HashListener listener) booleanvoidvoidvoidinformFullyConnected(PEPeer peer) private voidprivate voidvoidvoidIPBlockedListChanged(IpFilter filter) voidIPFilterEnabledChanged(boolean is_enabled) private booleanisAlreadyConnected(PeerItem peer_id) private booleanisBlocked(PEPeerTransport peer, String name, byte[] hash) booleanbooleanisFastExtensionPermitted(PEPeerTransport originator) booleanisHolePunchOperationOK(PEPeerTransport peer, boolean is_connect) booleanAre we in end-game mode?booleanbooleanisNetworkEnabled(String net) booleanbooleanisPeerSourceEnabled(String peer_source) booleanbooleanisRTA()booleanbooleanprivate booleanbooleanisWritten(int piece_number, int offset) private StringmakeNewOutgoingConnection(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 voidMD5CheckPiece(PEPiece piece, boolean correct) booleanneedsMD5CheckOnCompletion(int pieceNumber) private voidvoidpeerConnectionClosed(PEPeerTransport peer, boolean connect_failed, boolean network_failed) Notify the manager that the given peer connection has been closed.voidpeerDiscovered(PEPeerTransport finder, PeerItem pi) voidpeerDiscovered(String peer_source, String ip_address, int tcp_port, int udp_port, boolean use_crypto) private voidvoidNotify that the given peer connection represents our own client.private voidprocessPieceCheckResult(DiskManagerCheckRequest request, int outcome) private voidPrivate method to process the results given by DiskManager's piece checking thread via asyncPieceChecked(..)voidvoidprotocolBytesReceived(PEPeer peer, long length) Protocol bytes received.voidprotocolBytesSent(PEPeer peer, long length) Protocol bytes sent.voidremoveAllPeers(String reason, int reason_code) voidvoidremovePeer(PEPeer _transport, String reason, int reason_code) voidremovePiece(PEPiece pePiece, int pieceNumber) Sends messages to listeners that the piece is no longer active.voidremoveRateLimiter(LimitedRateGroup group, boolean upload) voidreportBadFastExtensionUse(PEPeerTransport originator) voidrequestAdded(PEPiece piece, PEPeerTransport peer, DiskManagerReadRequest request) voidrequestCanceled(DiskManagerReadRequest request) The way to unmark a request as being downloaded, or also called by Peer connections objects when connection is closed or chokedbooleanrequestExists(String peer_ip, int piece_number, int offset, int length) voidschedule()booleanprivate voidsendHave(int pieceNumber) voidTo store arbitrary objects against a control.voidvoidsetNbPeersSnubbed(int n) voidsetPreferUDP(boolean prefer) voidsetStatsReceiver(PEPeerManager.StatsReceiver receiver) voidsetSuperSeedMode(boolean _superSeedMode) voidsetTorrentInfoDictSize(int size) voidstart()voidstatsReply(PEPeerTransport originator, Map reply) voidstatsRequest(PEPeerTransport originator, Map request) voidstopAll()private voidprivate voidprivate voidvoidupdateSuperSeedPiece(PEPeer peer, int pieceNumber) private voidbooleanvalidateHintRequest(PEPeerTransport originator, int pieceNumber, int offset, int length) booleanvalidatePieceReply(PEPeerTransport originator, int pieceNumber, int offset, DirectByteBuffer data) booleanvalidateReadRequest(PEPeerTransport originator, int pieceNumber, int offset, int length) voidwriteBlock(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.voidwriteCompleted(DiskManagerWriteRequest request) DiskManagerWriteRequestListener messagevoidwriteFailed(DiskManagerWriteRequest request, Throwable cause) Methods inherited from class LogRelation
propogatedRelationText, queryForClassMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface DiskManagerCheckRequestListener
isFailureInterestingMethods inherited from interface IPFilterListener
IPBanListChangedMethods inherited from interface 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
-
ignore_v4
private static volatile boolean ignore_v4 -
ignore_v6
private static volatile boolean ignore_v6 -
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:
getUIDin interfacePEPeerManager
-
start
public void start()- Specified by:
startin interfacePEPeerManager
-
stopAll
public void stopAll()- Specified by:
stopAllin interfacePEPeerManager
-
removeAllPeers
- Specified by:
removeAllPeersin interfacePEPeerManager
-
getPartitionID
public int getPartitionID()- Specified by:
getPartitionIDin interfacePEPeerManager
-
getTCPListeningPortNumber
public int getTCPListeningPortNumber()- Specified by:
getTCPListeningPortNumberin interfacePEPeerControl
-
getTargetHash
public byte[] getTargetHash()Description copied from interface:PEPeerControlGet torrent hash including any overrides- Specified by:
getTargetHashin interfacePEPeerControl- Returns:
-
isDestroyed
public boolean isDestroyed()- Specified by:
isDestroyedin interfacePEPeerManager
-
getDiskManager
- Specified by:
getDiskManagerin interfacePEPeerManager
-
getPiecePicker
- Specified by:
getPiecePickerin interfacePEPeerManager
-
getAdapter
- Specified by:
getAdapterin interfacePEPeerManager
-
getDisplayName
- Specified by:
getDisplayNamein interfacePeerNATInitiator- Specified by:
getDisplayNamein interfacePEPeerManager
-
getName
- Specified by:
getNamein interfacePeerControlInstance
-
schedule
public void schedule()- Specified by:
schedulein 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:
processTrackerResponsein interfacePEPeerManager
-
addExtendedPeersFromTracker
-
getMyPeer
- Specified by:
getMyPeerin interfacePEPeerManager
-
getPeers
- Specified by:
getPeersin interfacePEPeerManager
-
getPeers
- Specified by:
getPeersin interfacePEPeerManager
-
getPendingPeerCount
public int getPendingPeerCount()- Specified by:
getPendingPeerCountin interfacePEPeerManager
-
getPendingPeers
- Specified by:
getPendingPeersin interfacePEPeerManager
-
getPendingPeers
- Specified by:
getPendingPeersin interfacePEPeerManager
-
addPeer
- Specified by:
addPeerin interfacePEPeerManager
-
getTorrentHash
protected byte[] getTorrentHash() -
removePeer
- Specified by:
removePeerin 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:PEPeerManagerAdd a new peer, using the default internal PEPeer implementation (like for peers given in announce reply), using the given address and port.- Specified by:
addPeerin 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:
peerDiscoveredin 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:
hashRequestin 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:
badPieceReportedin interfacePEPeerControl
-
isFastExtensionPermitted
- Specified by:
isFastExtensionPermittedin interfacePEPeerControl
-
reportBadFastExtensionUse
- Specified by:
reportBadFastExtensionUsein interfacePEPeerControl
-
setStatsReceiver
- Specified by:
setStatsReceiverin interfacePEPeerManager
-
statsRequest
- Specified by:
statsRequestin interfacePEPeerControl
-
statsReply
- Specified by:
statsReplyin 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:
checkSnubbingin interfacePEPeerControl
-
updateTrackerAnnounceInterval
private void updateTrackerAnnounceInterval() -
hasDownloadablePiece
public boolean hasDownloadablePiece()- Specified by:
hasDownloadablePiecein interfacePEPeerManager
-
getBytesQueuedForUpload
public int getBytesQueuedForUpload()- Specified by:
getBytesQueuedForUploadin interfacePEPeerManager
-
getNbPeersWithUploadQueued
public int getNbPeersWithUploadQueued()- Specified by:
getNbPeersWithUploadQueuedin interfacePEPeerManager
-
getNbPeersWithUploadBlocked
public int getNbPeersWithUploadBlocked()- Specified by:
getNbPeersWithUploadBlockedin interfacePEPeerManager
-
getNbPeersUnchoked
public int getNbPeersUnchoked()- Specified by:
getNbPeersUnchokedin interfacePEPeerManager
-
getNbPeersUnchoking
public int getNbPeersUnchoking()- Specified by:
getNbPeersUnchokingin interfacePEPeerManager
-
getAvailability
public int[] getAvailability()- Specified by:
getAvailabilityin interfacePEPeerManager
-
getMinAvailability
public float getMinAvailability()- Specified by:
getMinAvailabilityin interfacePEPeerManager
-
getMinAvailability
public float getMinAvailability(int file_index) - Specified by:
getMinAvailabilityin interfacePEPeerManager
-
getAvgAvail
public float getAvgAvail()- Specified by:
getAvgAvailin interfacePEPeerManager
-
getAvailWentBadTime
public long getAvailWentBadTime()- Specified by:
getAvailWentBadTimein 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:
addPeerTransportin 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:
requestCanceledin interfacePEPeerManager- Parameters:
request- a DiskManagerReadRequest holding details of what was canceled
-
requestAdded
- Specified by:
requestAddedin interfacePEPeerControl
-
getControl
-
getSecrets
public byte[][] getSecrets(int crypto_level) - Specified by:
getSecretsin interfacePEPeerControl
-
getHash
public byte[] getHash()- Specified by:
getHashin interfacePEPeerManager
-
getPeerIdentityDataID
- Specified by:
getPeerIdentityDataIDin interfacePEPeerManager
-
getPeerId
public byte[] getPeerId()- Specified by:
getPeerIdin interfacePEPeerManager
-
getRemaining
public long getRemaining()- Specified by:
getRemainingin interfacePEPeerManager
-
discarded
- Specified by:
discardedin interfacePEPeerManager
-
dataBytesReceived
Description copied from interface:PEPeerManagerData bytes received.- Specified by:
dataBytesReceivedin interfacePEPeerManager- Parameters:
length-
-
protocolBytesReceived
Description copied from interface:PEPeerManagerProtocol bytes received.- Specified by:
protocolBytesReceivedin interfacePEPeerManager- Parameters:
length-
-
dataBytesSent
Description copied from interface:PEPeerManagerData bytes sent.- Specified by:
dataBytesSentin interfacePEPeerManager- Parameters:
length-
-
protocolBytesSent
Description copied from interface:PEPeerManagerProtocol bytes sent.- Specified by:
protocolBytesSentin interfacePEPeerManager- Parameters:
length-
-
writeCompleted
DiskManagerWriteRequestListener message- Specified by:
writeCompletedin interfaceDiskManagerWriteRequestListener- See Also:
-
writeFailed
- Specified by:
writeFailedin 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:
writeBlockin 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:
isWrittenin interfacePEPeerManager
-
validateReadRequest
public boolean validateReadRequest(PEPeerTransport originator, int pieceNumber, int offset, int length) - Specified by:
validateReadRequestin interfacePEPeerControl
-
validateHintRequest
public boolean validateHintRequest(PEPeerTransport originator, int pieceNumber, int offset, int length) - Specified by:
validateHintRequestin interfacePEPeerControl
-
validatePieceReply
public boolean validatePieceReply(PEPeerTransport originator, int pieceNumber, int offset, DirectByteBuffer data) - Specified by:
validatePieceReplyin interfacePEPeerManager
-
getAvailability
public int getAvailability(int pieceNumber) - Specified by:
getAvailabilityin interfacePEPeerManager
-
havePiece
- Specified by:
havePiecein interfacePEPeerControl
-
getPieceLength
public int getPieceLength(int pieceNumber) - Specified by:
getPieceLengthin interfacePEPeerManager
-
getNbPeers
public int getNbPeers()- Specified by:
getNbPeersin interfacePEPeerManager
-
getNbSeeds
public int getNbSeeds()- Specified by:
getNbSeedsin interfacePEPeerManager
-
getNbRemoteTCPConnections
public int getNbRemoteTCPConnections()- Specified by:
getNbRemoteTCPConnectionsin interfacePEPeerManager
-
getNbRemoteUDPConnections
public int getNbRemoteUDPConnections()- Specified by:
getNbRemoteUDPConnectionsin interfacePEPeerManager
-
getNbRemoteUTPConnections
public int getNbRemoteUTPConnections()- Specified by:
getNbRemoteUTPConnectionsin interfacePEPeerManager
-
getLastRemoteConnectionTime
public long getLastRemoteConnectionTime()- Specified by:
getLastRemoteConnectionTimein interfacePEPeerManager
-
getStats
- Specified by:
getStatsin interfacePEPeerManager
-
getNbPeersStalledPendingLoad
public int getNbPeersStalledPendingLoad()- Specified by:
getNbPeersStalledPendingLoadin 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:
getETAin interfacePEPeerManager
-
isRTA
public boolean isRTA()- Specified by:
isRTAin interfacePEPeerControl
-
addToPeerTransports
-
addRateLimiter
- Specified by:
addRateLimiterin interfacePEPeerManager
-
removeRateLimiter
- Specified by:
removeRateLimiterin interfacePEPeerManager
-
getEffectiveUploadRateLimitBytesPerSecond
public int getEffectiveUploadRateLimitBytesPerSecond()- Specified by:
getEffectiveUploadRateLimitBytesPerSecondin interfacePEPeerManager
-
getUploadRateLimitBytesPerSecond
public int getUploadRateLimitBytesPerSecond()- Specified by:
getUploadRateLimitBytesPerSecondin interfacePEPeerManager
-
getDownloadRateLimitBytesPerSecond
public int getDownloadRateLimitBytesPerSecond()- Specified by:
getDownloadRateLimitBytesPerSecondin interfacePEPeerManager
-
peerConnectionClosed
public void peerConnectionClosed(PEPeerTransport peer, boolean connect_failed, boolean network_failed) Description copied from interface:PEPeerManagerNotify the manager that the given peer connection has been closed.- Specified by:
peerConnectionClosedin interfacePEPeerManager- Parameters:
peer- closed
-
informFullyConnected
- Specified by:
informFullyConnectedin interfacePEPeerManager
-
updateConnectHealth
-
getConnectHealth
- Specified by:
getConnectHealthin interfacePEPeerManager
-
peerAdded
-
peerRemoved
-
addPiece
Don't pass a null to this method. All activations of pieces must go through here.- Specified by:
addPiecein 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:
getNbActivePiecesin interfacePEPeerControl
-
getElapsedTime
- Specified by:
getElapsedTimein interfacePEPeerManager
-
getTimeStarted
public long getTimeStarted(boolean mono) - Specified by:
getTimeStartedin interfacePEPeerManager
-
getTimeStartedSeeding
public long getTimeStartedSeeding(boolean mono) - Specified by:
getTimeStartedSeedingin interfacePEPeerManager
-
computeMd5Hash
-
MD5CheckPiece
-
checkCompleted
- Specified by:
checkCompletedin interfaceDiskManagerCheckRequestListener
-
checkCancelled
- Specified by:
checkCancelledin interfaceDiskManagerCheckRequestListener
-
checkFailed
- Specified by:
checkFailedin interfaceDiskManagerCheckRequestListener
-
needsMD5CheckOnCompletion
public boolean needsMD5CheckOnCompletion(int pieceNumber) - Specified by:
needsMD5CheckOnCompletionin interfacePEPeerManager
-
processPieceCheckResult
-
badPeerDetected
-
getNbPieces
public int getNbPieces()- Specified by:
getNbPiecesin interfacePEPeerManager
-
getPieces
Description copied from interface:PEPeerManagerOften better to use getPiece(pieceNumber)- Specified by:
getPiecesin interfacePEPeerManager
-
getPiece
- Specified by:
getPiecein interfacePEPeerManager- Returns:
- PEPiece or null if piece not currently active
-
createPeerStats
- Specified by:
createPeerStatsin interfacePEPeerManager
-
createDiskManagerRequest
- Specified by:
createDiskManagerRequestin interfacePEPeerManager
-
requestExists
- Specified by:
requestExistsin interfacePEPeerManager
-
seedPieceRecheck
public boolean seedPieceRecheck()- Specified by:
seedPieceRecheckin interfacePEPeerManager
-
addListener
- Specified by:
addListenerin interfacePEPeerManager
-
removeListener
- Specified by:
removeListenerin interfacePEPeerManager
-
checkForBannedConnections
private void checkForBannedConnections() -
isBlocked
-
addWarning
-
addBan
-
isSeeding
public boolean isSeeding()- Specified by:
isSeedingin interfacePEPeerManager
-
isMetadataDownload
public boolean isMetadataDownload()- Specified by:
isMetadataDownloadin interfacePEPeerManager
-
getTorrentInfoDictSize
public int getTorrentInfoDictSize()- Specified by:
getTorrentInfoDictSizein interfacePEPeerManager
-
setTorrentInfoDictSize
public void setTorrentInfoDictSize(int size) - Specified by:
setTorrentInfoDictSizein interfacePEPeerManager
-
isInEndGameMode
public boolean isInEndGameMode()Description copied from interface:PEPeerManagerAre we in end-game mode?- Specified by:
isInEndGameModein interfacePEPeerManager- Returns:
- true if in end game mode, false if not
-
isSuperSeedMode
public boolean isSuperSeedMode()- Specified by:
isSuperSeedModein interfacePEPeerManager
-
canToggleSuperSeedMode
public boolean canToggleSuperSeedMode()- Specified by:
canToggleSuperSeedModein interfacePEPeerManager
-
setSuperSeedMode
public void setSuperSeedMode(boolean _superSeedMode) - Specified by:
setSuperSeedModein interfacePEPeerManager
-
initialiseSuperSeedMode
private void initialiseSuperSeedMode() -
updatePeersInSuperSeedMode
private void updatePeersInSuperSeedMode() -
updateSuperSeedPiece
- Specified by:
updateSuperSeedPiecein interfacePEPeerControl
-
isPrivateTorrent
public boolean isPrivateTorrent()- Specified by:
isPrivateTorrentin interfacePEPeerControl
-
getExtendedMessagingMode
public int getExtendedMessagingMode()- Specified by:
getExtendedMessagingModein interfacePEPeerControl
-
isPeerExchangeEnabled
public boolean isPeerExchangeEnabled()- Specified by:
isPeerExchangeEnabledin interfacePEPeerControl
-
getUploadLimitedRateGroup
Description copied from interface:PEPeerManagerGet the limited rate group used for upload limiting.- Specified by:
getUploadLimitedRateGroupin interfacePEPeerManager- Returns:
- upload limit group
-
getDownloadLimitedRateGroup
Description copied from interface:PEPeerManagerGet the limited rate group used for download limiting.- Specified by:
getDownloadLimitedRateGroupin interfacePEPeerManager- Returns:
- download limit group
-
getData
To retreive arbitrary objects against this object.- Specified by:
getDatain interfacePEPeerManager
-
setData
To store arbitrary objects against a control.- Specified by:
setDatain interfacePEPeerManager
-
getConnectTimeout
public int getConnectTimeout(int ct_def) - Specified by:
getConnectTimeoutin interfacePEPeerControl
-
doConnectionChecks
private void doConnectionChecks() -
isHolePunchOperationOK
- Specified by:
isHolePunchOperationOKin 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:
doOptimisticDisconnectin interfacePEPeerControl
-
createPeerExchangeConnection
Description copied from interface:PEPeerManagerRegister 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:
createPeerExchangeConnectionin interfacePEPeerManager- Parameters:
base_peer- exchanging with- Returns:
- peer database connection item, or null if creation failed
-
isAlreadyConnected
-
peerVerifiedAsSelf
Description copied from interface:PEPeerManagerNotify that the given peer connection represents our own client.- Specified by:
peerVerifiedAsSelfin interfacePEPeerManager- Parameters:
self- peer
-
IPFilterEnabledChanged
public void IPFilterEnabledChanged(boolean is_enabled) - Specified by:
IPFilterEnabledChangedin interfaceIPFilterListener
-
canIPBeBanned
- Specified by:
canIPBeBannedin interfaceIPFilterListener
-
canIPBeBlocked
- Specified by:
canIPBeBlockedin interfaceIPFilterListener
-
IPBlockedListChanged
- Specified by:
IPBlockedListChangedin interfaceIPFilterListener
-
IPBanned
- Specified by:
IPBannedin interfaceIPFilterListener
-
disconnectSeedsWhenSeeding
private boolean disconnectSeedsWhenSeeding() -
initHiddenPiece
private void initHiddenPiece() -
setMaskDownloadCompletion
- Specified by:
setMaskDownloadCompletionin interfacePEPeerManager
-
getHiddenBytes
public long getHiddenBytes()- Specified by:
getHiddenBytesin interfacePEPeerManager
-
getHiddenPiece
public int getHiddenPiece()- Specified by:
getHiddenPiecein interfacePEPeerManager
-
getUploadPriority
public int getUploadPriority()- Specified by:
getUploadPriorityin interfacePEPeerControl
-
getAverageCompletionInThousandNotation
public int getAverageCompletionInThousandNotation()Description copied from interface:PEPeerManagerGet the average completion percentage of connected peers.- Specified by:
getAverageCompletionInThousandNotationin interfacePEPeerManager- Returns:
- average percent complete in thousand notation
-
getMaxCompletionInThousandNotation
public int getMaxCompletionInThousandNotation(boolean never_include_seeds) Description copied from interface:PEPeerManagerMax completion of connected peers (doesn't factor in our completion)- Specified by:
getMaxCompletionInThousandNotationin interfacePEPeerManager- Returns:
-
getMaxConnections
public int[] getMaxConnections()- Specified by:
getMaxConnectionsin interfacePEPeerControl
-
getMaxConnections
-
getMaxSeedConnections
public int[] getMaxSeedConnections() -
getMaxSeedConnections
-
getMaxNewConnectionsAllowed
returns the allowed connections for the given network -1 -> unlimited- Specified by:
getMaxNewConnectionsAllowedin 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:
getPeerCountin interfacePeerControlInstance
-
getPieceCount
public int[] getPieceCount()- Specified by:
getPieceCountin interfacePeerControlInstance
-
getSchedulePriority
public int getSchedulePriority()- Specified by:
getSchedulePriorityin interfacePeerControlInstance
-
hasPotentialConnections
public boolean hasPotentialConnections()- Specified by:
hasPotentialConnectionsin interfacePEPeerManager
-
getRelationText
Description copied from class:LogRelationA short description of what your class holds that can be printed by the logger- Overrides:
getRelationTextin classLogRelation- Returns:
-
getQueryableInterfaces
Description copied from class:LogRelationQuery this class for a reference to another class that it may hold- Overrides:
getQueryableInterfacesin classLogRelation- Returns:
- If found, the class desired. Otherwise, null.
-
getTransportFromIdentity
Description copied from interface:PEPeerManagerLocate an existing transport via peer id byte identity.- Specified by:
getTransportFromIdentityin interfacePEPeerManager- Parameters:
peer_id- to look for- Returns:
- transport with matching identity, or null if no match is found
-
getTransportFromAddress
Description copied from interface:PEPeerManagerLocate an existing transport via [IP] Address.- Specified by:
getTransportFromAddressin 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:
incNbPeersSnubbedin interfacePEPeerControl
-
decNbPeersSnubbed
public void decNbPeersSnubbed()- Specified by:
decNbPeersSnubbedin interfacePEPeerControl
-
setNbPeersSnubbed
public void setNbPeersSnubbed(int n) - Specified by:
setNbPeersSnubbedin interfacePEPeerControl
-
getNbPeersSnubbed
public int getNbPeersSnubbed()- Specified by:
getNbPeersSnubbedin interfacePEPeerControl
-
getPreferUDP
public boolean getPreferUDP()- Specified by:
getPreferUDPin interfacePEPeerManager
-
setPreferUDP
public void setPreferUDP(boolean prefer) - Specified by:
setPreferUDPin interfacePEPeerManager
-
isPeerSourceEnabled
- Specified by:
isPeerSourceEnabledin interfacePEPeerManager
-
isNetworkEnabled
- Specified by:
isNetworkEnabledin interfacePEPeerManager
-
peerDiscovered
- Specified by:
peerDiscoveredin interfacePEPeerControl
-
getTrackerPeerSource
- Specified by:
getTrackerPeerSourcein interfacePEPeerManager
-
checkAutoSequentialFiles
-
handleFilePriorityChanged
private void handleFilePriorityChanged() -
handleCloseReason
- Specified by:
handleCloseReasonin interfacePEPeerControl
-
getHashHandler
- Specified by:
getHashHandlerin interfacePEPeerControl
-
generateEvidence
- Specified by:
generateEvidencein interfacePEPeerManager
-