Fields Summary |
---|
public static final int | UNLIMITED_RATE |
private static final NetworkManager | instance |
private static int | max_download_rate_bps |
private static int | max_upload_rate_bps_normal |
private static int | max_upload_rate_bps_seeding_only |
private static int | max_upload_rate_bps |
private static boolean | lan_rate_enabled |
private static int | max_lan_upload_rate_bps |
private static int | max_lan_download_rate_bps |
private static boolean | seeding_only_mode_allowed |
private static boolean | seeding_only_mode |
public static boolean | REQUIRE_CRYPTO_HANDSHAKE |
public static boolean | INCOMING_HANDSHAKE_FALLBACK_ALLOWED |
public static boolean | OUTGOING_HANDSHAKE_FALLBACK_ALLOWED |
private final WriteController | write_controller |
private final ReadController | read_controller |
private final TransferProcessor | upload_processor |
private final TransferProcessor | download_processor |
private final TransferProcessor | lan_upload_processor |
private final TransferProcessor | lan_download_processor |
private NetworkManagerStats | stats |
public static final int | CRYPTO_OVERRIDE_NONE |
public static final int | CRYPTO_OVERRIDE_REQUIRED |
public static final int | CRYPTO_OVERRIDE_NOT_REQUIRED |
Methods Summary |
---|
public void | addRateLimiter(NetworkConnectionBase peer_connection, LimitedRateGroup group, boolean upload)
if ( upload ){
if ( lan_upload_processor.isRegistered( peer_connection )){
lan_upload_processor.addRateLimiter( peer_connection, group );
}else{
upload_processor.addRateLimiter( peer_connection, group );
}
}else{
if ( lan_download_processor.isRegistered( peer_connection )){
lan_download_processor.addRateLimiter( peer_connection, group );
}else{
download_processor.addRateLimiter( peer_connection, group );
}
}
|
public void | addReadEntity(RateControlledEntity entity)Add a download entity for read processing.
read_controller.addReadEntity( entity );
|
public void | addWriteEntity(RateControlledEntity entity)Add an upload entity for write processing.
write_controller.addWriteEntity( entity );
|
public NetworkConnection | bindTransport(Transport transport, MessageStreamEncoder encoder, MessageStreamDecoder decoder)
return( NetworkConnectionFactory.create( transport, encoder, decoder ));
|
public void | cancelIncomingConnectionRouting(com.aelitis.azureus.core.networkmanager.NetworkManager$ByteMatcher matcher)Cancel a request for inbound connection routing.
IncomingConnectionManager.getSingleton().deregisterMatchBytes( matcher );
|
public NetworkConnection | createConnection(ConnectionEndpoint target, MessageStreamEncoder encoder, MessageStreamDecoder decoder, boolean connect_with_crypto, boolean allow_fallback, byte[][] shared_secrets)Create a new unconnected remote network connection (for outbound-initiated connections).
return NetworkConnectionFactory.create( target, encoder, decoder, connect_with_crypto, allow_fallback, shared_secrets );
|
public void | downgradeTransferProcessing(NetworkConnectionBase peer_connection)Downgrade the given connection back to a normal-speed network transfer handling.
if( lan_upload_processor.isRegistered( peer_connection )) {
lan_upload_processor.downgradePeerConnection( peer_connection );
lan_download_processor.downgradePeerConnection( peer_connection );
}
else {
upload_processor.downgradePeerConnection( peer_connection );
download_processor.downgradePeerConnection( peer_connection );
}
|
public static boolean | getCryptoRequired(int override_level)
if ( override_level == CRYPTO_OVERRIDE_NONE ){
return( REQUIRE_CRYPTO_HANDSHAKE );
}else if ( override_level == CRYPTO_OVERRIDE_REQUIRED ){
return( true );
}else{
return( false );
}
|
public static int | getMaxDownloadRateBPS()
if( max_download_rate_bps == UNLIMITED_RATE ) return 0;
return max_download_rate_bps;
|
public static int | getMaxUploadRateBPSNormal()
if( max_upload_rate_bps_normal == UNLIMITED_RATE ) return 0;
return max_upload_rate_bps_normal;
|
public static int | getMaxUploadRateBPSSeedingOnly()
if( max_upload_rate_bps_seeding_only == UNLIMITED_RATE ) return 0;
return max_upload_rate_bps_seeding_only;
|
public static int | getMinMssSize() return Math.min( TCPNetworkManager.getTcpMssSize(), UDPNetworkManager.getUdpMssSize());
|
public static com.aelitis.azureus.core.networkmanager.NetworkManager | getSingleton()Get the singleton instance of the network manager. return instance;
|
public NetworkManagerStats | getStats()
return( stats );
|
public void | initialize()
HTTPNetworkManager.getSingleton();
AzureusCoreFactory.getSingleton().getGlobalManager().addListener( new GlobalManagerListener() {
public void downloadManagerAdded( DownloadManager dm ){}
public void downloadManagerRemoved( DownloadManager dm ){}
public void destroyInitiated(){}
public void destroyed(){}
public void seedingStatusChanged( boolean seeding_only ) {
seeding_only_mode = seeding_only;
refreshRates();
}
});
|
public static boolean | isLANRateEnabled()
return( lan_rate_enabled );
|
public static boolean | isSeedingOnlyUploadRate()
return seeding_only_mode_allowed && seeding_only_mode;
|
private static void | refreshRates()
if( isSeedingOnlyUploadRate() ) {
max_upload_rate_bps = max_upload_rate_bps_seeding_only;
}
else {
max_upload_rate_bps = max_upload_rate_bps_normal;
}
if( max_upload_rate_bps < 1024 ) {
Debug.out( "max_upload_rate_bps < 1024=" +max_upload_rate_bps);
}
//ensure that mss isn't greater than up/down rate limits
int min_rate = Math.min( max_upload_rate_bps,
Math.min( max_download_rate_bps,
Math.min( max_lan_upload_rate_bps, max_lan_download_rate_bps )));
TCPNetworkManager.refreshRates( min_rate );
UDPNetworkManager.refreshRates( min_rate );
|
public void | removeRateLimiter(NetworkConnectionBase peer_connection, LimitedRateGroup group, boolean upload)
if ( upload ){
if ( lan_upload_processor.isRegistered( peer_connection )){
lan_upload_processor.removeRateLimiter( peer_connection, group );
}else{
upload_processor.removeRateLimiter( peer_connection, group );
}
}else{
if ( lan_download_processor.isRegistered( peer_connection )){
lan_download_processor.removeRateLimiter( peer_connection, group );
}else{
download_processor.removeRateLimiter( peer_connection, group );
}
}
|
public void | removeReadEntity(RateControlledEntity entity)Remove a download entity from read processing.
read_controller.removeReadEntity( entity );
|
public void | removeWriteEntity(RateControlledEntity entity)Remove an upload entity from write processing.
write_controller.removeWriteEntity( entity );
|
public void | requestIncomingConnectionRouting(com.aelitis.azureus.core.networkmanager.NetworkManager$ByteMatcher matcher, com.aelitis.azureus.core.networkmanager.NetworkManager$RoutingListener listener, MessageStreamFactory factory)Request the acceptance and routing of new incoming connections that match the given initial byte sequence.
IncomingConnectionManager.getSingleton().registerMatchBytes( matcher, new IncomingConnectionManager.MatchListener() {
public boolean
autoCryptoFallback()
{
return( listener.autoCryptoFallback());
}
public void connectionMatched( Transport transport, Object routing_data ) {
listener.connectionRouted( NetworkConnectionFactory.create( transport, factory.createEncoder(), factory.createDecoder() ), routing_data );
}
});
|
public void | startTransferProcessing(NetworkConnectionBase peer_connection)Register peer connection for network upload and download handling.
NOTE: The given max rate limits are ignored until the connection is upgraded.
NOTE: The given max rate limits are ignored for LANLocal connections.
if( peer_connection.isLANLocal() && lan_rate_enabled ) {
lan_upload_processor.registerPeerConnection( peer_connection, true );
lan_download_processor.registerPeerConnection( peer_connection, false );
}
else {
upload_processor.registerPeerConnection( peer_connection, true );
download_processor.registerPeerConnection( peer_connection, false );
}
|
public void | stopTransferProcessing(NetworkConnectionBase peer_connection)Cancel network upload and download handling for the given connection.
if( lan_upload_processor.isRegistered( peer_connection )) {
lan_upload_processor.deregisterPeerConnection( peer_connection );
lan_download_processor.deregisterPeerConnection( peer_connection );
}
else {
upload_processor.deregisterPeerConnection( peer_connection );
download_processor.deregisterPeerConnection( peer_connection );
}
|
public void | upgradeTransferProcessing(NetworkConnectionBase peer_connection)Upgrade the given connection to high-speed network transfer handling.
if( lan_upload_processor.isRegistered( peer_connection )) {
lan_upload_processor.upgradePeerConnection( peer_connection );
lan_download_processor.upgradePeerConnection( peer_connection );
}
else {
upload_processor.upgradePeerConnection( peer_connection );
download_processor.upgradePeerConnection( peer_connection );
}
|