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); Thread.sleep(5000);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); //e.printStackTrace();
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); //e.printStackTrace();
} }
} }
} }

@ -42,7 +42,8 @@ public class HttpMatchBrowserHost extends Thread {
Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
boolean matches = false; boolean matches = false;
String ip = ""; 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()) while(e.hasMoreElements())
{ {
if (matches){ if (matches){
@ -54,10 +55,12 @@ public class HttpMatchBrowserHost extends Thread {
{ {
InetAddress i = ee.nextElement(); InetAddress i = ee.nextElement();
matches = ipPattern.matcher(i.getHostAddress()).matches(); matches = ipPattern.matcher(i.getHostAddress()).matches();
System.out.println(i.getHostAddress());
if (matches){ if (matches){
ip = i.getHostAddress(); if (!localIpPattern.matcher(i.getHostAddress()).matches()) {
//System.out.println(ip); ip = i.getHostAddress();
break; //break;
}
} }
} }
} }

Loading…
Cancel
Save