fixing username
This commit is contained in:
parent
0ba92e4b60
commit
4d31a133a9
@ -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) {
|
||||
|
10
sshChat.js
10
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 => {
|
||||
|
Loading…
Reference in New Issue
Block a user