Skip to content

Commit

Permalink
fixed ip + cleaned srvCmdBuffer output + fluff
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Feb 26, 2020
1 parent 63f7ac2 commit fd14665
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
4 changes: 2 additions & 2 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -17,4 +17,4 @@ server_scripts {
client_scripts {
'extensions/**/resource/cl_*.js',
'extensions/**/resource/cl_*.lua',
}
}
2 changes: 1 addition & 1 deletion src/components/fxRunner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
26 changes: 14 additions & 12 deletions src/components/webServer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -160,15 +161,16 @@ 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);
}

//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.`);
Expand Down
2 changes: 1 addition & 1 deletion src/webroutes/authentication/providerCallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'){
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.0.0-conv",
"version": "2.0.0-rc1",
"changelog": "Deprecated Message. Please Update.",
"allVersions": [
{
Expand Down
6 changes: 3 additions & 3 deletions web/basic/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ <h1 class="mb-3">Login</h1>
<div class="row justify-content-md-center">
<div class="col-md-4 ">
<div class="alert alert-secondary text-center small" role="alert">
<strong>Server Profile:</strong> {{config}} <br>
<strong>txAdmin Version:</strong> {{txAdminVersion}} <br>
<strong>FXServer Version:</strong> {{fxserverVersion}}
<strong>Server profile:</strong> {{config}} <br>
<strong>txAdmin version:</strong> {{txAdminVersion}} <br>
<strong>FXServer build:</strong> {{fxserverVersion}}
</div>
</div>
</div>
Expand Down

0 comments on commit fd14665

Please sign in to comment.