diff --git a/index.js b/index.js index 92cc741..4601560 100644 --- a/index.js +++ b/index.js @@ -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"); } diff --git a/ssh.js b/ssh.js index 7983440..f5ab101 100644 --- a/ssh.js +++ b/ssh.js @@ -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(); }); }