Fixed match client

main
Fan-Wu Yang 8 years ago
parent 804d27e055
commit 79d90f6ad5

@ -33,9 +33,9 @@ public class HttpMatchBrowserClient extends Thread {
Thread.sleep(5000);
} catch (IOException e) {
e.printStackTrace();
//e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
//e.printStackTrace();
}
}
}

@ -42,7 +42,8 @@ public class HttpMatchBrowserHost extends Thread {
Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
boolean matches = false;
String ip = "";
Pattern ipPattern = Pattern.compile("192.168.1.*");
Pattern localIpPattern = Pattern.compile("192\\.168\\..*");
Pattern ipPattern = Pattern.compile("[0-9]{0,3}\\.[0-9]{0,3}\\.[0-9]{0,3}\\.[0-9]{0,3}");
while(e.hasMoreElements())
{
if (matches){
@ -54,10 +55,12 @@ public class HttpMatchBrowserHost extends Thread {
{
InetAddress i = ee.nextElement();
matches = ipPattern.matcher(i.getHostAddress()).matches();
System.out.println(i.getHostAddress());
if (matches){
ip = i.getHostAddress();
//System.out.println(ip);
break;
if (!localIpPattern.matcher(i.getHostAddress()).matches()) {
ip = i.getHostAddress();
//break;
}
}
}
}

Loading…
Cancel
Save