From fac82611dc094527483d7b7086bee5ea19abc2d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Dahlgren?= Date: Sat, 15 Aug 2015 13:56:43 +0200 Subject: [PATCH] Set default prefix and suffix to all server names --- config.js.example | 4 +++- lib/server.js | 14 +++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/config.js.example b/config.js.example index 3f5398e..75717c9 100644 --- a/config.js.example +++ b/config.js.example @@ -7,5 +7,7 @@ module.exports = { auth: { // If both username and password is set, HTTP Basic Auth will be used username: '', // Username for HTTP Basic Auth password: '', // Password for HTTP Basic Auth - } + }, + prefix: "", // Prefix to all server names + suffix: "", // Suffix to all server names }; diff --git a/lib/server.js b/lib/server.js index 9b4c013..c752e03 100644 --- a/lib/server.js +++ b/lib/server.js @@ -18,6 +18,18 @@ var queryTypes = { ofpresistance: 'operationflashpoint', }; +var createServerTitle = function(title) { + if (config.prefix) { + title = config.prefix + title; + } + + if (config.suffix) { + title = title + config.suffix; + } + + return title; +}; + var Server = function (path, type, options) { this.path = path; this.type = type; @@ -69,7 +81,7 @@ Server.prototype.start = function() { disableVoN: this.von ? 0 : 1, game: config.game, headlessClients: this.headless ? ["127.0.0.1"] : null, - hostname: this.title, + hostname: createServerTitle(this.title), localClient: this.headless ? ["127.0.0.1"] : null, mods: this.mods, password: this.password,