axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject cvs commit: ws-axis/java/src/org/apache/axis/transport/http SimpleAxisWorker.java
Date Fri, 05 Mar 2004 16:28:41 GMT
stevel      2004/03/05 08:28:41

  Modified:    java/src/org/apache/axis/transport/http
                        SimpleAxisWorker.java
  Log:
  trying to stop this code always returning 127.0.0.1 when serving up urls
  
  Revision  Changes    Path
  1.35      +16 -5     ws-axis/java/src/org/apache/axis/transport/http/SimpleAxisWorker.java
  
  Index: SimpleAxisWorker.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/transport/http/SimpleAxisWorker.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- SimpleAxisWorker.java	5 Mar 2004 05:20:46 -0000	1.34
  +++ SimpleAxisWorker.java	5 Mar 2004 16:28:41 -0000	1.35
  @@ -735,18 +735,29 @@
        * One method for all host name lookups.
        */
       public static String getLocalHost() {
  -        // FIXME
           // This doesn't return anything but 0.0.0.0
           //  String hostname = serverSocket.getInetAddress().getHostAddress();
           // And this returns the hostname of the host on the other
           // end of the socket:
           //  String hostname = socket.getInetAddress().getHostName();
           // This works for 99% of the uses of SimpleAxisServer,
  -        // but is very stupid
  +        // but is very stupid. One challenge is that a machine may
  +        // have >1 network card, as on each attached network it will have a different
  +        // hostname.
  +        // The other challenge is that unmanaged networks lack reverse DNS. 
  +        InetAddress address;
  +        String hostname;
           try {
  -            return InetAddress.getLocalHost().getHostAddress();
  -        } catch (UnknownHostException uhe){
  -            return "localhost";
  +            address = InetAddress.getLocalHost();
  +            //force a best effort reverse DNS lookup
  +            hostname = address.getCanonicalHostName();
  +            if (hostname == null || hostname.length() == 0) {
  +                hostname = address.toString();
  +            }
  +        } catch (UnknownHostException noIpAddrException) {
  +            //bail out here
  +            hostname = "127.0.0.1";
           }
  +        return hostname;
       }
   }
  
  
  

Mime
View raw message