Package com.biglybt.core.networkmanager
Class NetworkManager
- java.lang.Object
-
- com.biglybt.core.networkmanager.NetworkManager
-
public class NetworkManager extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
NetworkManager.ByteMatcher
Byte stream match filter for routing.static interface
NetworkManager.RoutingListener
Listener for routing events.
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description private
NetworkManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRateLimiter(NetworkConnectionBase peer_connection, LimitedRateGroup group, boolean upload)
void
addReadEntity(RateControlledEntity entity, int partition_id)
Add a download entity for read processing.void
addWriteEntity(RateControlledEntity entity, int partition_id)
Add an upload entity for write processing.NetworkConnection
bindTransport(Transport transport, MessageStreamEncoder encoder, MessageStreamDecoder decoder)
void
cancelIncomingConnectionRouting(NetworkManager.ByteMatcher matcher)
Cancel a request for inbound connection routing.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).void
downgradeTransferProcessing(NetworkConnectionBase peer_connection)
Downgrade the given connection back to a normal-speed network transfer handling.java.util.Set<NetworkConnectionBase>
getConnections()
static boolean
getCryptoRequired(int override_level)
static int
getMaxDownloadRateBPS()
This method is for display purposes only, the internal rate limiting is 10% higher than returned by this method!static int
getMaxUploadRateBPSNormal()
static int
getMaxUploadRateBPSSeedingOnly()
static int
getMinMssSize()
RateHandler
getRateHandler(boolean upload, boolean lan)
RateHandler
getRateHandler(NetworkConnectionBase peer_connection, boolean upload)
static NetworkManager
getSingleton()
Get the singleton instance of the network manager.TransferProcessor
getUploadProcessor()
java.util.List<WriteController>
getWriteControllers()
void
initialize(Core _core)
static boolean
isLANRateEnabled()
static boolean
isSeedingOnlyUploadRate()
(package private) static void
refreshRates()
void
removeRateLimiter(NetworkConnectionBase peer_connection, LimitedRateGroup group, boolean upload)
boolean
removeReadEntity(RateControlledEntity entity)
Remove a download entity from read processing.boolean
removeWriteEntity(RateControlledEntity entity)
Remove an upload entity from write processing.void
requestIncomingConnectionRouting(NetworkManager.ByteMatcher matcher, NetworkManager.RoutingListener listener, MessageStreamFactory factory)
Request the acceptance and routing of new incoming connections that match the given initial byte sequence.void
startTransferProcessing(NetworkConnectionBase peer_connection)
Register peer connection for network upload and download handling.void
stopTransferProcessing(NetworkConnectionBase peer_connection)
Cancel network upload and download handling for the given connection.void
upgradeTransferProcessing(NetworkConnectionBase peer_connection, int partition_id)
Upgrade the given connection to high-speed network transfer handling.
-
-
-
Field Detail
-
UNLIMITED_RATE
public static final int UNLIMITED_RATE
- See Also:
- Constant Field Values
-
instance
private static final NetworkManager instance
-
max_download_rate_bps
static int max_download_rate_bps
-
external_max_download_rate_bps
static int external_max_download_rate_bps
-
max_upload_rate_bps_normal
static int max_upload_rate_bps_normal
-
max_upload_rate_bps_seeding_only
static int max_upload_rate_bps_seeding_only
-
max_upload_rate_bps
static int max_upload_rate_bps
-
lan_rate_enabled
static boolean lan_rate_enabled
-
max_lan_upload_rate_bps
static int max_lan_upload_rate_bps
-
max_lan_download_rate_bps
static int max_lan_download_rate_bps
-
seeding_only_mode_allowed
static boolean seeding_only_mode_allowed
-
seeding_only_mode
static boolean seeding_only_mode
-
REQUIRE_CRYPTO_HANDSHAKE
public static boolean REQUIRE_CRYPTO_HANDSHAKE
-
INCOMING_HANDSHAKE_FALLBACK_ALLOWED
public static boolean INCOMING_HANDSHAKE_FALLBACK_ALLOWED
-
OUTGOING_HANDSHAKE_FALLBACK_ALLOWED
public static boolean OUTGOING_HANDSHAKE_FALLBACK_ALLOWED
-
INCOMING_CRYPTO_ALLOWED
public static boolean INCOMING_CRYPTO_ALLOWED
-
USE_REQUEST_LIMITING
static boolean USE_REQUEST_LIMITING
-
core
private Core core
-
write_controllers
private final java.util.List<WriteController> write_controllers
-
read_controllers
private final java.util.List<ReadController> read_controllers
-
upload_processor
private TransferProcessor upload_processor
-
download_processor
private TransferProcessor download_processor
-
lan_upload_processor
private TransferProcessor lan_upload_processor
-
lan_download_processor
private TransferProcessor lan_download_processor
-
CRYPTO_OVERRIDE_NONE
public static final int CRYPTO_OVERRIDE_NONE
- See Also:
- Constant Field Values
-
CRYPTO_OVERRIDE_REQUIRED
public static final int CRYPTO_OVERRIDE_REQUIRED
- See Also:
- Constant Field Values
-
CRYPTO_OVERRIDE_NOT_REQUIRED
public static final int CRYPTO_OVERRIDE_NOT_REQUIRED
- See Also:
- Constant Field Values
-
-
Method Detail
-
getWriteControllers
public java.util.List<WriteController> getWriteControllers()
-
isLANRateEnabled
public static boolean isLANRateEnabled()
-
getMinMssSize
public static int getMinMssSize()
-
refreshRates
static void refreshRates()
-
isSeedingOnlyUploadRate
public static boolean isSeedingOnlyUploadRate()
-
getMaxUploadRateBPSNormal
public static int getMaxUploadRateBPSNormal()
-
getMaxUploadRateBPSSeedingOnly
public static int getMaxUploadRateBPSSeedingOnly()
-
getMaxDownloadRateBPS
public static int getMaxDownloadRateBPS()
This method is for display purposes only, the internal rate limiting is 10% higher than returned by this method!
-
getCryptoRequired
public static boolean getCryptoRequired(int override_level)
-
initialize
public void initialize(Core _core)
-
getSingleton
public static NetworkManager getSingleton()
Get the singleton instance of the network manager.- Returns:
- the network manager
-
createConnection
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).- Parameters:
remote_address
- to connect toencoder
- default message stream encoder to use for the outgoing queuedecoder
- default message stream decoder to use for the incoming queue- Returns:
- a new connection
-
requestIncomingConnectionRouting
public void requestIncomingConnectionRouting(NetworkManager.ByteMatcher matcher, NetworkManager.RoutingListener listener, MessageStreamFactory factory)
Request the acceptance and routing of new incoming connections that match the given initial byte sequence.- Parameters:
matcher
- initial byte sequence used for routinglistener
- for handling new inbound connectionsfactory
- to use for creating default stream encoder/decoders
-
bindTransport
public NetworkConnection bindTransport(Transport transport, MessageStreamEncoder encoder, MessageStreamDecoder decoder)
-
cancelIncomingConnectionRouting
public void cancelIncomingConnectionRouting(NetworkManager.ByteMatcher matcher)
Cancel a request for inbound connection routing.- Parameters:
matcher
- byte sequence originally used to register
-
addWriteEntity
public void addWriteEntity(RateControlledEntity entity, int partition_id)
Add an upload entity for write processing.- Parameters:
entity
- to add
-
removeWriteEntity
public boolean removeWriteEntity(RateControlledEntity entity)
Remove an upload entity from write processing.- Parameters:
entity
- to remove
-
addReadEntity
public void addReadEntity(RateControlledEntity entity, int partition_id)
Add a download entity for read processing.- Parameters:
entity
- to add
-
removeReadEntity
public boolean removeReadEntity(RateControlledEntity entity)
Remove a download entity from read processing.- Parameters:
entity
- to remove
-
getConnections
public java.util.Set<NetworkConnectionBase> getConnections()
-
startTransferProcessing
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.- Parameters:
peer_connection
- to register for network transfer processingupload_group
- upload rate limit groupdownload_group
- download rate limit group
-
stopTransferProcessing
public void stopTransferProcessing(NetworkConnectionBase peer_connection)
Cancel network upload and download handling for the given connection.- Parameters:
peer_connection
- to cancel
-
upgradeTransferProcessing
public void upgradeTransferProcessing(NetworkConnectionBase peer_connection, int partition_id)
Upgrade the given connection to high-speed network transfer handling.- Parameters:
peer_connection
- to upgrade
-
downgradeTransferProcessing
public void downgradeTransferProcessing(NetworkConnectionBase peer_connection)
Downgrade the given connection back to a normal-speed network transfer handling.- Parameters:
peer_connection
- to downgrade
-
getUploadProcessor
public TransferProcessor getUploadProcessor()
-
addRateLimiter
public void addRateLimiter(NetworkConnectionBase peer_connection, LimitedRateGroup group, boolean upload)
-
removeRateLimiter
public void removeRateLimiter(NetworkConnectionBase peer_connection, LimitedRateGroup group, boolean upload)
-
getRateHandler
public RateHandler getRateHandler(boolean upload, boolean lan)
-
getRateHandler
public RateHandler getRateHandler(NetworkConnectionBase peer_connection, boolean upload)
-
-