Package java.net

Examples of java.net.InetAddress$InetAddressHolder


    }
     
    protected boolean
    hasIPChanged()
    {
      InetAddress  latest_ip = buddy.getAdjustedIP();
     
      if ( latest_ip == null && current_ip == null ){
       
        return( false );
       
      }else if ( latest_ip == null || current_ip == null ){
       
        return( true );
       
      }else{
     
        return!current_ip.equals( latest_ip.getHostAddress()));
      }
    }
View Full Code Here


        getToolTip(
          BuddyPluginBuddy  buddy )
        {
          List addresses = buddy.getAdjustedIPs();
         
          InetAddress  ip  = buddy.getIP();
         
          InetAddress adj = buddy.getAdjustedIP();
         
          String  str = "";
         
          if ( ip == null ){
           
View Full Code Here

    Long h_type = (Long)root.get( "handshake_type" );
    if( h_type == null ) {  //only 2307+ send type
      h_type = new Long( HANDSHAKE_TYPE_PLAIN );
    }
   
    InetAddress ipv6 = null;
    if(root.get("ipv6") instanceof byte[])
  {
    try
    {
      InetAddress.getByAddress((byte[]) root.get("ipv6"));
View Full Code Here

   
    boolean  checked_public  = false;

    Set<InetAddress>  public_addresses = new HashSet<InetAddress>();
   
    InetAddress def_pa = admin.getDefaultPublicAddress();
   
    if ( def_pa != null ){
     
      log( "Default public address is " + def_pa.getHostAddress());
     
      addPublicAddress( public_addresses, def_pa );
     
      checked_public = true;
    }
   
    if ( doTest( TEST_PING_ROUTE )){
     
      log( "Testing routing for the following interfaces:" );
     
      NetworkAdminNetworkInterface[] interfaces = admin.getInterfaces();
     
      for (int i=0;i<interfaces.length;i++){
       
        NetworkAdminNetworkInterface  intf = interfaces[i];
       
        NetworkAdminNetworkInterfaceAddress[] addresses = intf.getAddresses();
       
        String  a_str = "";
       
        for (int j=0;j<addresses.length;j++){
         
          NetworkAdminNetworkInterfaceAddress address = addresses[j];
         
          InetAddress ia = address.getAddress();
         
          if ( ia.isLoopbackAddress() || ia instanceof Inet6Address ){
           
          }else{
           
            a_str += (a_str.length()==0?"":",") + ia.getHostAddress();
          }
        }
       
        if ( a_str.length() > 0 ){
         
          log( "    " + intf.getName() + "/" + intf.getDisplayName() + ": " + a_str );
        }
      }
     
      if ( admin.canPing()){
       
        log( "Running ping tests" );
       
        try{
          InetAddress  target_address = InetAddress.getByName( plugin.getPingTarget());
         
          final Map  active_pings = new HashMap();
         
          admin.pingTargets(
            target_address,
            ROUTE_TIMEOUT,
            new NetworkAdminRoutesListener()
            {
              private int  timeouts;
             
              public boolean
              foundNode(
                NetworkAdminNetworkInterfaceAddress    intf,
                NetworkAdminNode[]            route,
                int                    distance,
                int                    rtt )
              {
                if ( test_cancelled ){
                 
                  return( false );
                }
               
                synchronized( active_pings ){
                 
                  active_pings.put( intf, route );
                }
               
                log( "  " + intf.getAddress().getHostAddress() + " -> " + route[route.length-1].getAddress().getHostAddress());
               
                return( false );
              }
             
              public boolean
              timeout(
                NetworkAdminNetworkInterfaceAddress    intf,
                NetworkAdminNode[]            route,
                int                    distance )
              {
                if ( test_cancelled ){
                 
                  return( false );
                }
               
                log( "  " + intf.getAddress().getHostAddress() + " - timeout" );
               
                timeouts++;
               
                if ( timeouts >= 3 ){
                 
                  return( false );
                }
               
                return( true );
              }
            });
   
          if ( test_cancelled ){
           
            return;
          }
         
          int  num_routes = active_pings.size();
         
          if ( num_routes == 0 ){
           
            logError( "No active pings found!" );
           
          }else{
           
            log( "Found " + num_routes + " pings(s)" );
           
            Iterator it = active_pings.entrySet().iterator();
           
            while( it.hasNext()){
             
              Map.Entry entry = (Map.Entry)it.next();
             
              NetworkAdminNetworkInterfaceAddress address = (NetworkAdminNetworkInterfaceAddress)entry.getKey();
             
              NetworkAdminNode[]  route = (NetworkAdminNode[])entry.getValue();
             
              String  node_str = "";
             
              for (int i=0;i<route.length;i++){
               
                node_str += (i==0?"":",") + route[i].getAddress().getHostAddress();
              }
             
              log( "    " + address.getInterface().getName() + "/" + address.getAddress().getHostAddress() + " - " + node_str );
            }
          }
        }catch( Throwable e ){
         
          logError( "Pinging failed: " + Debug.getNestedExceptionMessage(e));
        }
      }else{
       
        logError( "Can't run ping test as not supported" );
      }
     
      if ( test_cancelled ){
       
        return;
      }
     
      if ( admin.canTraceRoute()){
       
        log( "Running trace route tests" );
       
        try{
          InetAddress  target_address = InetAddress.getByName( plugin.getPingTarget());
         
          final Map  active_routes = new HashMap();
         
          admin.getRoutes(
            target_address,
            ROUTE_TIMEOUT,
            new NetworkAdminRoutesListener()
            {
              private String  last_as = "";
             
              public boolean
              foundNode(
                NetworkAdminNetworkInterfaceAddress    intf,
                NetworkAdminNode[]            route,
                int                    distance,
                int                    rtt )
              {
                if ( test_cancelled ){
                 
                  return( false );
                }
               
                synchronized( active_routes ){
                 
                  active_routes.put( intf, route );
                }
               
                InetAddress ia = route[route.length-1].getAddress();
               
                String  as = "";
               
                if ( !ia.isLinkLocalAddress() && !ia.isSiteLocalAddress()){
                 
                  try{
                    NetworkAdminASN asn = admin.lookupASN( ia );
                   
                    as = asn.getString();
                   
                    if ( as.equals( last_as )){
                     
                      as = "";
                     
                    }else{
                     
                      last_as = as;
                    }
                  }catch( Throwable e ){
                   
                  }
                }
               
                log( "  " + intf.getAddress().getHostAddress() + " -> " + ia.getHostAddress() + " (hop=" + distance + ")" + (as.length()==0?"":( " - " + as )));
               
                return( true );
              }
             
              public boolean
              timeout(
                NetworkAdminNetworkInterfaceAddress    intf,
                NetworkAdminNode[]            route,
                int                    distance )
              {
                if ( test_cancelled ){
                 
                  return( false );
                }
               
                log( "  " + intf.getAddress().getHostAddress() + " - timeout (hop=" + distance + ")" );
   
                  // see if we're getting nowhere
               
                if ( route.length == 0 && distance >= 5 ){
               
                  logError( "    giving up, no responses" );
                 
                  return( false );
                }
               
                  // see if we've got far enough
               
                if ( route.length >= 5 && distance > 6 ){
                 
                  log( "    truncating, sufficient responses" );
   
                  return( false );
                }
               
                return( true );
              }
            });
   
          if ( test_cancelled ){
           
            return;
          }
         
          int  num_routes = active_routes.size();
         
          if ( num_routes == 0 ){
           
            logError( "No active routes found!" );
           
          }else{
           
            log( "Found " + num_routes + " route(s)" );
           
            Iterator it = active_routes.entrySet().iterator();
           
            while( it.hasNext()){
             
              Map.Entry entry = (Map.Entry)it.next();
             
              NetworkAdminNetworkInterfaceAddress address = (NetworkAdminNetworkInterfaceAddress)entry.getKey();
             
              NetworkAdminNode[]  route = (NetworkAdminNode[])entry.getValue();
             
              String  node_str = "";
             
              for (int i=0;i<route.length;i++){
               
                node_str += (i==0?"":",") + route[i].getAddress().getHostAddress();
              }
             
              log( "    " + address.getInterface().getName() + "/" + address.getAddress().getHostAddress() + " - " + node_str );
            }
          }
        }catch( Throwable e ){
         
          logError( "Route tracing failed: " + Debug.getNestedExceptionMessage(e));
        }
      }else{
         
        logError( "Can't run trace route test as not supported" );
      }
     
      if ( test_cancelled ){
       
        return;
      }
    }
   
    if ( doTest( TEST_NAT_PROXIES )){
 
      checked_public = true;
     
      NetworkAdminNATDevice[] nat_devices = admin.getNATDevices(core);
     
      log( nat_devices.length + " NAT device" + (nat_devices.length==1?"":"s") + " found" );
     
      for (int i=0;i<nat_devices.length;i++){
       
        NetworkAdminNATDevice device = nat_devices[i];
       
        InetAddress ext_address = device.getExternalAddress();
       
        addPublicAddress( public_addresses, ext_address );
       
        log( "    " + device.getString());
      }
     
      NetworkAdminSocksProxy[] socks_proxies = admin.getSocksProxies();
     
      if ( socks_proxies.length == 0 ){
       
        log( "No SOCKS proxy found" );

      }else if socks_proxies.length == 1 ){
       
        log( "One SOCKS proxy found" );
       
      }else{
       
        log( socks_proxies.length + " SOCKS proxies found" );
      }
     
      for (int i=0;i<socks_proxies.length;i++){
       
        NetworkAdminSocksProxy proxy = socks_proxies[i];
       
        log( "    " + proxy.getString());
      }
     
      NetworkAdminHTTPProxy http_proxy = admin.getHTTPProxy();
     
      if ( http_proxy == null ){
       
        log( "No HTTP proxy found" );
       
      }else{
       
        log( "HTTP proxy found" );
       
        log( "    " + http_proxy.getString());
      }
    }
   
    InetAddress[] bind_addresses = admin.getAllBindAddresses( false );
   
    int  num_binds = 0;
   
    for ( int i=0;i<bind_addresses.length;i++ ){
   
      if ( bind_addresses[i] != null ){
       
        num_binds++;
      }
    }
   
    if ( num_binds == 0 ){
     
      log( "No explicit bind address set" );
     
    }else{
   
      log( num_binds + " bind addresses" );
     
      for ( int i=0;i<bind_addresses.length;i++ ){
   
        if ( bind_addresses[i] != null ){
       
          log( "    " + bind_addresses[i].getHostAddress());
        }
      }
    }
   
    if ( doTest( TEST_OUTBOUND )){

      checked_public = true;
     
      NetworkAdminProtocol[] outbound_protocols = admin.getOutboundProtocols(core);
     
      if ( outbound_protocols.length == 0 ){
       
        log( "No outbound protocols" );
       
      }else{
       
        for (int i=0;i<outbound_protocols.length;i++){
         
          if ( test_cancelled ){
           
            return;
          }
         
          NetworkAdminProtocol protocol = outbound_protocols[i];
         
          log( "Testing " + protocol.getName());
         
          try{
            InetAddress public_address =
              protocol.test(
                null,
                new NetworkAdminProgressListener()
                {
                  public void
                  reportProgress(
                    String task )
                  {
                    log( "    " + task );
                  }
                });
           
            logSuccess( "    Test successful" );
           
            addPublicAddress( public_addresses, public_address );
           
          }catch( Throwable e ){
           
            logError( "    Test failed", e );
          }
        }
      }
    }
   
    if ( doTest( TEST_INBOUND )){

      checked_public = true;
     
      NetworkAdminProtocol[] inbound_protocols = admin.getInboundProtocols(core);
     
      if ( inbound_protocols.length == 0 ){
       
        log( "No inbound protocols" );
       
      }else{
       
        for (int i=0;i<inbound_protocols.length;i++){
         
          if ( test_cancelled ){
           
            return;
          }
         
          NetworkAdminProtocol protocol = inbound_protocols[i];
         
          log( "Testing " + protocol.getName());
         
          try{
            InetAddress public_address =
              protocol.test(
                null,
                new NetworkAdminProgressListener()
                {
                  public void
                  reportProgress(
                    String task )
                  {
                    log( "    " + task );
                  }
                });
           
            logSuccess( "    Test successful" );
 
            addPublicAddress( public_addresses, public_address );
           
          }catch( Throwable e ){
           
            logError( "    Test failed", e );
            logInfo"    Check your port forwarding for " + protocol.getTypeString() + " " + protocol.getPort());
          }
        }
      }
    }
   
    if ( checked_public ){
     
      if ( public_addresses.size() == 0 ){
       
        log( "No public addresses found" );
       
      }else{
       
        Iterator<InetAddress>  it = public_addresses.iterator();
       
        log( public_addresses.size() + " public/external addresses found" );
       
        while( it.hasNext()){
         
          InetAddress  pub_address = it.next();
         
          log( "    " + pub_address.getHostAddress());
         
          try{
            NetworkAdminASN asn = admin.lookupASN(pub_address);
           
            log( "    AS details: " + asn.getString());
View Full Code Here

        }
       
        if ( new_external_address == null ){
     
          InetAddress public_address = logger.getPluginInterface().getUtilities().getPublicAddress( v6 );
                     
          if ( public_address != null ){
             
            new_external_address = public_address.getHostAddress();
           
            log.log( "    External IP address obtained: " + new_external_address );
          }
        }
       
View Full Code Here

       * using the above explicit check then this is accurate
       * Only in the case where the above check fails do we believe the address
       * that we've been told about
       */
     
    InetAddress  ia = new_address.getAddress();
   
    if ( ia == null ){
     
      Debug.out( "reported new external address '" + new_address + "' is unresolved" );
     
      throw( new DHTTransportException( "Address '" + new_address + "' is unresolved" ));
    }
   
      // dump addresses incompatible with our protocol
   
    if (   ( ia instanceof Inet4Address && v6  ) ||
        ( ia instanceof Inet6Address && !v6 )){
     
        // reduce debug spam, just return
     
      // throw( new DHTTransportException( "Address " + new_address + " is incompatible with protocol family for " + external_address ));
     
      return;
    }
   
    final String  new_ip = ia.getHostAddress();
   
    if ( new_ip.equals( external_address )){
     
        // probably just be a second notification of an address change, return
        // "ok to retry" as it should now work
View Full Code Here

          { //ensure it's actually running
            long accept_idle = SystemTime.getCurrentTime() - server_selector.getTimeOfLastAccept();
            if (accept_idle > 10 * 60 * 1000)
            { //the socket server hasn't accepted any new connections in the last 10min
              //so manually test the listen port for connectivity
              InetAddress inet_address = server_selector.getBoundToAddress();
              try
              {
                if (inet_address == null)
                  inet_address = InetAddress.getByName("127.0.0.1"); //failback
                Socket sock = new Socket(inet_address, tcp_listen_port, inet_address, 0);
View Full Code Here

         
         
          listenFailCounts = new int[bindAddresses.length];
          for (int i = 0; i < bindAddresses.length; i++)
          {
            InetAddress bindAddress = bindAddresses[i];

            if(!NetworkAdmin.getSingleton().hasIPV6Potential(true) && bindAddress instanceof Inet6Address)
              continue;
           
            if (bindAddress != null)
View Full Code Here

  TcpSelectListener implements
  VirtualServerChannelSelector.SelectListener
  {
    public void newConnectionAccepted( final ServerSocketChannel server, final SocketChannel channel ) {

      InetAddress remote_ia = channel.socket().getInetAddress();

      if ( !( remote_ia.isLoopbackAddress() || remote_ia.isLinkLocalAddress() || remote_ia.isSiteLocalAddress())){
       
        last_non_local_connection_time = SystemTime.getCurrentTime();
      }
     
      //check for encrypted transport
View Full Code Here

   
    synchronized( this ){
           
      NetworkAdmin network_admin = NetworkAdmin.getSingleton();
         
      InetAddress latest_v4 = azureus_core.getInstanceManager().getMyInstance().getExternalAddress();
     
      InetAddress temp_v4 = updateAddress( current_v4, latest_v4, false );
     
      InetAddress latest_v6 = network_admin.getDefaultPublicAddressV6();
 
      InetAddress temp_v6 = updateAddress( current_v6, latest_v6, true );
     
      final TreeSet<String>  latest_v4_locals = new TreeSet<String>();
      final TreeSet<String>  latest_v6_locals = new TreeSet<String>();
     
      NetworkAdminNetworkInterface[] interfaces = network_admin.getInterfaces();
     
      List<Runnable>  to_do = new ArrayList<Runnable>();
     
      Set<String> existing_checked = new HashSet<String>( local_address_checks.keySet());
     
      for ( NetworkAdminNetworkInterface intf: interfaces ){
       
        NetworkAdminNetworkInterfaceAddress[] addresses = intf.getAddresses();
       
        for ( NetworkAdminNetworkInterfaceAddress address: addresses ){
         
          final InetAddress ia = address.getAddress();
         
          if ( ia.isLoopbackAddress()){
           
            continue;
          }
         
          if ( ia.isLinkLocalAddress() || ia.isSiteLocalAddress()){
           
            final String a_str = ia.getHostAddress();
           
            existing_checked.remove( a_str );
           
            Object[] check;
           
View Full Code Here

TOP

Related Classes of java.net.InetAddress$InetAddressHolder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.