Fix style
This commit is contained in:
parent
8d5ef8a52b
commit
e56aad5526
@ -132,8 +132,10 @@ public class ClientP2P {
|
||||
}
|
||||
}
|
||||
|
||||
if (serverPortRange.isPortInRange(portServer)){
|
||||
if(trackerPortRange.isPortInRange(portTracker)){
|
||||
boolean serverInRange = serverPortRange.isPortInRange(portServer);
|
||||
boolean trackerInRange = trackerPortRange.isPortInRange(portTracker);
|
||||
|
||||
if (serverInRange && trackerInRange) {
|
||||
System.out.println("using hostname : " + hostnameServer);
|
||||
System.out.println("using port : " + portServer);
|
||||
System.out.println("tracker hostname : " + hostnameTracker);
|
||||
@ -182,13 +184,14 @@ public class ClientP2P {
|
||||
} catch (InterruptedException e) {}
|
||||
smudp.setStop();
|
||||
smtcp.setStop();
|
||||
} else {
|
||||
if (!serverInRange) {
|
||||
System.err.println("SERVER: Port not in range. " + serverPortRange);
|
||||
}
|
||||
else{
|
||||
System.out.println("\n TRACKER: Port not in range. " + trackerPortRange);
|
||||
if (!trackerInRange) {
|
||||
System.err.println("TRACKER: Port not in range. " + trackerPortRange);
|
||||
}
|
||||
}
|
||||
else{
|
||||
System.out.println("\n SERVER: Port not in range. " + serverPortRange);
|
||||
System.exit(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,19 +66,21 @@ public class ServerP2P {
|
||||
System.exit(1);
|
||||
}
|
||||
else if (args.length == 5) {
|
||||
isInteractive = false;
|
||||
hostnameServer = args[1];
|
||||
portServer = Integer.valueOf(Integer.parseInt(args[2]));
|
||||
hostnameTracker = args[3];
|
||||
portTracker = Integer.valueOf(Integer.parseInt(args[4]));
|
||||
} else {
|
||||
isInteractive = true;
|
||||
// configure application
|
||||
System.out.println("Server, enter hostname to bind (default = localhost): ");
|
||||
hostnameServer = scanner.nextLine();
|
||||
if (hostnameServer.equals("")) {
|
||||
hostnameServer = defaultHostname;
|
||||
System.out.println("using default hostname : " + hostnameServer);
|
||||
}
|
||||
System.out.println("enter port (default = " + serverPortRange.getDefaultPort() + "): ");
|
||||
System.out.println("Enter port (default = " + serverPortRange.getDefaultPort() + "): ");
|
||||
String portServerStr = scanner.nextLine();
|
||||
if (portServerStr.equals("")) {
|
||||
portServer = serverPortRange.getDefaultPort();
|
||||
@ -86,13 +88,14 @@ public class ServerP2P {
|
||||
} else {
|
||||
portServer = Integer.valueOf(Integer.parseInt(portServerStr));
|
||||
}
|
||||
System.out.println("enter hostname of tracker (default = localhost): ");
|
||||
// configure tracker
|
||||
System.out.println("Enter hostname of tracker (default = localhost): ");
|
||||
hostnameTracker = scanner.nextLine();
|
||||
if (hostnameTracker.equals("")) {
|
||||
hostnameTracker = defaultHostname;
|
||||
System.out.println("tracker default hostname : " + hostnameTracker);
|
||||
}
|
||||
System.out.println("enter tracker's port (default = " + trackerPortRange.getDefaultPort() + "): ");
|
||||
System.out.println("Enter tracker's port (default = " + trackerPortRange.getDefaultPort() + "): ");
|
||||
String portTrackerStr = scanner.nextLine();
|
||||
if (portTrackerStr.equals("")) {
|
||||
portTracker = trackerPortRange.getDefaultPort();
|
||||
@ -102,8 +105,9 @@ public class ServerP2P {
|
||||
}
|
||||
}
|
||||
|
||||
if (serverPortRange.isPortInRange(portServer)){
|
||||
if(trackerPortRange.isPortInRange(portTracker)){
|
||||
boolean serverInRange = serverPortRange.isPortInRange(portServer);
|
||||
boolean trackerInRange = trackerPortRange.isPortInRange(portTracker);
|
||||
if (serverInRange && trackerInRange) {
|
||||
System.out.println("using hostname : " + hostnameServer);
|
||||
System.out.println("using port : " + portServer);
|
||||
System.out.println("tracker hostname : " + hostnameTracker);
|
||||
@ -117,13 +121,14 @@ public class ServerP2P {
|
||||
Thread ttcp = new Thread(smtcp);
|
||||
ttcp.setName("server TCP P2P-JAVA-PROJECT");
|
||||
ttcp.start();
|
||||
} else {
|
||||
if (!serverInRange) {
|
||||
System.err.println("SERVER: Port not in range. " + serverPortRange);
|
||||
}
|
||||
else{
|
||||
System.out.println("\n TRACKER: Port not in range. " + trackerPortRange);
|
||||
if (!trackerInRange) {
|
||||
System.err.println("TRACKER: Port not in range. " + trackerPortRange);
|
||||
}
|
||||
}
|
||||
else{
|
||||
System.out.println("\n SERVER: Port not in range. " + serverPortRange);
|
||||
System.exit(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ public class Tracker {
|
||||
System.out.println("usage : java tracker.Tracker (interactive) or java trackerP2P.trackerP2P -- <hostname> <PORT> (" + trackerPortRange +")");
|
||||
System.exit(1);
|
||||
} else if (args.length == 3) {
|
||||
isInteractive = false;
|
||||
hostname = args[1];
|
||||
port = Integer.valueOf(Integer.parseInt(args[2]));
|
||||
} else {
|
||||
@ -88,9 +89,9 @@ public class Tracker {
|
||||
Thread ttcp = new Thread(tmtcp);
|
||||
ttcp.setName("Tracker TCP P2P-JAVA-PROJECT");
|
||||
ttcp.start();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
System.out.println("Port not in range. " + trackerPortRange);
|
||||
System.exit(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user