Class NetworkAdminImpl
java.lang.Object
com.biglybt.core.networkmanager.admin.NetworkAdmin
com.biglybt.core.networkmanager.admin.impl.NetworkAdminImpl
- All Implemented Interfaces:
AEDiagnosticsEvidenceGenerator
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
protected class
protected static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate InetAddress[]
private final Map<String,
NetworkAdminImpl.AddressHistoryRecord> private long
private static InetAddress
private static InetAddress
private static InetAddress
private final List
private final List
private static final int
private final AsyncDispatcher
(package private) final Map<InetAddress,
NetworkAdminASN> static final int
static final int
(package private) long
private Object[]
static final int
static final int
private InetAddress[]
private static final String
private boolean
private static final boolean
private static final AESemaphore
private static long
private static long
private static final InetAddress[]
private static AESemaphore
private static InetAddress
private static boolean
private static int
private static long
private static InetAddress
private final Object
private boolean
private boolean
private final boolean
private static final int
private boolean
private long
private List<NetworkInterface>
private final CopyOnWriteList<NetworkAdminPropertyChangeListener>
private static InetAddress
private static InetAddress
private boolean
private static final LogIDs
private static final int
private Set<NetworkInterface>
private boolean
private int
private int
private static final int
private static final int
private boolean
private boolean
private boolean
private boolean
(package private) final NetworkAdminRouteListener
Fields inherited from class com.biglybt.core.networkmanager.admin.NetworkAdmin
DNS_SPI_TEST_HOST, IP_PROTOCOL_VERSION_AUTO, IP_PROTOCOL_VERSION_REQUIRE_V4, IP_PROTOCOL_VERSION_REQUIRE_V6, PR_ADDITIONAL_SERVICE_ADDRESS, PR_AS, PR_DEFAULT_BIND_ADDRESS, PR_NAMES, PR_NETWORK_INTERFACES
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
private void
void
protected void
protected NetworkAdminASNImpl
ASNFromMap
(Map m) protected Map
protected void
bind
(ServerSocketChannel ssc, InetAddress address, int port) protected boolean[]
bytesToBits
(byte[] bytes) private InetAddress[]
calcBindAddresses
(String addressString, boolean enforceBind) protected boolean
canBind
(InetAddress bind_ip) protected boolean
canConnectWithBind
(InetAddress bind_address, int timeout) boolean
canPing()
boolean
private int
(package private) void
private String
checkBindAddresses
(boolean log_alerts) (package private) void
protected void
checkDefaultBindAddress
(boolean first_time) private void
(package private) void
protected boolean
checkNetworkInterfaces
(boolean first_time, boolean force) classifyRoute
(InetAddress address) (package private) void
createInboundProtocol
(Core core, int type, int port) createSocksProxy
(String host, int port, String username, String password) protected void
firePropertyChange
(String property) void
generate
(IndentWriter writer) void
protected void
generateDiagnostics
(IndentWriter iw, NetworkAdminProtocol[] protocols) getAllBindAddresses
(boolean include_wildcard) Returns the list of current addresses that can successfully be bound to with an ephemeral portprivate InetAddress[]
getBindableAddresses
(boolean ignore_loopback, boolean ignore_link_local) int
getBindablePort
(int prefer_port) Object[]
private String
getConfigKey
(NetworkInterface intf) getDefaultPublicAddress
(boolean peek) protected NetworkAdminASN
getFromASHistory
(InetAddress address) getInboundProtocols
(Core core) Object[]
getInterfaceForAddress
(InetAddress address) getMultiHomedServiceBindAddresses
(boolean nio) getNATDevices
(Core core) getNetworkInterfacesAsString
(boolean only_with_addresses) getOutboundProtocols
(Core core) getRoute
(InetAddress interface_address, InetAddress target, int max_millis, NetworkAdminRouteListener listener) void
getRoutes
(InetAddress target, int max_millis, NetworkAdminRoutesListener listener) getSingleHomedServiceBindAddress
(int proto) Selects a bind address based on available host address and bind protocol familiesList<InetAddress[]>
private String
getString
(InetAddress[] addresses) private String
getString
(List<InetAddress> addresses) protected InetAddress
guessAddress
(List addresses) boolean
boolean
boolean
boolean
hasIPV6Potential
(boolean nio) boolean
private void
interfacesChanged
(boolean first_time) boolean
boolean
void
lookupASN
(InetAddress address) ad-hoc queryvoid
lookupASN
(InetAddress address, NetworkAdminASNListener listener) lookupCurrentASN
(InetAddress address) Only call if the supplied address is believed to be the current public addressstatic void
protected InetAddress
mapAddressToBindIP
(InetAddress address) private void
maybeVPN
(NetworkInterface intf) private boolean
maybeVPNDone
(NetworkInterface intf) boolean
mustBind()
private static List<InetAddress>
parseAddresses
(String str) pingTarget
(InetAddress interface_address, InetAddress target, int max_millis, NetworkAdminRouteListener listener) void
pingTargets
(InetAddress target, int max_millis, NetworkAdminRoutesListener listener) private void
void
resolveBindAddresses
(String bind_to) Given an interface name etc this will return the corresponding ip addressesvoid
runInitialChecks
(Core core) protected void
setIPv6Enabled
(boolean enabled) private void
private void
testProtocol
(NetworkAdminProtocol protocol) Methods inherited from class com.biglybt.core.networkmanager.admin.NetworkAdmin
getNetworkInterfacesAsString, getSingleHomedServiceBindAddress, getSingleton, hasIPV6Potential
-
Field Details
-
LOGID
-
FULL_INTF_PROBE
private static final boolean FULL_INTF_PROBE- See Also:
-
anyLocalAddress
-
anyLocalAddressIPv4
-
anyLocalAddressIPv6
-
localhostV4
-
localhostV6
-
INTERFACE_CHECK_MILLIS
private static final int INTERFACE_CHECK_MILLIS- See Also:
-
ROUTE_CHECK_MILLIS
private static final int ROUTE_CHECK_MILLIS- See Also:
-
ROUTE_CHECK_TICKS
private static final int ROUTE_CHECK_TICKS- See Also:
-
old_network_interfaces
-
address_history
-
address_history_update_time
private long address_history_update_time -
currentBindIPs
-
forceBind
private boolean forceBind -
supportsIPv6withNIO
private boolean supportsIPv6withNIO -
supportsIPv6
private boolean supportsIPv6 -
supportsIPv4
private boolean supportsIPv4 -
ignoreIPv4
private boolean ignoreIPv4 -
ignoreIPv6
private boolean ignoreIPv6 -
IPv6_enabled
private boolean IPv6_enabled -
preferIPv6
private boolean preferIPv6 -
additionalServiceBindIPs
-
testedIPv6Routing
private volatile boolean testedIPv6Routing -
roundRobinCounterV4
private int roundRobinCounterV4 -
roundRobinCounterV6
private int roundRobinCounterV6 -
logged_bind_force_issue
private boolean logged_bind_force_issue -
listeners
-
trace_route_listener
-
ASN_MIN_CHECK
private static final int ASN_MIN_CHECK- See Also:
-
last_asn_lookup_time
private long last_asn_lookup_time -
asn_ips_checked
-
as_history
-
async_asn_dispacher
-
MAX_ASYNC_ASN_LOOKUPS
private static final int MAX_ASYNC_ASN_LOOKUPS- See Also:
-
async_asn_history
-
initialised
private final boolean initialised -
DM_PAUSE_PENDING_KEY
- See Also:
-
last_getni_result
-
getni_lock
-
gdpa_lock
-
gdpa_sem
-
gdpa_last_fail
private static long gdpa_last_fail -
gdpa_last_lookup
private static long gdpa_last_lookup -
gdpa_initial_sem
-
gdpa6
-
gdpa6_count
private static int gdpa6_count -
gdpa6_last_good
-
gdpa6_last_check
private static long gdpa6_last_check -
gdpa6_checking
private static boolean gdpa6_checking -
BS_INACTIVE
public static final int BS_INACTIVE- See Also:
-
BS_OK
public static final int BS_OK- See Also:
-
BS_WARNING
public static final int BS_WARNING- See Also:
-
BS_ERROR
public static final int BS_ERROR- See Also:
-
bs_last_calc
long bs_last_calc -
bs_last_value
-
-
Constructor Details
-
NetworkAdminImpl
public NetworkAdminImpl()
-
-
Method Details
-
setup
-
addKickAllPeerListener
-
removeKickAllPeerListener
-
checkDNSSPI
private void checkDNSSPI() -
setIPv6Enabled
protected void setIPv6Enabled(boolean enabled) -
isIPV6Enabled
public boolean isIPV6Enabled()- Specified by:
isIPV6Enabled
in classNetworkAdmin
-
checkNetworkInterfaces
protected boolean checkNetworkInterfaces(boolean first_time, boolean force) -
getMultiHomedOutgoingRoundRobinBindAddress
- Specified by:
getMultiHomedOutgoingRoundRobinBindAddress
in classNetworkAdmin
-
setupAdditionalServiceBindIPs
-
getMultiHomedServiceBindAddresses
- Specified by:
getMultiHomedServiceBindAddresses
in classNetworkAdmin
-
getSingleHomedServiceBindAddress
- Specified by:
getSingleHomedServiceBindAddress
in classNetworkAdmin
-
getSingleHomedServiceBinding
public InetAddress[] getSingleHomedServiceBinding(String host) throws UnknownHostException, UnsupportedAddressTypeException Description copied from class:NetworkAdmin
Selects a bind address based on available host address and bind protocol families- Specified by:
getSingleHomedServiceBinding
in classNetworkAdmin
- Returns:
- Array with 2 entries, first is selected host address, second is selected bind address (possibly null of course)
- Throws:
UnknownHostException
UnsupportedAddressTypeException
-
getSingleHomedServiceBindings
public List<InetAddress[]> getSingleHomedServiceBindings(String host) throws UnknownHostException, UnsupportedAddressTypeException - Specified by:
getSingleHomedServiceBindings
in classNetworkAdmin
- Throws:
UnknownHostException
UnsupportedAddressTypeException
-
getAllBindAddresses
- Specified by:
getAllBindAddresses
in classNetworkAdmin
-
resolveBindAddresses
Description copied from class:NetworkAdmin
Given an interface name etc this will return the corresponding ip addresses- Specified by:
resolveBindAddresses
in classNetworkAdmin
- Returns:
-
parseAddresses
-
calcBindAddresses
-
checkBindAddresses
-
checkDefaultBindAddress
protected void checkDefaultBindAddress(boolean first_time) -
getNetworkInterfacesAsString
- Specified by:
getNetworkInterfacesAsString
in classNetworkAdmin
-
hasIPV4Potential
public boolean hasIPV4Potential()- Specified by:
hasIPV4Potential
in classNetworkAdmin
-
hasIPV6Potential
public boolean hasIPV6Potential(boolean nio) - Specified by:
hasIPV6Potential
in classNetworkAdmin
-
getLoopbackAddress
- Specified by:
getLoopbackAddress
in classNetworkAdmin
-
getBindableAddresses
Description copied from class:NetworkAdmin
Returns the list of current addresses that can successfully be bound to with an ephemeral port- Specified by:
getBindableAddresses
in classNetworkAdmin
- Returns:
-
getBindableAddresses
-
canBind
-
getBindablePort
- Specified by:
getBindablePort
in classNetworkAdmin
- Throws:
IOException
-
bind
- Throws:
IOException
-
guessRoutableBindAddress
- Specified by:
guessRoutableBindAddress
in classNetworkAdmin
-
getAlternativeProtocolBindAddress
- Specified by:
getAlternativeProtocolBindAddress
in classNetworkAdmin
-
canConnectWithBind
-
mapAddressToBindIP
-
bytesToBits
protected boolean[] bytesToBits(byte[] bytes) -
guessAddress
-
interfacesChanged
private void interfacesChanged(boolean first_time) -
getDefaultPublicAddress
- Specified by:
getDefaultPublicAddress
in classNetworkAdmin
-
getDefaultPublicAddress
- Specified by:
getDefaultPublicAddress
in classNetworkAdmin
-
getDefaultPublicAddressV6
- Specified by:
getDefaultPublicAddressV6
in classNetworkAdmin
-
hasDHTIPV4
public boolean hasDHTIPV4()- Specified by:
hasDHTIPV4
in classNetworkAdmin
-
hasDHTIPV6
public boolean hasDHTIPV6()- Specified by:
hasDHTIPV6
in classNetworkAdmin
-
firePropertyChange
-
getInterfaces
- Specified by:
getInterfaces
in classNetworkAdmin
-
getOutboundProtocols
- Specified by:
getOutboundProtocols
in classNetworkAdmin
-
createInboundProtocol
- Specified by:
createInboundProtocol
in classNetworkAdmin
-
getInboundProtocols
- Specified by:
getInboundProtocols
in classNetworkAdmin
-
testProtocol
- Specified by:
testProtocol
in classNetworkAdmin
- Throws:
NetworkAdminException
-
isSocksActive
public boolean isSocksActive()- Specified by:
isSocksActive
in classNetworkAdmin
-
createSocksProxy
public NetworkAdminSocksProxy createSocksProxy(String host, int port, String username, String password) - Specified by:
createSocksProxy
in classNetworkAdmin
-
getSocksProxies
- Specified by:
getSocksProxies
in classNetworkAdmin
-
getHTTPProxy
- Specified by:
getHTTPProxy
in classNetworkAdmin
-
getNATDevices
- Specified by:
getNATDevices
in classNetworkAdmin
-
getCurrentASN
- Specified by:
getCurrentASN
in classNetworkAdmin
-
ASNToMap
-
ASNFromMap
-
lookupCurrentASN
Description copied from class:NetworkAdmin
Only call if the supplied address is believed to be the current public address- Specified by:
lookupCurrentASN
in classNetworkAdmin
- Returns:
- Throws:
NetworkAdminException
-
lookupASN
Description copied from class:NetworkAdmin
ad-hoc query- Specified by:
lookupASN
in classNetworkAdmin
- Returns:
- Throws:
NetworkAdminException
-
lookupASN
- Specified by:
lookupASN
in classNetworkAdmin
-
addToASHistory
-
getFromASHistory
-
runInitialChecks
- Specified by:
runInitialChecks
in classNetworkAdmin
-
canTraceRoute
public boolean canTraceRoute()- Specified by:
canTraceRoute
in classNetworkAdmin
-
getRoute
public NetworkAdminNode[] getRoute(InetAddress interface_address, InetAddress target, int max_millis, NetworkAdminRouteListener listener) throws NetworkAdminException - Throws:
NetworkAdminException
-
canPing
public boolean canPing()- Specified by:
canPing
in classNetworkAdmin
-
pingTarget
public NetworkAdminNode pingTarget(InetAddress interface_address, InetAddress target, int max_millis, NetworkAdminRouteListener listener) throws NetworkAdminException - Throws:
NetworkAdminException
-
getRoutes
public void getRoutes(InetAddress target, int max_millis, NetworkAdminRoutesListener listener) throws NetworkAdminException - Specified by:
getRoutes
in classNetworkAdmin
- Throws:
NetworkAdminException
-
pingTargets
public void pingTargets(InetAddress target, int max_millis, NetworkAdminRoutesListener listener) throws NetworkAdminException - Specified by:
pingTargets
in classNetworkAdmin
- Throws:
NetworkAdminException
-
mustBind
public boolean mustBind()- Specified by:
mustBind
in classNetworkAdmin
-
hasMissingForcedBind
public boolean hasMissingForcedBind()- Specified by:
hasMissingForcedBind
in classNetworkAdmin
-
getBindStatus
- Specified by:
getBindStatus
in classNetworkAdmin
-
getBindingStatus
-
getString
-
checkConnectionRoutes
void checkConnectionRoutes() -
checkActiveConnections
void checkActiveConnections() -
checkIPV6Routing
void checkIPV6Routing() -
clearMaybeVPNs
void clearMaybeVPNs() -
maybeVPNDone
-
maybeVPN
-
getConfigKey
-
categoriseIntf
-
classifyRoute
- Specified by:
classifyRoute
in classNetworkAdmin
-
getInterfaceForAddress
- Specified by:
getInterfaceForAddress
in classNetworkAdmin
- Returns:
- { NetworkInterface, InetAddress (best intf address)}, {NetworkInterface} or {InetAddress (nomatch, same as arg)}
-
addPropertyChangeListener
- Specified by:
addPropertyChangeListener
in classNetworkAdmin
-
addAndFirePropertyChangeListener
- Specified by:
addAndFirePropertyChangeListener
in classNetworkAdmin
-
removePropertyChangeListener
- Specified by:
removePropertyChangeListener
in classNetworkAdmin
-
generate
- Specified by:
generate
in interfaceAEDiagnosticsEvidenceGenerator
-
getString
-
generateDiagnostics
- Specified by:
generateDiagnostics
in classNetworkAdmin
-
generateDiagnostics
-
logNATStatus
- Specified by:
logNATStatus
in classNetworkAdmin
-
main
-