diff options
author | Michael P. Masterson | 2012-03-27 22:49:54 +0000 |
---|---|---|
committer | Roberto E. Escobar | 2012-03-27 22:49:54 +0000 |
commit | 46029c0c6e9937f989a6f1a6178d7a71f9410f9e (patch) | |
tree | 78581310ec7cc2468aa5efeaad2779de5e6e90e7 | |
parent | c56fed99bc4de04dcc704fc1766c41d6063bcdd3 (diff) | |
download | org.eclipse.osee-46029c0c6e9937f989a6f1a6178d7a71f9410f9e.tar.gz org.eclipse.osee-46029c0c6e9937f989a6f1a6178d7a71f9410f9e.tar.xz org.eclipse.osee-46029c0c6e9937f989a6f1a6178d7a71f9410f9e.zip |
feature[ats_2FKP5]: Fix address string for ipv6 compatibility
-rw-r--r-- | plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteServiceStarterImpl.java | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteServiceStarterImpl.java b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteServiceStarterImpl.java index 7e70926a25f..1b40b012139 100644 --- a/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteServiceStarterImpl.java +++ b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteServiceStarterImpl.java @@ -14,6 +14,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.Serializable; +import java.net.Inet6Address; import java.net.InetAddress; import java.net.URI; import java.net.UnknownHostException; @@ -189,22 +190,18 @@ public class OteServiceStarterImpl implements OteServiceStarter, ServiceInfoPopu private String getAddress() throws UnknownHostException { InetAddress[] all = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName()); - String addressAsString = all[0].getHostAddress(); - int local = 0; - for (int i = 0; i < all.length; i++) { - if (all[i].getHostAddress().contains("192.168")) { - local = i; - } - } - if (all.length > 1) { - for (int i = 0; i < all.length; i++) { - if (i != local) { - addressAsString = all[i].getHostAddress(); - break; - } - } + String defaultAddress = all[0].getHostAddress(); + for (InetAddress address : all ) { + if(!address.isSiteLocalAddress()) + { + String firstRealLocalAddress = address.getHostAddress(); + if (address instanceof Inet6Address) { + firstRealLocalAddress = "[" + firstRealLocalAddress + "]"; + } + return firstRealLocalAddress; + } } - return addressAsString; + return defaultAddress; } private class ListenForHostRequest extends OseeMessagingListener { |