aaaaaaaaaaaaaaaaaa

This commit is contained in:
BurningScarf347 2021-08-15 12:55:32 -07:00
parent 24927b594f
commit 9a437765b0
2 changed files with 5 additions and 7 deletions

View file

@ -3,7 +3,7 @@ const Client = require('./client.js');
const vars = require("./vars.json");
const color = (str, code) => `\x1b[${code}m${str}\x1b[0m`;
const dim = str => color(str, vars.color.system);
const valid = /^[a-z0-9_]+$/;
const valid = /^[a-z0-9_]*$/i;
const conns = new Set();
const server = new Server();
@ -28,10 +28,8 @@ Client.command("shrug", (user, args) => {
Client.command("nick", (user, args) => {
const old = user.name;
const nick = args[0];
if(nick.length === 0) {
return user.write("name too short\x1b[K");
}
console.log(args.join(" ").trim());
const nick = args.join(" ").trim();
if(nick.length > vars.maxlen) {
return user.write("name too long\x1b[K");
}

4
ssh.js
View file

@ -20,7 +20,7 @@ for(let user of fs.readFileSync("users", "utf8").split("\n")) {
// hashing helper function
function hash(str) {
return crypto.createHash("sha256").update(str).digest();
return crypto.createHash("sha256").update(str).digest("hex");
}
// new user
@ -31,7 +31,7 @@ function newUser(ctx) {
], "new user!", "to claim this account, please add a password", (a) => {
if(a[0] !== a[1]) return ctx.reject(["keyboard-interactive"]);
users.set(ctx.username, hash(a[0]));
passwds.write(`${ctx.username} ${a[0]}\n`);
passwds.write(`${ctx.username} ${hash(a[0])}\n`);
ctx.accept();
});
}