From 4d31a133a9e4c80a212a0a26f9f09e80e8f7926d Mon Sep 17 00:00:00 2001 From: raven Date: Thu, 12 Jan 2023 10:29:32 -0500 Subject: [PATCH] fixing username --- commands/login.js | 4 ++-- sshChat.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/commands/login.js b/commands/login.js index 0e4280b..65902b5 100644 --- a/commands/login.js +++ b/commands/login.js @@ -1,12 +1,12 @@ var unirest = require('unirest'); -async function login(key, conns, MYKEY) { +async function login(key, conns, MYKEY, USERNAME) { getUSERNAME(key) .then((data) => { process.stdout.write("\033[2J") process.stdout.write("\033[0f") console.log("Hello, " + data + "\nYou are now logged in.\n\n\n") - USERNAME = data + USERNAME[0] = data MYKEY.push(key) LOGGEDIN = true for (const conn of conns) { diff --git a/sshChat.js b/sshChat.js index 115f5f9..9ed4622 100644 --- a/sshChat.js +++ b/sshChat.js @@ -19,10 +19,10 @@ let rand = Math.floor(Math.random() * 99999).toString(); let USERPWD = "/" let DAPI_KEY -let USERNAME = "anon" + rand let LOGGEDIN = false let MYKEY = [] let conns = [] +let USERNAME = ["annon" + rand] function sleep(ms) { return new Promise((resolve) => { @@ -83,7 +83,7 @@ async function handleCommand(input) { start(MYKEY[0]) break; case ">login": - login(command[1], conns, MYKEY) + login(command[1], conns, MYKEY, USERNAME) break; case ">exit": console.log("Sending close message...") @@ -100,10 +100,10 @@ async function handleCommand(input) { } else { for (const conn of conns) - conn.write(`${USERNAME}: ${input}`) + conn.write(`${USERNAME[0]}: ${input}`) } - console.log(`${USERNAME}: ${input}`) + console.log(`${USERNAME[0]}: ${input}`) clearCursor() } @@ -121,7 +121,7 @@ swarm.on('connection', conn => { }) const name = b4a.toString(conn.remotePublicKey, 'hex') - console.log(`* got a connection from ${name} (${USERNAME}) *`) + console.log(`* got a connection from ${name} (${USERNAME[0]}) *`) conns.push(conn) conn.once('close', () => conns.splice(conns.indexOf(conn), 1)) conn.on('data', data => {