added support for tools/testlegitip

pull/63/head
Flavien Haas 5 years ago committed by Louis
parent 9c5bfc5430
commit d0eff567f5

@ -7,6 +7,7 @@ import tools.Directories;
import tools.Logger; import tools.Logger;
import tools.LogLevel; import tools.LogLevel;
import tools.TestPort; import tools.TestPort;
import tools.TestLegitIP;
/** Tracker implementation /** Tracker implementation
* First argument of main method is port listened by the tracker, and is mandatory. * First argument of main method is port listened by the tracker, and is mandatory.
@ -42,16 +43,20 @@ public class Tracker {
final String defaultPort = "6969"; final String defaultPort = "6969";
final String defaultHostname = "localhost"; final String defaultHostname = "localhost";
Scanner scanner = new Scanner(System.in); Scanner scanner = new Scanner(System.in);
TestLegitIP testLegitIP = new TestLegitIP();
TestPort testPortTracker = new TestPort();
Tracker t; Tracker t;
System.out.println("Tracker Server, enter hostname to bind (default = localhost): "); do{
String hostname = scanner.nextLine(); System.out.println("Tracker Server, enter hostname to bind (default = localhost): ");
if(hostname.equals("")){ String hostname = scanner.nextLine();
hostname = defaultHostname; if(hostname.equals("")){
System.out.println("using default hostname : " + hostname); hostname = defaultHostname;
} else{ System.out.println("using default hostname : " + hostname);
System.out.println("using hostname : " + hostname); }
} } while (!testLegitIP.TestIP(hostname))
System.out.println("using hostname : " + hostname);
System.out.println("enter port (default = 6969): "); System.out.println("enter port (default = 6969): ");
String port = scanner.nextLine(); String port = scanner.nextLine();
if(port.equals("")){ if(port.equals("")){
@ -60,7 +65,6 @@ public class Tracker {
} else { } else {
System.out.println("using port : " + port); System.out.println("using port : " + port);
} }
TestPort testPortTracker = new TestPort();
if(testPortTracker.testPortTracker(Integer.parseInt(port))){ if(testPortTracker.testPortTracker(Integer.parseInt(port))){
t = new Tracker(port); t = new Tracker(port);
} }

Loading…
Cancel
Save