From 232eca98bbba968ea8fb7d22cce35b2cb624176b Mon Sep 17 00:00:00 2001 From: Emil Ivov Date: Tue, 14 Oct 2008 09:51:21 +0000 Subject: [PATCH] Adding extra logging to help diagnoze wrong localhost selections. --- .../NetworkAddressManagerServiceImpl.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java b/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java index be131d5f1..0e114a2a3 100644 --- a/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java +++ b/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java @@ -237,11 +237,17 @@ public void stop() */ public synchronized InetAddress getLocalHost(InetAddress intendedDestination) { + if(logger.isTraceEnabled()) + { + logger.trace("Querying a localhost addr for dst=" + + intendedDestination); + + } //no point in making sure that the localHostFinderSocket is initialized. //better let it through a NullPointerException. InetAddress localHost = null; localHostFinderSocket.connect(intendedDestination - , this.RANDOM_ADDR_DISC_PORT); + , RANDOM_ADDR_DISC_PORT); localHost = localHostFinderSocket.getLocalAddress(); localHostFinderSocket.disconnect(); //windows socket implementations return the any address so we need to @@ -249,6 +255,8 @@ public synchronized InetAddress getLocalHost(InetAddress intendedDestination) //better on windows so lets hope it'll do the trick. if( localHost.isAnyLocalAddress()) { + logger.trace("Socket returned the AnyLocalAddress. "+ + "Trying a workaround."); try { //all that's inside the if is an ugly IPv6 hack @@ -276,6 +284,11 @@ public synchronized InetAddress getLocalHost(InetAddress intendedDestination) && !address.isSiteLocalAddress() && !address.isLoopbackAddress()) { + if(logger.isTraceEnabled()) + { + logger.trace("will return ipv6 addr " + + address); + } return address; } } @@ -293,6 +306,11 @@ public synchronized InetAddress getLocalHost(InetAddress intendedDestination) } } + if(logger.isTraceEnabled()) + { + logger.trace("Will return the following localhost address" + + localHost); + } return localHost; }