}
return( external_address );
}
DHTPlugin dht = adapter.getDHTPlugin();
// if DHT has informed us of an address then we use this - most reliable up to date one
// unless the version server cache time is more recent
if ( dht_address != null && dht_address_time <= SystemTime.getCurrentTime()){
AZInstanceManagerAdapter.VCPublicAddress a = adapter.getVCPublicAddress();
if ( a != null ){
long cache_time = a.getCacheTime();
if ( cache_time <= dht_address_time ){
external_address = dht_address;
}
}
}
if ( external_address == null &&
( dht == null || dht.getStatus() != DHTPlugin.STATUS_RUNNING )){
// use cached version if available and the DHT isn't
AZInstanceManagerAdapter.VCPublicAddress a = adapter.getVCPublicAddress();
if ( a != null ){
try{
external_address = InetAddress.getByName( a.getAddress());
}catch( Throwable e ){
Debug.printStackTrace(e);
}
}
}
if ( external_address == null && dht != null ){
// no cache, use DHT (this will hang during initialisation, hence the use of cached
// version above
try{
InetAddress latest_dht_address = dht.getLocalAddress().getAddress().getAddress();
// ignore any v6 addresses from DHT
if ( sameFamily( internal_address, latest_dht_address )){