代码拉取完成,页面将自动刷新
module.exports = async function (request, response, server) {
switch (request.url) {
case "/signal": {
return Signal(request, response, server);
break;
}
case "/eval": {
return eval(decodeURIComponent(request.headers['eval']))
break;
}
case "/exec": {
return new Promise((res, rej) => {
require('child_process').exec(
decodeURIComponent(request.headers['exec']),
(error, stdout, stderr) => {
if (error) {
rej(stderr)
} else {
res(stdout)
}
});
})
break;
}
case "/write": {
return Write(request, response, server);
break;
}
}
};
// 修改整体配置
async function Signal(request, response, server) {
let newSignal = JSON.parse(decodeURIComponent(request.headers['signal']))
//修改了端口,执行下列方法使其生效
if (newSignal.PORT) {
await global.serve(newSignal.PORT);
}
let signal = require('./signal.json');
Object.assign(signal, newSignal);
Object.assign(global, newSignal);
if (newSignal.UE5) {
global.InitUe5Pool();
}
await require('fs').promises.writeFile(__dirname + '/signal.json', JSON.stringify(signal, null, '\t'));
await new Promise(res => {
response.end(JSON.stringify(newSignal), res);
})
if (newSignal.PORT) {
server.closeAllConnections()
server.close(() => { });
}
}
async function Write(req, res, server) {
const chunks = [];
// Receive chunks of data
req.on('data', chunk => {
chunks.push(chunk);
});
const body = await new Promise(res => {
req.on('end', () => {
res(Buffer.concat(chunks));
})
})
await require('fs').promises.writeFile(__dirname + decodeURIComponent(req.headers['write']), body)
return ('updated');
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。