Skip to content

Commit

Permalink
Handle incorrect password better
Browse files Browse the repository at this point in the history
  • Loading branch information
Morphan1 committed Oct 12, 2016
1 parent 372cfce commit b60ead9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Expand Up @@ -115,7 +115,6 @@ public void close(String reason, boolean shouldReconnect) {

public void attemptReconnect() {
if (!isConnected && reconnectThread == null) {
Depenizen.getImplementation().debugMessage("Attempting to reconnect...");
reconnectThread = new Thread(new ReconnectTask(this, getReconnectAttempts(), getReconnectDelay()));
reconnectThread.start();
}
Expand Down Expand Up @@ -256,14 +255,16 @@ public void run() {
}
listenThread = null;
}
catch (IllegalStateException e) {
close("Password is incorrect", false);
}
catch (SocketTimeoutException e) {
close("Connection timed out", true);
}
catch (IOException e) {
close("Server socket closed", true);
if (!isRegistered()) {
close("Server socket closed the connection during registration. Incorrect password?", false);
}
else {
close("Server socket closed", true);
}
}
catch (InterruptedException e) {
// Assume this is intentional
Expand Down
Expand Up @@ -7,6 +7,7 @@
import com.denizenscript.depenizen.common.socket.server.packet.*;
import com.denizenscript.depenizen.common.util.Utilities;

import javax.crypto.BadPaddingException;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
Expand Down Expand Up @@ -269,7 +270,7 @@ public void run() {
}
}
}
catch (IllegalStateException e) {
catch (BadPaddingException e) {
server.removeClient(clientId, "Password is incorrect");
}
catch (IOException e) {
Expand Down

0 comments on commit b60ead9

Please sign in to comment.