Esempio n. 1
0
        private static InetAddress[] getAllByName0(String host, InetAddress reqAddr, bool check)
        {
            /* If it gets here it is presumed to be a hostname */
            /* Cache.get can return: null, unknownAddress, or InetAddress[] */

            /* make sure the connection to the host is allowed, before we
             * give out a hostname
             */
//          if (check)
//          {
//              SecurityManager security = System.getSecurityManager();
//              if (security != null)
//              {
//                  security.checkConnect(host, -1);
//              }
//          }
//
//          InetAddress[] addresses = getCachedAddresses(host);
//
//          /* If no entry in cache, then do the host lookup */
//          if (addresses == null)
//          {
//              addresses = getAddressesFromNameService(host, reqAddr);
//          }
//
//          if (addresses == unknown_array)
//              throw new UnknownHostException(host);
//
//          return addresses.clone();
            return(null);
        }
Esempio n. 2
0
 String getHostName(bool check)
 {
     if (holder().getHostName() == null)
     {
         holder().hostName = InetAddress.getHostFromNameService(this, check);
     }
     return(holder().getHostName());
 }
Esempio n. 3
0
 public InetSocketAddressHolder(String hostname, InetAddress addr, int port)
 {
     this.hostname = hostname;
     this.addr     = addr;
     this.port     = port;
 }
Esempio n. 4
0
        private static String getHostFromNameService(InetAddress addr, bool check)
        {
//          String host = null;
//          foreach (NameService nameService in nameServices)
//          {
//              try
//              {
//                  // first lookup the hostname
//                  host = nameService.getHostByAddr(addr.getAddress());
//
//                  /* check to see if calling code is allowed to know
//                   * the hostname for this IP address, ie, connect to the host
//                   */
//                  if (check)
//                  {
//                      SecurityManager sec = System.getSecurityManager();
//
//                      if (sec != null)
//                      {
//                          sec.checkConnect(host, -1);
//                      }
//                  }
//
//                  /* now get all the IP addresses for this hostname,
//                   * and make sure one of them matches the original IP
//                   * address. We do this to try and prevent spoofing.
//                   */
//                  InetAddress[] arr = InetAddress.getAllByName0(host, check);
//                  bool ok = false;
//
//                  if (arr != null)
//                  {
//                      for (int i = 0; !ok && i < arr.Length; i++)
//                      {
//                          ok = addr.Equals(arr[i]);
//                      }
//                  }
//
//                  //XXX: if it looks a spoof just return the address?
//                  if (!ok)
//                  {
//                      host = addr.getHostAddress();
//                      return host;
//                  }
//
//                  break;
//
//              }
//              catch (SecurityException e)
//              {
//                  host = addr.getHostAddress();
//                  break;
//              }
//              catch (UnknownHostException e)
//              {
//                  host = addr.getHostAddress();
//                  // let next provider resolve the hostname
//              }
//          }
//
//          return host;
            return(null);
        }