fixing username

This commit is contained in:
raven 2023-01-12 10:29:32 -05:00
parent 0ba92e4b60
commit 4d31a133a9
2 changed files with 7 additions and 7 deletions

View File

@ -1,12 +1,12 @@
var unirest = require('unirest'); var unirest = require('unirest');
async function login(key, conns, MYKEY) { async function login(key, conns, MYKEY, USERNAME) {
getUSERNAME(key) getUSERNAME(key)
.then((data) => { .then((data) => {
process.stdout.write("\033[2J") process.stdout.write("\033[2J")
process.stdout.write("\033[0f") process.stdout.write("\033[0f")
console.log("Hello, " + data + "\nYou are now logged in.\n\n\n") console.log("Hello, " + data + "\nYou are now logged in.\n\n\n")
USERNAME = data USERNAME[0] = data
MYKEY.push(key) MYKEY.push(key)
LOGGEDIN = true LOGGEDIN = true
for (const conn of conns) { for (const conn of conns) {

View File

@ -19,10 +19,10 @@ let rand = Math.floor(Math.random() * 99999).toString();
let USERPWD = "/" let USERPWD = "/"
let DAPI_KEY let DAPI_KEY
let USERNAME = "anon" + rand
let LOGGEDIN = false let LOGGEDIN = false
let MYKEY = [] let MYKEY = []
let conns = [] let conns = []
let USERNAME = ["annon" + rand]
function sleep(ms) { function sleep(ms) {
return new Promise((resolve) => { return new Promise((resolve) => {
@ -83,7 +83,7 @@ async function handleCommand(input) {
start(MYKEY[0]) start(MYKEY[0])
break; break;
case ">login": case ">login":
login(command[1], conns, MYKEY) login(command[1], conns, MYKEY, USERNAME)
break; break;
case ">exit": case ">exit":
console.log("Sending close message...") console.log("Sending close message...")
@ -100,10 +100,10 @@ async function handleCommand(input) {
} else { } else {
for (const conn of conns) for (const conn of conns)
conn.write(`${USERNAME}: ${input}`) conn.write(`${USERNAME[0]}: ${input}`)
} }
console.log(`${USERNAME}: ${input}`) console.log(`${USERNAME[0]}: ${input}`)
clearCursor() clearCursor()
} }
@ -121,7 +121,7 @@ swarm.on('connection', conn => {
}) })
const name = b4a.toString(conn.remotePublicKey, 'hex') 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) conns.push(conn)
conn.once('close', () => conns.splice(conns.indexOf(conn), 1)) conn.once('close', () => conns.splice(conns.indexOf(conn), 1))
conn.on('data', data => { conn.on('data', data => {