-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create BattlEye config file for RCON
- Loading branch information
Showing
5 changed files
with
127 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
var fs = require('fs') | ||
var path = require('path') | ||
|
||
var BattlEye = function (config, server) { | ||
this.config = config | ||
this.server = server | ||
} | ||
|
||
BattlEye.prototype.configContents = function () { | ||
var vars = [] | ||
|
||
if (this.server.battle_eye_password) { | ||
vars.push('RConPassword ' + this.server.battle_eye_password) | ||
} | ||
|
||
if (this.server.battle_eye_port) { | ||
vars.push('RConPort ' + this.server.battle_eye_port) | ||
} | ||
|
||
return vars.join('\n') | ||
} | ||
|
||
BattlEye.prototype.configPath = function () { | ||
if (this.config.game === 'arma3_x64') { | ||
return path.join(this.config.path, 'battleye', 'beserver_x64.cfg') | ||
} | ||
|
||
return path.join(this.config.path, 'battleye', 'beserver.cfg') | ||
} | ||
|
||
BattlEye.prototype.createConfigFile = function (callback) { | ||
var contents = this.configContents() | ||
var filePath = this.configPath() | ||
|
||
fs.writeFile(filePath, contents, function (err) { | ||
if (err) { | ||
console.error('Failed to write BattlEye config: ' + err) | ||
} | ||
|
||
callback(err) | ||
}) | ||
} | ||
|
||
module.exports = BattlEye |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
var path = require('path') | ||
require('should') | ||
|
||
var BattlEye = require('../../lib/battleye.js') | ||
var Server = require('../../lib/server.js') | ||
|
||
var server = new Server(null, null, { | ||
battle_eye: true, | ||
battle_eye_password: 'password', | ||
battle_eye_port: '12345', | ||
title: 'BattlEye Server' | ||
}) | ||
|
||
describe('BattlEye', function () { | ||
describe('configContents()', function () { | ||
it('should include password', function () { | ||
var battlEye = new BattlEye({}, server) | ||
battlEye.configContents().should.containEql('RConPassword password') | ||
}) | ||
|
||
it('should include port', function () { | ||
var battlEye = new BattlEye({}, server) | ||
battlEye.configContents().should.containEql('RConPort 12345') | ||
}) | ||
|
||
it('should generate valid config contents', function () { | ||
var battlEye = new BattlEye({}, server) | ||
battlEye.configContents().should.eql('RConPassword password\nRConPort 12345') | ||
}) | ||
}) | ||
|
||
describe('configPath()', function () { | ||
it('should generate x64 config for arma 3 x64 server', function () { | ||
var battlEye = new BattlEye({ game: 'arma3_x64', path: '/' }, server) | ||
battlEye.configPath().should.eql(path.join('/', 'battleye', 'beserver_x64.cfg')) | ||
}) | ||
|
||
it('should generate regular config for arma3 server', function () { | ||
var battlEye = new BattlEye({ game: 'arma3', path: '/' }, server) | ||
battlEye.configPath().should.eql(path.join('/', 'battleye', 'beserver.cfg')) | ||
}) | ||
}) | ||
}) |