Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 52912 invoked from network); 5 Mar 2004 16:28:50 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 5 Mar 2004 16:28:50 -0000 Received: (qmail 51961 invoked by uid 500); 5 Mar 2004 16:28:37 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 51931 invoked by uid 500); 5 Mar 2004 16:28:37 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 51870 invoked from network); 5 Mar 2004 16:28:36 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 5 Mar 2004 16:28:36 -0000 Received: (qmail 52658 invoked by uid 1365); 5 Mar 2004 16:28:41 -0000 Date: 5 Mar 2004 16:28:41 -0000 Message-ID: <20040305162841.52657.qmail@minotaur.apache.org> From: stevel@apache.org To: ws-axis-cvs@apache.org Subject: cvs commit: ws-axis/java/src/org/apache/axis/transport/http SimpleAxisWorker.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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; } }