10 05, 2005

ÅжÏÊDz»ÊDZ¾»úip

 public static boolean isLocalClient(String clientIP){
     //logger.debug("client ip is " + clientIP);
  if (null == clientIP ) {
      return false;  
  }
  if ("127.0.0.1".equals(clientIP)) {
      return true;  
  }
  InetAddress[] localIP = getLocalIP();
          
  for(int i =0 ;i <localIP.length ;i++){
      if (localIP[i].getHostAddress().equals(clientIP)){
       return true; 
      } 
  }
  return false;
 }
 

 public static InetAddress[] getLocalIP(){
  
  InetAddress[] ia = null;
  
  try{
      ia = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());
  }catch(Exception e){
   logger.error("getLocalIP error " ,e);
  }
  return ia;
 }
 

ÆäÖУ¬127.0.0.1Õâ¸öµØÖ·£¬ÔÚwindowsϲ»ÄÜÓÃÉÏÃæµÄ·½·¨µÃµ½£¬ËùÒÔÖ®ºóÊÖ¹¤Ð´×ÅÅжÏÁË¡£

×îлظ´