changeset 262:7d8f45cadd89

add parse port and hostAddress and rootAddress, when IPv6 adderss.
author oc
date Mon, 08 Dec 2014 04:48:23 +0900
parents 233c73b5b964
children 4075f68f1c91
files .DS_Store src/main/java/jp/ac/u_ryukyu/treevnc/TreeRootFinderListener.java src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncRootSelectionPanel.java
diffstat 3 files changed, 18 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
Binary file .DS_Store has changed
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRootFinderListener.java	Sun Dec 07 11:38:40 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRootFinderListener.java	Mon Dec 08 04:48:23 2014 +0900
@@ -9,7 +9,7 @@
 import com.glavsoft.viewer.swing.ConnectionParams;
 
 public class TreeRootFinderListener implements Runnable {
-	public static final String McastAddr = "224.0.0.1";
+	public static final String McastAddr = "FF02::1";
 	static final int BufSize = 1024;
 	private boolean stopFlag = false;
 	private ViewerInterface vps;
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncRootSelectionPanel.java	Sun Dec 07 11:38:40 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncRootSelectionPanel.java	Mon Dec 08 04:48:23 2014 +0900
@@ -113,13 +113,26 @@
 	public void actionPerformed(ActionEvent e) {
 		flag = true;
 		for (int t = 0; t < counter; t++) {
-			if (check[t].getState()) {
+            int ipv4AddressLength = 3;
+            int ipv6AddressLength = 17;
+            String port = null;
+            String hostAddress = null;
+            String rootAddress = null;
+ 			if (check[t].getState()) {
 				System.out.println(check[t].getLabel());
 				String str = check[t].getLabel();
 		        String[] temp = str.split(":");
-		        String port = temp[0];
-		        String hostAddress = temp[1];
-		        String rootAddress = temp[2];
+                if (temp.length == ipv4AddressLength) {
+                    // IPv4 Address
+                    port = temp[0];
+                    hostAddress = temp[1];
+                    rootAddress = temp[2];
+                } else if (temp.length == ipv6AddressLength) {
+                    // IPv6 Address
+                    port = temp[0];
+                    hostAddress = temp[1] + ":" + temp[2] + ":" + temp[3] + ":" + temp[4] + ":" + temp[5] + ":" + temp[6] + ":" + temp[7] + ":" + temp[8];
+                    rootAddress = temp[9] + ":" + temp[10] + ":" + temp[11] + ":" + temp[12] + ":" + temp[13] + ":" + temp[14] + ":" + temp[15] + ":" + temp[16];
+                }
 				cp.setHostName(hostAddress,Integer.parseInt(port),rootAddress);
                 unVisible();
 			}