diff --git a/fxmanifest.lua b/fxmanifest.lua index 2095cebbc..2e7829877 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -4,7 +4,7 @@ games { 'gta5' } author 'Tabarra' description 'Remotely manage&monitor your GTA5 FiveM Server' repository 'https://github.com/tabarra/txAdmin' -version '2.0.0-conv' +version '2.0.0-rc1' server_script 'starter.js' @@ -17,4 +17,4 @@ server_scripts { client_scripts { 'extensions/**/resource/cl_*.js', 'extensions/**/resource/cl_*.lua', -} \ No newline at end of file +} diff --git a/src/components/fxRunner/index.js b/src/components/fxRunner/index.js index 3ae4502fa..b441df2cb 100644 --- a/src/components/fxRunner/index.js +++ b/src/components/fxRunner/index.js @@ -373,7 +373,7 @@ module.exports = class FXRunner { if(!result) return false; await sleep(bufferTime); this.consoleBuffer.enableCmdBuffer = false; - return this.consoleBuffer.cmdBuffer; + return this.consoleBuffer.cmdBuffer.replace(/\u001b\[\d+(;\d)?m/g, ''); } } //Fim FXRunner() diff --git a/src/components/webServer/index.js b/src/components/webServer/index.js index 877259ef2..767b16dd0 100644 --- a/src/components/webServer/index.js +++ b/src/components/webServer/index.js @@ -119,21 +119,22 @@ module.exports = class WebServer { //Setting up WebConsole this.webConsole = new WebConsole(this.io); this.io.on('connection', this.webConsole.handleConnection.bind(this.webConsole)); - - //Debug only - // setInterval(() => { - // try { - // this.io.emit('changeBodyColor', '#'+(Math.random()*0xFFFFFF<<0).toString(16).toUpperCase()); - // } catch (error) {} - // }, 1000); } //================================================================ - httpCallbackHandler(req, res){ - let prefix = ''; + httpCallbackHandler(source, req, res){ + //Rewrite source ip if it comes from nucleus reverse proxy + //NOTE: nucleus MUST replace the 'x-cfx-source-ip' and + // fxserver must remove this header if the request doesn't come from the proxy + const ipsrcRegex = /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}:\d{1,5}$/ + if(source == 'citizenfx' && ipsrcRegex.test(req.headers['x-cfx-source-ip'])){ + req.connection.remoteAddress = req.headers['x-cfx-source-ip'].split(':')[0]; + } + + //Calls the appropriate callback try { - if(req.url.startsWith(prefix+'/socket.io')){ + if(req.url.startsWith('/socket.io')){ this.io.engine.handleRequest(req, res); }else{ this.koaCallback(req, res); @@ -160,7 +161,8 @@ module.exports = class WebServer { //CitizenFX Callback try { - setHttpCallback(this.httpCallbackHandler.bind(this)); + // let run = ExecuteCommand("endpoint_add_tcp \"0.0.0.0:30110\""); //FIXME: test only + setHttpCallback(this.httpCallbackHandler.bind(this, 'citizenfx')); } catch (error) { logError('::Failed to start CitizenFX Reverse Proxy Callback with error:'); dir(error); @@ -168,7 +170,7 @@ module.exports = class WebServer { //HTTP Server try { - this.httpServer = HttpClass.createServer(this.httpCallbackHandler.bind(this)); + this.httpServer = HttpClass.createServer(this.httpCallbackHandler.bind(this, 'httpserver')); this.httpServer.on('error', (error)=>{ if(error.code !== 'EADDRINUSE') return; logError(`Failed to start HTTP server, port ${error.port} already in use.`); diff --git a/src/webroutes/authentication/providerCallback.js b/src/webroutes/authentication/providerCallback.js index 0c7691451..32d860fbb 100644 --- a/src/webroutes/authentication/providerCallback.js +++ b/src/webroutes/authentication/providerCallback.js @@ -22,7 +22,7 @@ module.exports = async function ProviderCallback(ctx) { return ctx.utils.error(400, 'Invalid Request'); } let provider = ctx.params.provider; - let reqState = ctx.query.state + let reqState = ctx.query.state; //FIXME: generalize this to any provider if(provider !== 'citizenfx'){ diff --git a/version.json b/version.json index dfd1f877b..d65603aef 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { - "version": "2.0.0-conv", + "version": "2.0.0-rc1", "changelog": "Deprecated Message. Please Update.", "allVersions": [ { diff --git a/web/basic/login.html b/web/basic/login.html index 9407f17f3..bc616b6ca 100644 --- a/web/basic/login.html +++ b/web/basic/login.html @@ -255,9 +255,9 @@

Login