make access password mandatory
This commit is contained in:
parent
5f49d6c036
commit
435e3f3e29
5 changed files with 35 additions and 7 deletions
|
@ -132,7 +132,9 @@ public class GuiConnect extends GuiList<GuiConnect.ServerInfo> implements Button
|
|||
for(int z = 0; z <= lines.length; z++) {
|
||||
String line = z == lines.length ? null : lines[z];
|
||||
if(line == null || (line.startsWith("[") && line.endsWith("]"))) {
|
||||
if(!name.isEmpty() && !address.isEmpty() && !user.isEmpty() && user.length() < IPlayer.MAX_USER_LENGTH && IPlayer.isValidUser(user) && password.length() < IPlayer.MAX_PASS_LENGTH && access.length() < IPlayer.MAX_PASS_LENGTH && address.length() < 128 && name.length() < 128 && port >= 1024 && port <= 32767)
|
||||
if(!name.isEmpty() && !address.isEmpty() && !user.isEmpty() && user.length() < IPlayer.MAX_USER_LENGTH && IPlayer.isValidUser(user) &&
|
||||
password.length() < IPlayer.MAX_PASS_LENGTH && access.length() < IPlayer.MAX_PASS_LENGTH && address.length() < 128 && name.length() < 128 &&
|
||||
port >= 1024 && port <= 32767 && password.length() >= 8 && access.length() >= 8)
|
||||
this.elements.add(new ServerInfo(name, address, port, user, password, access, time));
|
||||
if(line != null) {
|
||||
address = "";
|
||||
|
|
|
@ -69,8 +69,8 @@ public class GuiServer extends Gui implements FieldCallback {
|
|||
this.portLabel = this.add(new Label(404, 0, 76, 20, "Port", true));
|
||||
this.rangeLabel = this.add(new Label(370, 44, 110, 20, "[1024..32767]", true));
|
||||
this.userLabel = this.add(new Label(0, 50, 220, 20, "Nutzer", true));
|
||||
this.passLabel = this.add(new Label(0, 100, 480, 20, "Passwort", true));
|
||||
this.accLabel = this.add(new Label(0, 150, 480, 20, "Zugang", true));
|
||||
this.passLabel = this.add(new Label(0, 100, 480, 20, "Passwort (mind. 8 Zeichen)", true));
|
||||
this.accLabel = this.add(new Label(0, 150, 480, 20, "Zugang (mind. 8 Zeichen)", true));
|
||||
this.shift();
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,15 @@ public class GuiServer extends Gui implements FieldCallback {
|
|||
return;
|
||||
}
|
||||
String pass = this.passBox.getText();
|
||||
if(pass.length() < 8) {
|
||||
this.passLabel.setText(pass.isEmpty() ? TextColor.RED + "Passwort (mind. 8 Zeichen)" : "Passwort (" + TextColor.RED + "mind. 8 Zeichen" + TextColor.RESET + ")");
|
||||
return;
|
||||
}
|
||||
String acc = this.accBox.getText();
|
||||
if(acc.length() < 8) {
|
||||
this.accLabel.setText(acc.isEmpty() ? TextColor.RED + "Zugang (mind. 8 Zeichen)" : "Zugang (" + TextColor.RED + "mind. 8 Zeichen" + TextColor.RESET + ")");
|
||||
return;
|
||||
}
|
||||
if(this.server == null) {
|
||||
this.lastAddr = addr;
|
||||
this.lastPort = port;
|
||||
|
@ -148,6 +156,10 @@ public class GuiServer extends Gui implements FieldCallback {
|
|||
}
|
||||
else if(elem == this.userBox)
|
||||
this.userLabel.setText("Nutzer");
|
||||
else if(elem == this.passBox)
|
||||
this.passLabel.setText("Passwort (mind. 8 Zeichen)");
|
||||
else if(elem == this.accBox)
|
||||
this.accLabel.setText("Zugang (mind. 8 Zeichen)");
|
||||
else if(this.server != null && elem == this.nameBox)
|
||||
this.nameLabel.setText("Name");
|
||||
}
|
||||
|
|
|
@ -435,7 +435,7 @@ public abstract class Config {
|
|||
public static int eggTimer = 6000;
|
||||
@Var(name = "connectionTimeout", min = 10, max = 300)
|
||||
public static int timeout = 30;
|
||||
@Var(name = "passwordMinLength", min = 1, max = 32)
|
||||
@Var(name = "passwordMinLength", min = 8, max = 32)
|
||||
public static int minPassLength = 8;
|
||||
@Var(name = "port", min = 1024, max = 32767, nonDefault = true)
|
||||
public static int port = -1;
|
||||
|
@ -459,7 +459,7 @@ public abstract class Config {
|
|||
@Var(name = "spawnPitch", min = -89.0f, max = 89.0f)
|
||||
public static float spawnPitch = 0.0f;
|
||||
|
||||
@Var(name = "password")
|
||||
@Var(name = "password", nonDefault = true)
|
||||
public static String password = "";
|
||||
|
||||
static {
|
||||
|
|
|
@ -252,6 +252,14 @@ public final class Server implements IThreadListener {
|
|||
Server.this.bind(Config.port);
|
||||
}
|
||||
}, "port");
|
||||
Config.setCallback(new Runnable() {
|
||||
public void run() {
|
||||
if(Config.password.length() < 8 || Config.password.length() > IPlayer.MAX_PASS_LENGTH) {
|
||||
Log.IO.error("Passwort muss aus 8-" + IPlayer.MAX_PASS_LENGTH + " Zeichen bestehen");
|
||||
Config.set("password", "", false);
|
||||
}
|
||||
}
|
||||
}, "password");
|
||||
this.keyPair = EncryptUtil.generateKeyPair();
|
||||
}
|
||||
|
||||
|
@ -440,7 +448,7 @@ public final class Server implements IThreadListener {
|
|||
}
|
||||
}
|
||||
Config.set(args[0], value, true);
|
||||
exec.logConsole(TextColor.YELLOW + "%s" + TextColor.GRAY + " -> " + ((cv.type == ValueType.BOOLEAN ? (cv.getValue().equals("true") ? TextColor.GREEN : TextColor.RED) : (cv.type == ValueType.STRING ? TextColor.NEON : TextColor.BLUE))) + "%s", args[0], cv.type == ValueType.STRING ? ("'" + cv.getValue() + "'") : cv.getValue());
|
||||
exec.logConsole(TextColor.YELLOW + "%s" + TextColor.GRAY + " -> " + (cv.noDef && cv.def.equals(cv.getValue()) ? TextColor.DGRAY + "[ - ]" : ((cv.type == ValueType.BOOLEAN ? (cv.getValue().equals("true") ? TextColor.GREEN : TextColor.RED) : (cv.type == ValueType.STRING ? TextColor.NEON : TextColor.BLUE))) + "%s"), args[0], cv.type == ValueType.STRING ? ("'" + cv.getValue() + "'") : cv.getValue());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -504,6 +512,8 @@ public final class Server implements IThreadListener {
|
|||
this.bind(Config.port);
|
||||
else
|
||||
Log.SYSTEM.warn("Kein Port definiert, verwende 'port <1024-32767>' um einen Hosting-Port festzulegen");
|
||||
if(Config.password.length() < 8)
|
||||
Log.SYSTEM.warn("Kein Passwort definiert, verwende 'password <8-" + IPlayer.MAX_PASS_LENGTH + " Zeichen>' um ein Zugangspasswort festzulegen");
|
||||
Thread con = new Thread(new Runnable() {
|
||||
private final BufferedReader reader = new BufferedReader(new InputStreamReader(new BufferedInputStream(System.in)));
|
||||
|
||||
|
|
|
@ -133,7 +133,11 @@ public class LoginHandler extends NetHandler implements ILoginHandler
|
|||
throw new IllegalStateException("Ungültiger Nutzername!");
|
||||
// if(!this.checkConnect(packetIn.getAccess()))
|
||||
// return;
|
||||
if(!Config.password.isEmpty() && !Config.password.equals(packetIn.getAccess())) {
|
||||
if(Config.password.length() < 8) {
|
||||
this.closeConnection("Es ist kein Zugangspasswort für diesen Server konfiguriert");
|
||||
return;
|
||||
}
|
||||
if(!Config.password.equals(packetIn.getAccess())) {
|
||||
this.closeConnection("Falsches Zugangspasswort");
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue