actually close socket, make add action work
All checks were successful
/ Build BaseBand Server (push) Successful in 2m18s

This commit is contained in:
Daniella / Tove 2024-06-10 17:53:36 +02:00
parent 5fb70e8f8a
commit 20635084f8
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
2 changed files with 8 additions and 4 deletions

View file

@ -143,7 +143,7 @@ public class Main extends ListenerAdapter {
try {
TCN tcn = new TCN();
tcn.set("action", "create");
tcn.set("action", "add");
tcn.set("authorisation", Hasher.sha512hex(password));
tcn.set("discord-id", user.getIdLong());
event.reply("Contacting server...").setEphemeral(true).queue();
@ -212,7 +212,7 @@ public class Main extends ListenerAdapter {
}
case 400: {
event.reply("Error! I sent malformed data somehow.").setEphemeral(true).queue();
event.reply("Error! I sent malformed data somehow.\n\nEither I am broken,\nor your password is too long.").setEphemeral(true).queue();
break;
}

View file

@ -8,6 +8,7 @@ import de.tudbut.tools.Hasher;
import java.io.IOException;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
public class BotServiceHandler {
@ -68,7 +69,7 @@ public class BotServiceHandler {
TCN userToAdd = new TCN();
tcn.set("username", username);
tcn.set("password", BCrypt.withDefaults().hashToString(4, new String(SecureRandom.getSeed(64)).toCharArray()));
tcn.set("password", BCrypt.withDefaults().hashToString(4, new String(SecureRandom.getSeed(32), StandardCharsets.ISO_8859_1).toCharArray()));
tcn.set("hardware-id", Hasher.sha512hex(new String(SecureRandom.getSeed(512))));
tcn.set("hardware-id-reset", true);
tcn.set("disabled", false);
@ -92,8 +93,11 @@ public class BotServiceHandler {
System.out.println("Bot processed " + action);
Main.save();
} catch (TCN.TCNException e) {
} catch (Exception e) {
tos.writeInt(400);
}
finally {
tos.getStream().close();
}
}
}