This commit is contained in:
I-Have-An-Issue 2023-01-20 18:15:54 -05:00
parent 24b2e3ae69
commit 2aa69bb240
No known key found for this signature in database
GPG Key ID: E55435DEA0825091
11 changed files with 97 additions and 53 deletions

View File

@ -2,8 +2,6 @@ const logger = require("./lib/logger.js")
const express = require("express")
const app = express()
process.env.RCCSERVICE_PATH = "D:\\Projects\\Roblox\\Source\\UploadBits\\Win32-Release-RCCService\\"
app.use("/game/start", require("./routes/game/start.js"))
app.use("/game/stop", require("./routes/game/stop.js"))
app.use("/game/execute", require("./routes/game/execute.js"))

View File

@ -1,6 +1,6 @@
const EventEmitter = require("events")
const child_process = require("child_process")
const logger = require(`${__dirname}\\..\\logger.js`)
const logger = require("../../lib/logger.js")
class RCCService extends EventEmitter {
constructor(port, path = process.env.RCCSERVICE_PATH) {
@ -12,21 +12,21 @@ class RCCService extends EventEmitter {
Start(options = { cwd: this.path }) {
return new Promise((resolve, reject) => {
try {
if(process.platform == "win32") {
if (process.platform == "win32") {
this.proc = child_process.spawn("RCCService.exe", ["-Console", "-PlaceId:-1", `-Port`, this.port], options)
} else {
this.proc = child_process.spawn("wine", ["RCCService.exe", "-Console", "-PlaceId:-1", `-Port`, this.port], options)
}
this.proc.once("spawn", () => {
logger.info(`Spawned RCCService instance on port ${this.port}`);
logger.info(`Spawned RCCService instance on port ${this.port}`)
resolve(this.proc)
})
this.proc.once("exit", () => {
this.proc = null;
this.proc = null
logger.info(`An RCCService instance has closed on port ${this.port}`)
})
} catch (_) {
logger.error(_);
logger.error(_)
reject(_)
}
})

View File

@ -1,6 +1,6 @@
const express = require("express")
const app = express.Router()
app.all("*", (request, response) => response.status(404).end())
app.all("*", (request, response) => response.status(404).json({ status: 404 }))
module.exports = app

View File

@ -1,6 +1,6 @@
const express = require("express")
const app = express.Router()
app.all("*", (request, response) => response.status(404).end())
app.all("*", (request, response) => response.status(404).json({ status: 404 }))
module.exports = app

View File

@ -1,6 +1,6 @@
const express = require("express")
const app = express.Router()
app.all("*", (request, response) => response.status(404).end())
app.all("*", (request, response) => response.status(404).json({ status: 404 }))
module.exports = app

View File

@ -1,46 +1,8 @@
const waitPort = require("wait-port")
const logger = require(`${__dirname}\\..\\lib\\logger.js`)
const { readFileSync, read } = require("fs")
const express = require("express")
const Job = require("../lib/classes/Job.js")
const { randomUUID } = require("crypto")
const app = express.Router()
let tempPort = 64990
app.get("/", (request, response) => response.status(200).json())
app.all("*", async (request, response) => {
const job = new Job(randomUUID(), tempPort)
await job.Start()
const { open } = await waitPort({ host: "127.0.0.1", port: tempPort, timeout: 5000, output: "silent" })
if (!open) {
logger.warn("Job could not be started because port is already taken. Closing job..");
job.Close()
return response.json(false)
}
await job.CreateClient()
const result = await job.Open({
name: job.id,
script: readFileSync(__dirname + "/../lua/headshot.lua", { encoding: "utf-8" }),
arguments: {
LuaValue: [
{ type: "LUA_TSTRING", value: job.id },
{ type: "LUA_TSTRING", value: "Headshot" },
{ type: "LUA_TSTRING", value: "PNG" },
// change this to 1920x when we finish the arbiter
{ type: "LUA_TNUMBER", value: "420" },
{ type: "LUA_TNUMBER", value: "420" },
{ type: "LUA_TSTRING", value: "https://sitetest.unexp.xyz" },
{ type: "LUA_TNUMBER", value: "1" },
],
},
})
await job.Stop()
return response.end(Buffer.from(result[0].OpenJobExResult.LuaValue[0].value, "base64"))
})
app.all("*", (request, response) => response.status(404).json({ status: 404 }))
module.exports = app

View File

@ -1,6 +1,46 @@
const waitPort = require("wait-port")
const { readFileSync } = require("fs")
const { randomUUID } = require("crypto")
const logger = require("../../lib/logger.js")
const Job = require("../../lib/classes/Job.js")
const express = require("express")
const app = express.Router()
app.all("*", (request, response) => response.status(404).end())
app.get("/", async (request, response) => {
let tempPort = 64990
const job = new Job(randomUUID(), tempPort)
await job.Start()
const { open } = await waitPort({ host: "127.0.0.1", port: tempPort, timeout: 5000, output: "silent" })
if (!open) {
logger.warn("Job could not be started because port is already taken. Closing job..")
job.Close()
return response.json(false)
}
await job.CreateClient()
const result = await job.Open({
name: job.id,
script: readFileSync(__dirname + "/../lua/xml.lua", { encoding: "utf-8" }),
arguments: {
LuaValue: [
{ type: "LUA_TSTRING", value: job.id },
{ type: "LUA_TSTRING", value: "XML" },
{ type: "LUA_TSTRING", value: "PNG" },
// change this to 1920x when we finish the arbiter
{ type: "LUA_TNUMBER", value: "420" },
{ type: "LUA_TNUMBER", value: "420" },
{ type: "LUA_TSTRING", value: "https://economy.ittblox.gay" },
{ type: "LUA_TNUMBER", value: "2555" },
],
},
})
await job.Stop()
return response.end(Buffer.from(result[0].OpenJobExResult.LuaValue[0].value, "base64"))
})
module.exports = app

View File

@ -1,6 +1,46 @@
const waitPort = require("wait-port")
const { readFileSync } = require("fs")
const { randomUUID } = require("crypto")
const logger = require("../../lib/logger.js")
const Job = require("../../lib/classes/Job.js")
const express = require("express")
const app = express.Router()
app.all("*", (request, response) => response.status(404).end())
app.get("/", async (request, response) => {
let tempPort = 64990
const job = new Job(randomUUID(), tempPort)
await job.Start()
const { open } = await waitPort({ host: "127.0.0.1", port: tempPort, timeout: 5000, output: "silent" })
if (!open) {
logger.warn("Job could not be started because port is already taken. Closing job..")
job.Close()
return response.json(false)
}
await job.CreateClient()
const result = await job.Open({
name: job.id,
script: readFileSync(__dirname + "/../lua/headshot.lua", { encoding: "utf-8" }),
arguments: {
LuaValue: [
{ type: "LUA_TSTRING", value: job.id },
{ type: "LUA_TSTRING", value: "Headshot" },
{ type: "LUA_TSTRING", value: "PNG" },
// change this to 1920x when we finish the arbiter
{ type: "LUA_TNUMBER", value: "420" },
{ type: "LUA_TNUMBER", value: "420" },
{ type: "LUA_TSTRING", value: "https://economy.ittblox.gay" },
{ type: "LUA_TNUMBER", value: "1" },
],
},
})
await job.Stop()
return response.end(Buffer.from(result[0].OpenJobExResult.LuaValue[0].value, "base64"))
})
module.exports = app

View File

@ -1,6 +1,6 @@
const express = require("express")
const app = express.Router()
app.all("*", (request, response) => response.status(404).end())
app.all("*", (request, response) => response.status(404).json({ status: 404 }))
module.exports = app

2
start.bat Normal file
View File

@ -0,0 +1,2 @@
set RCCSERVICE_PATH=D:\\Projects\\Roblox\\Source\\UploadBits\\Win32-Release-RCCService\\
npm run dev

2
start.sh Normal file
View File

@ -0,0 +1,2 @@
export RCCSERVICE_PATH=/run/media/calones/32531f99-d721-4297-90c7-f91e56851060/ICCService/
npm run dev