Lock server port between 1024 and 64000
This commit is contained in:
부모
b281b4b530
커밋
ada6167c25
1개의 변경된 파일과 7개의 추가작업 그리고 2개의 파일을 삭제
|
|
@ -32,11 +32,16 @@ public class Main {
|
|||
}
|
||||
|
||||
private static int getPort(String value, int defaultValue) {
|
||||
int port = defaultValue;
|
||||
int port;
|
||||
try {
|
||||
port = Integer.parseInt(value.trim());
|
||||
if (port <= 1024 || port >= 64000) {
|
||||
System.out.println("Port should be between 1024 and 64000. Falling back to default.");
|
||||
port = defaultValue;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println("Could not read port " + value + ". Using default.");
|
||||
System.out.println("Could not read port " + value + ". Falling back to default.");
|
||||
port = defaultValue;
|
||||
}
|
||||
return port;
|
||||
}
|
||||
|
|
|
|||
불러오는 중…
Reference in a new issue