adding cd

This commit is contained in:
raven 2023-01-08 22:59:49 -05:00
parent e279f57be0
commit b8f039cb9e

View File

@ -17,6 +17,7 @@ goodbye(() => swarm.destroy())
// Keep track of all connections and USERNAMEs
const conns = []
const names = {}
let USERPWD = "/"
let DAPI_KEY = {}
let USERNAME = "annon" + rand
let LOGGEDIN = false
@ -38,8 +39,10 @@ async function getUSERNAME(key) {
async function runCMD(key, cmd, pwd) {
let requestData = await unirest
.post('https://api.discord-linux.com/exec')
.headers({'Accept': 'application/json', 'Content-Type': 'application/json',
'x-discord-linux-auth': key})
.headers({
'Accept': 'application/json', 'Content-Type': 'application/json',
'x-discord-linux-auth': key
})
.send({ "cmd": cmd, "pwd": pwd })
return requestData.body.stdout
}
@ -47,8 +50,10 @@ async function runCMD(key, cmd, pwd){
async function startContainer(key) {
let startContainer = await unirest
.get('https://api.discord-linux.com/start')
.headers({'Accept': 'application/json', 'Content-Type': 'application/json',
'x-discord-linux-auth': key})
.headers({
'Accept': 'application/json', 'Content-Type': 'application/json',
'x-discord-linux-auth': key
})
return startContainer.body.completed
}
@ -56,24 +61,30 @@ async function startContainer(key){
async function stopContainer(key) {
let stopContainer = await unirest
.get('https://api.discord-linux.com/stop')
.headers({'Accept': 'application/json', 'Content-Type': 'application/json',
'x-discord-linux-auth': key})
.headers({
'Accept': 'application/json', 'Content-Type': 'application/json',
'x-discord-linux-auth': key
})
return stopContainer.body.completed
}
async function restartContainer(key) {
let restartContainer = await unirest
.get('https://api.discord-linux.com/restart')
.headers({'Accept': 'application/json', 'Content-Type': 'application/json',
'x-discord-linux-auth': key})
.headers({
'Accept': 'application/json', 'Content-Type': 'application/json',
'x-discord-linux-auth': key
})
return restartContainer.body.completed
}
async function getStats(key) {
let getStats = await unirest
.get('https://api.discord-linux.com/restart')
.headers({'Accept': 'application/json', 'Content-Type': 'application/json',
'x-discord-linux-auth': key})
.headers({
'Accept': 'application/json', 'Content-Type': 'application/json',
'x-discord-linux-auth': key
})
console.log(getStats.body)
return getStats.body.data
}
@ -112,15 +123,30 @@ rl.on('line', input => {
conn.write(`${USERNAME} has logged in!`)
}
clearCursor()
console.log(`Weclcome ${USERNAME} you are now logged in!`)
console.log(`Welcome ${USERNAME} you are now logged in!`)
return LOGGEDIN = true
});
}
const changeDir = input.startsWith(">cd") || input.startsWith("> cd")
if (changeDir) {
const commandArgs = input.replace("> cd ", "").replace(">cd", "").replace(" ", "")
if (commandArgs.startsWith("/")) {
USERPWD = commandArgs;
console.log("Directory Changed to: " + USERPWD)
} else {
USERPWD = USERPWD + "/" + commandArgs;
console.log("Directory Changed to: " + USERPWD)
}
}
const execute = input.startsWith(">")
if (execute) {
let inputdata = input.split(2)
const cmdToRun = inputdata.join(" ").replace("> ", "").replace(">", "")
if (cmdToRun.includes("cd")) return
runCMD(DAPI_KEY.key, cmdToRun, "/").then((data) => {
console.log(data)
for (const conn of conns) {
@ -129,7 +155,6 @@ rl.on('line', input => {
})
}
const start = input.match(/^\/start (\S+)$/)
if (start) {
const cmdToRun = start[1]