Compare commits

..

No commits in common. "744ab922d6827f189cc44ffcefe0e07f78527fa9" and "1c32f1f2ca9f0e3c7ee8916ea10c7fd94a350054" have entirely different histories.

2 changed files with 67 additions and 98 deletions

View File

@ -53,14 +53,8 @@ To connect to an altready made topic (room) pass the hash on start up:
/login [API KEY] - Login to the API /login [API KEY] - Login to the API
<<<<<<< HEAD
\>command here - Send a command to your container \>command here - Send a command to your container
\> cd /to/path - change working directory
=======
\>command here - Send a command to your container
>>>>>>> 1c32f1f2ca9f0e3c7ee8916ea10c7fd94a350054
/start - Start your container /start - Start your container
/stop - Stop your container /stop - Stop your container

View File

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