Package com.biglybt.core.peer.util
Class PeerUtils
- java.lang.Object
-
- com.biglybt.core.peer.util.PeerUtils
-
public class PeerUtils extends java.lang.Object
Varies peer connection utility methods.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String[]
asn_failed
private static java.lang.Object
asn_key
private static java.lang.Object
asn_pending
static java.lang.String
CC_UNKNOWN
(package private) static java.lang.String
chars
private static java.lang.String
CONFIG_MAX_CONN_PER_TORRENT
private static java.lang.String
CONFIG_MAX_CONN_TOTAL
private static java.lang.Object
country_key
private static LocationProvider
country_provider
private static long
country_provider_last_check
private static java.util.Set<java.lang.Integer>
ignore_peer_ports
static int
MAX_CONNECTIONS_PER_TORRENT
static int
MAX_CONNECTIONS_TOTAL
private static byte[]
na_last_ip4
private static long
na_last_ip4_time
private static byte[]
na_last_ip6
private static long
na_last_ip6_time
private static int
na_tcp_port
private static java.lang.Object
net_key
private static NetworkAdmin
network_admin
private static java.lang.Object
ni_key
private static java.lang.Object
ni_null
-
Constructor Summary
Constructors Constructor Description PeerUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
createPeerID()
static byte[]
createWebSeedPeerID()
static java.lang.String[]
getASandASN(PEPeer peer)
static java.lang.String
getASN(PEPeer peer)
static java.lang.String[]
getCountryDetails(PEPeer peer)
static java.lang.String[]
getCountryDetails(Peer peer)
static java.lang.String[]
getCountryDetails(java.net.InetAddress address)
private static LocationProvider
getCountryProvider()
static java.net.NetworkInterface
getLocalNetworkInterface(PEPeer peer)
static java.lang.String
getNetwork(PEPeer peer)
static int
getPeerPriority(byte[] peer_address, int peer_port)
private static int
getPeerPriority(byte[] a1, int port1, byte[] a2, int port2)
static int
getPeerPriority(byte[] peer_address, short peer_port)
static int
getPeerPriority(java.lang.String address, int port)
static int
getPeerPriority(java.net.InetAddress address, int peer_port)
static boolean
ignorePeerPort(int port)
static int
numNewConnectionsAllowed(PeerIdentityDataID data_id, int specific_max)
Get the number of new peer connections allowed for the given data item, within the configured per-torrent and global connection limits.private static void
readIgnorePeerPorts()
-
-
-
Field Detail
-
CC_UNKNOWN
public static final java.lang.String CC_UNKNOWN
- See Also:
- Constant Field Values
-
CONFIG_MAX_CONN_PER_TORRENT
private static final java.lang.String CONFIG_MAX_CONN_PER_TORRENT
- See Also:
- Constant Field Values
-
CONFIG_MAX_CONN_TOTAL
private static final java.lang.String CONFIG_MAX_CONN_TOTAL
- See Also:
- Constant Field Values
-
MAX_CONNECTIONS_PER_TORRENT
public static int MAX_CONNECTIONS_PER_TORRENT
-
MAX_CONNECTIONS_TOTAL
public static int MAX_CONNECTIONS_TOTAL
-
network_admin
private static final NetworkAdmin network_admin
-
na_last_ip4_time
private static volatile long na_last_ip4_time
-
na_last_ip6_time
private static volatile long na_last_ip6_time
-
na_last_ip4
private static volatile byte[] na_last_ip4
-
na_last_ip6
private static volatile byte[] na_last_ip6
-
na_tcp_port
private static int na_tcp_port
-
ignore_peer_ports
private static final java.util.Set<java.lang.Integer> ignore_peer_ports
-
chars
static final java.lang.String chars
- See Also:
- Constant Field Values
-
country_provider
private static volatile LocationProvider country_provider
-
country_provider_last_check
private static long country_provider_last_check
-
country_key
private static final java.lang.Object country_key
-
net_key
private static final java.lang.Object net_key
-
ni_key
private static final java.lang.Object ni_key
-
ni_null
private static final java.lang.Object ni_null
-
asn_key
private static final java.lang.Object asn_key
-
asn_pending
private static final java.lang.Object asn_pending
-
asn_failed
private static final java.lang.String[] asn_failed
-
-
Method Detail
-
getPeerPriority
public static int getPeerPriority(java.lang.String address, int port)
-
getPeerPriority
public static int getPeerPriority(java.net.InetAddress address, int peer_port)
-
getPeerPriority
public static int getPeerPriority(byte[] peer_address, short peer_port)
-
getPeerPriority
public static int getPeerPriority(byte[] peer_address, int peer_port)
-
getPeerPriority
private static int getPeerPriority(byte[] a1, int port1, byte[] a2, int port2)
-
numNewConnectionsAllowed
public static int numNewConnectionsAllowed(PeerIdentityDataID data_id, int specific_max)
Get the number of new peer connections allowed for the given data item, within the configured per-torrent and global connection limits.- Returns:
- max number of new connections allowed, or -1 if there is no limit
-
readIgnorePeerPorts
private static void readIgnorePeerPorts()
-
ignorePeerPort
public static boolean ignorePeerPort(int port)
-
createPeerID
public static byte[] createPeerID()
-
createWebSeedPeerID
public static byte[] createWebSeedPeerID()
-
getCountryProvider
private static LocationProvider getCountryProvider()
-
getCountryDetails
public static java.lang.String[] getCountryDetails(Peer peer)
-
getCountryDetails
public static java.lang.String[] getCountryDetails(PEPeer peer)
-
getCountryDetails
public static java.lang.String[] getCountryDetails(java.net.InetAddress address)
-
getNetwork
public static java.lang.String getNetwork(PEPeer peer)
-
getLocalNetworkInterface
public static java.net.NetworkInterface getLocalNetworkInterface(PEPeer peer)
-
getASN
public static java.lang.String getASN(PEPeer peer)
- Parameters:
peer
-- Returns:
- null if lookup pending, "" or ASN otherwise
-
getASandASN
public static java.lang.String[] getASandASN(PEPeer peer)
- Parameters:
peer
-- Returns:
- null if pending, String[] of { as, asn } or { "", "" } if unavailable
-
-