com.aelitis.azureus.core.networkmanager.admin.impl
Class NetworkAdminImpl

java.lang.Object
  extended by com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin
      extended by com.aelitis.azureus.core.networkmanager.admin.impl.NetworkAdminImpl
All Implemented Interfaces:
AEDiagnosticsEvidenceGenerator

public class NetworkAdminImpl
extends NetworkAdmin
implements AEDiagnosticsEvidenceGenerator


Nested Class Summary
protected  class NetworkAdminImpl.networkInterface
           
protected static class NetworkAdminImpl.networkNode
           
 
Field Summary
static int BS_ERROR
           
static int BS_INACTIVE
           
static int BS_OK
           
static int BS_WARNING
           
 
Fields inherited from class com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin
IP_PROTOCOL_VERSION_AUTO, IP_PROTOCOL_VERSION_REQUIRE_V4, IP_PROTOCOL_VERSION_REQUIRE_V6, PR_AS, PR_DEFAULT_BIND_ADDRESS, PR_NAMES, PR_NETWORK_INTERFACES
 
Constructor Summary
NetworkAdminImpl()
           
 
Method Summary
 void addAndFirePropertyChangeListener(NetworkAdminPropertyChangeListener listener)
           
 void addPropertyChangeListener(NetworkAdminPropertyChangeListener listener)
           
protected  void addToASHistory(NetworkAdminASN asn)
           
protected  NetworkAdminASNImpl ASNFromMap(java.util.Map m)
           
protected  java.util.Map ASNToMap(NetworkAdminASNImpl x)
           
protected  void bind(java.nio.channels.ServerSocketChannel ssc, java.net.InetAddress address, int port)
           
protected  boolean[] bytesToBits(byte[] bytes)
           
protected  boolean canBind(java.net.InetAddress bind_ip)
           
protected  boolean canConnectWithBind(java.net.InetAddress bind_address, int timeout)
           
 boolean canPing()
           
 boolean canTraceRoute()
           
protected  void checkDefaultBindAddress(boolean first_time)
           
protected  boolean checkNetworkInterfaces(boolean first_time, boolean force)
           
 java.lang.String classifyRoute(java.net.InetAddress address)
           
 NetworkAdminProtocol createInboundProtocol(AzureusCore azureus_core, int type, int port)
           
 NetworkAdminSocksProxy createSocksProxy(java.lang.String host, int port, java.lang.String username, java.lang.String password)
           
protected  void firePropertyChange(java.lang.String property)
           
 void generate(IndentWriter writer)
           
 void generateDiagnostics(IndentWriter iw)
           
protected  void generateDiagnostics(IndentWriter iw, NetworkAdminProtocol[] protocols)
           
 java.net.InetAddress[] getAllBindAddresses(boolean include_wildcard)
           
 java.net.InetAddress[] getBindableAddresses()
          Returns the list of current addresses that can successfully be bound to with an ephemeral port
 int getBindablePort(int prefer_port)
           
 java.lang.Object[] getBindingStatus()
           
 java.lang.String getBindStatus()
           
 NetworkAdminASN getCurrentASN()
           
 java.net.InetAddress getDefaultPublicAddress()
           
 java.net.InetAddress getDefaultPublicAddress(boolean peek)
           
 java.net.InetAddress getDefaultPublicAddressV6()
           
 java.net.InetAddress getDefaultPublicAddressV6(boolean peek)
           
protected  NetworkAdminASN getFromASHistory(java.net.InetAddress address)
           
 NetworkAdminHTTPProxy getHTTPProxy()
           
 NetworkAdminProtocol[] getInboundProtocols(AzureusCore azureus_core)
           
 java.lang.Object[] getInterfaceForAddress(java.net.InetAddress address)
           
 NetworkAdminNetworkInterface[] getInterfaces()
           
 java.net.InetAddress getMultiHomedOutgoingRoundRobinBindAddress(java.net.InetAddress target)
           
 java.net.InetAddress[] getMultiHomedServiceBindAddresses(boolean nio)
           
 NetworkAdminNATDevice[] getNATDevices(AzureusCore azureus_core)
           
 java.lang.String getNetworkInterfacesAsString()
           
 NetworkAdminProtocol[] getOutboundProtocols(AzureusCore azureus_core)
           
 NetworkAdminNode[] getRoute(java.net.InetAddress interface_address, java.net.InetAddress target, int max_millis, NetworkAdminRouteListener listener)
           
 void getRoutes(java.net.InetAddress target, int max_millis, NetworkAdminRoutesListener listener)
           
 java.net.InetAddress getSingleHomedServiceBindAddress(int proto)
           
 NetworkAdminSocksProxy[] getSocksProxies()
           
protected  java.net.InetAddress guessAddress(java.util.List addresses)
           
 java.net.InetAddress guessRoutableBindAddress()
           
 boolean hasDHTIPV6()
           
 boolean hasIPV4Potential()
           
 boolean hasIPV6Potential(boolean nio)
           
 boolean hasMissingForcedBind()
           
 boolean isIPV6Enabled()
           
 boolean isSocksActive()
           
 void logNATStatus(IndentWriter iw)
           
 NetworkAdminASN lookupASN(java.net.InetAddress address)
          ad-hoc query
 void lookupASN(java.net.InetAddress address, NetworkAdminASNListener listener)
           
 NetworkAdminASN lookupCurrentASN(java.net.InetAddress address)
          Only call if the supplied address is believed to be the current public address
static void main(java.lang.String[] args)
           
protected  java.net.InetAddress mapAddressToBindIP(java.net.InetAddress address)
           
 boolean mustBind()
           
 NetworkAdminNode pingTarget(java.net.InetAddress interface_address, java.net.InetAddress target, int max_millis, NetworkAdminRouteListener listener)
           
 void pingTargets(java.net.InetAddress target, int max_millis, NetworkAdminRoutesListener listener)
           
 void removePropertyChangeListener(NetworkAdminPropertyChangeListener listener)
           
 java.net.InetAddress[] resolveBindAddresses(java.lang.String bind_to)
          Given an interface name etc this will return the corresponding ip addresses
 void runInitialChecks(AzureusCore azureus_core)
           
protected  void setIPv6Enabled(boolean enabled)
           
 java.net.InetAddress testProtocol(NetworkAdminProtocol protocol)
           
 
Methods inherited from class com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin
getSingleHomedServiceBindAddress, getSingleton, hasIPV6Potential
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BS_INACTIVE

public static final int BS_INACTIVE
See Also:
Constant Field Values

BS_OK

public static final int BS_OK
See Also:
Constant Field Values

BS_WARNING

public static final int BS_WARNING
See Also:
Constant Field Values

BS_ERROR

public static final int BS_ERROR
See Also:
Constant Field Values
Constructor Detail

NetworkAdminImpl

public NetworkAdminImpl()
Method Detail

setIPv6Enabled

protected void setIPv6Enabled(boolean enabled)

isIPV6Enabled

public boolean isIPV6Enabled()
Specified by:
isIPV6Enabled in class NetworkAdmin

checkNetworkInterfaces

protected boolean checkNetworkInterfaces(boolean first_time,
                                         boolean force)

getMultiHomedOutgoingRoundRobinBindAddress

public java.net.InetAddress getMultiHomedOutgoingRoundRobinBindAddress(java.net.InetAddress target)
Specified by:
getMultiHomedOutgoingRoundRobinBindAddress in class NetworkAdmin

getMultiHomedServiceBindAddresses

public java.net.InetAddress[] getMultiHomedServiceBindAddresses(boolean nio)
Specified by:
getMultiHomedServiceBindAddresses in class NetworkAdmin

getSingleHomedServiceBindAddress

public java.net.InetAddress getSingleHomedServiceBindAddress(int proto)
Specified by:
getSingleHomedServiceBindAddress in class NetworkAdmin

getAllBindAddresses

public java.net.InetAddress[] getAllBindAddresses(boolean include_wildcard)
Specified by:
getAllBindAddresses in class NetworkAdmin

resolveBindAddresses

public java.net.InetAddress[] resolveBindAddresses(java.lang.String bind_to)
Description copied from class: NetworkAdmin
Given an interface name etc this will return the corresponding ip addresses

Specified by:
resolveBindAddresses in class NetworkAdmin
Returns:

checkDefaultBindAddress

protected void checkDefaultBindAddress(boolean first_time)

getNetworkInterfacesAsString

public java.lang.String getNetworkInterfacesAsString()
Specified by:
getNetworkInterfacesAsString in class NetworkAdmin

hasIPV4Potential

public boolean hasIPV4Potential()
Specified by:
hasIPV4Potential in class NetworkAdmin

hasIPV6Potential

public boolean hasIPV6Potential(boolean nio)
Specified by:
hasIPV6Potential in class NetworkAdmin

getBindableAddresses

public java.net.InetAddress[] 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 class NetworkAdmin
Returns:

canBind

protected boolean canBind(java.net.InetAddress bind_ip)

getBindablePort

public int getBindablePort(int prefer_port)
                    throws java.io.IOException
Specified by:
getBindablePort in class NetworkAdmin
Throws:
java.io.IOException

bind

protected void bind(java.nio.channels.ServerSocketChannel ssc,
                    java.net.InetAddress address,
                    int port)
             throws java.io.IOException
Throws:
java.io.IOException

guessRoutableBindAddress

public java.net.InetAddress guessRoutableBindAddress()
Specified by:
guessRoutableBindAddress in class NetworkAdmin

canConnectWithBind

protected boolean canConnectWithBind(java.net.InetAddress bind_address,
                                     int timeout)

mapAddressToBindIP

protected java.net.InetAddress mapAddressToBindIP(java.net.InetAddress address)

bytesToBits

protected boolean[] bytesToBits(byte[] bytes)

guessAddress

protected java.net.InetAddress guessAddress(java.util.List addresses)

getDefaultPublicAddress

public java.net.InetAddress getDefaultPublicAddress()
Specified by:
getDefaultPublicAddress in class NetworkAdmin

getDefaultPublicAddress

public java.net.InetAddress getDefaultPublicAddress(boolean peek)
Specified by:
getDefaultPublicAddress in class NetworkAdmin

getDefaultPublicAddressV6

public java.net.InetAddress getDefaultPublicAddressV6()
Specified by:
getDefaultPublicAddressV6 in class NetworkAdmin

getDefaultPublicAddressV6

public java.net.InetAddress getDefaultPublicAddressV6(boolean peek)
Specified by:
getDefaultPublicAddressV6 in class NetworkAdmin

hasDHTIPV6

public boolean hasDHTIPV6()
Specified by:
hasDHTIPV6 in class NetworkAdmin

firePropertyChange

protected void firePropertyChange(java.lang.String property)

getInterfaces

public NetworkAdminNetworkInterface[] getInterfaces()
Specified by:
getInterfaces in class NetworkAdmin

getOutboundProtocols

public NetworkAdminProtocol[] getOutboundProtocols(AzureusCore azureus_core)
Specified by:
getOutboundProtocols in class NetworkAdmin

createInboundProtocol

public NetworkAdminProtocol createInboundProtocol(AzureusCore azureus_core,
                                                  int type,
                                                  int port)
Specified by:
createInboundProtocol in class NetworkAdmin

getInboundProtocols

public NetworkAdminProtocol[] getInboundProtocols(AzureusCore azureus_core)
Specified by:
getInboundProtocols in class NetworkAdmin

testProtocol

public java.net.InetAddress testProtocol(NetworkAdminProtocol protocol)
                                  throws NetworkAdminException
Specified by:
testProtocol in class NetworkAdmin
Throws:
NetworkAdminException

isSocksActive

public boolean isSocksActive()
Specified by:
isSocksActive in class NetworkAdmin

createSocksProxy

public NetworkAdminSocksProxy createSocksProxy(java.lang.String host,
                                               int port,
                                               java.lang.String username,
                                               java.lang.String password)
Specified by:
createSocksProxy in class NetworkAdmin

getSocksProxies

public NetworkAdminSocksProxy[] getSocksProxies()
Specified by:
getSocksProxies in class NetworkAdmin

getHTTPProxy

public NetworkAdminHTTPProxy getHTTPProxy()
Specified by:
getHTTPProxy in class NetworkAdmin

getNATDevices

public NetworkAdminNATDevice[] getNATDevices(AzureusCore azureus_core)
Specified by:
getNATDevices in class NetworkAdmin

getCurrentASN

public NetworkAdminASN getCurrentASN()
Specified by:
getCurrentASN in class NetworkAdmin

ASNToMap

protected java.util.Map ASNToMap(NetworkAdminASNImpl x)

ASNFromMap

protected NetworkAdminASNImpl ASNFromMap(java.util.Map m)

lookupCurrentASN

public NetworkAdminASN lookupCurrentASN(java.net.InetAddress address)
                                 throws NetworkAdminException
Description copied from class: NetworkAdmin
Only call if the supplied address is believed to be the current public address

Specified by:
lookupCurrentASN in class NetworkAdmin
Returns:
Throws:
NetworkAdminException

lookupASN

public NetworkAdminASN lookupASN(java.net.InetAddress address)
                          throws NetworkAdminException
Description copied from class: NetworkAdmin
ad-hoc query

Specified by:
lookupASN in class NetworkAdmin
Returns:
Throws:
NetworkAdminException

lookupASN

public void lookupASN(java.net.InetAddress address,
                      NetworkAdminASNListener listener)
Specified by:
lookupASN in class NetworkAdmin

addToASHistory

protected void addToASHistory(NetworkAdminASN asn)

getFromASHistory

protected NetworkAdminASN getFromASHistory(java.net.InetAddress address)

runInitialChecks

public void runInitialChecks(AzureusCore azureus_core)
Specified by:
runInitialChecks in class NetworkAdmin

canTraceRoute

public boolean canTraceRoute()
Specified by:
canTraceRoute in class NetworkAdmin

getRoute

public NetworkAdminNode[] getRoute(java.net.InetAddress interface_address,
                                   java.net.InetAddress target,
                                   int max_millis,
                                   NetworkAdminRouteListener listener)
                            throws NetworkAdminException
Throws:
NetworkAdminException

canPing

public boolean canPing()
Specified by:
canPing in class NetworkAdmin

pingTarget

public NetworkAdminNode pingTarget(java.net.InetAddress interface_address,
                                   java.net.InetAddress target,
                                   int max_millis,
                                   NetworkAdminRouteListener listener)
                            throws NetworkAdminException
Throws:
NetworkAdminException

getRoutes

public void getRoutes(java.net.InetAddress target,
                      int max_millis,
                      NetworkAdminRoutesListener listener)
               throws NetworkAdminException
Specified by:
getRoutes in class NetworkAdmin
Throws:
NetworkAdminException

pingTargets

public void pingTargets(java.net.InetAddress target,
                        int max_millis,
                        NetworkAdminRoutesListener listener)
                 throws NetworkAdminException
Specified by:
pingTargets in class NetworkAdmin
Throws:
NetworkAdminException

mustBind

public boolean mustBind()
Specified by:
mustBind in class NetworkAdmin

hasMissingForcedBind

public boolean hasMissingForcedBind()
Specified by:
hasMissingForcedBind in class NetworkAdmin

getBindStatus

public java.lang.String getBindStatus()
Specified by:
getBindStatus in class NetworkAdmin

getBindingStatus

public java.lang.Object[] getBindingStatus()

classifyRoute

public java.lang.String classifyRoute(java.net.InetAddress address)
Specified by:
classifyRoute in class NetworkAdmin

getInterfaceForAddress

public java.lang.Object[] getInterfaceForAddress(java.net.InetAddress address)

addPropertyChangeListener

public void addPropertyChangeListener(NetworkAdminPropertyChangeListener listener)
Specified by:
addPropertyChangeListener in class NetworkAdmin

addAndFirePropertyChangeListener

public void addAndFirePropertyChangeListener(NetworkAdminPropertyChangeListener listener)
Specified by:
addAndFirePropertyChangeListener in class NetworkAdmin

removePropertyChangeListener

public void removePropertyChangeListener(NetworkAdminPropertyChangeListener listener)
Specified by:
removePropertyChangeListener in class NetworkAdmin

generate

public void generate(IndentWriter writer)
Specified by:
generate in interface AEDiagnosticsEvidenceGenerator

generateDiagnostics

public void generateDiagnostics(IndentWriter iw)
Specified by:
generateDiagnostics in class NetworkAdmin

generateDiagnostics

protected void generateDiagnostics(IndentWriter iw,
                                   NetworkAdminProtocol[] protocols)

logNATStatus

public void logNATStatus(IndentWriter iw)
Specified by:
logNATStatus in class NetworkAdmin

main

public static void main(java.lang.String[] args)