diff --git a/README.md b/README.md
index 10f09ad..5f692a8 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@ Conan Server Manager (now known as Server Thrall) is a python based dedicated se
| **UptimeTracker** | Records the percentage of time the server has been online. If the server thrall is closed, this counts against the uptime percentage. | **enabled**: Set to true or false to prevent this plugin from running
**seconds_up**: The total amount of seconds the server has been up
**initial**: unix timestamp of when the server uptime started to be recorded. Delete this to restart your uptime counter |
| **RaidPlugin** | Allows you to set a period of time under which "Raiding" is enabled. This means that building damage will only be enabled during this time. Works by changing the games configuration and rebooting the server at the boundries of raiding times. This plugin modifies the CanDamagePlayerOwnedStructures option in ServerSettings. | **enabled**: Set to true or false to prevent this plugin from running
**start_hour**: The hour of the day that raiding should be enabled. This should be in 24 hour time. So 17 would be 5pm in the servers computers timezone.
**length_in_hours**: The number of hours after start_hour that raiding should be enabled. |
| **ApiUploader** | Uploads your server data to serverthrallapi so you can see your data online. If your **server_id** was `2`, and your **private_secret** was `200cd768-5b1d-11e7-9e82-d60626067254` you would access your servers characters at this URL: https://serverthrallapi.herokuapp.com/api/2/characters?private_secret=200cd768-5b1d-11e7-9e82-d60626067254 | **enabled**: Set to true or false to prevent this plugin from running
**server_id**: The registered server id with serverthrallapi, used to access your data.
**public_secret**: A public code you can give to your players to access a "public" view of your servers data. This is unused but will be used later.
**private_secret** A secret code that is used to make modifications to your server and synchronize data. Do NOT give this out to your players |
-| **ServerConfig** | Allows you to configure common server settings from your server thrall config. If the config differs from expected, the config will be edited and the server restarted. **NOTE** This even works for NetServerMaxTickRate which needs to be written to DefaultEngine, but all other settings get written to saved settings. |**enabled**: Set to true or false to prevent this plugin from running
**ServerName**=My Server: Sets the name that will be displayed in the server list.
**ServerPassword**=Password123: Sets the server password that will need to be entered to join the server. Leave blank for no password.
**GameServerQueryPort**=27015: Sets the query port for Steam matchmaking. Same as setting -QueryPort in the command line.
**Port**=7777: Sets the game server port.
**MaxPlayers**=70: Sets the maximum number of players.
**AdminPassword**=SecretPassword: Sets the administrative password for the server. This will grant players administrative rights when used from the settings menu in-game.
**MaxNudity**=2: Sets the maximum nudity level allowed on the server. (0=None, 1=Partial, 2=Full)
**IsBattleEyeEnabled**=True: Enables/disables BattlEye protection for the server.
**ServerRegion**=1: Sets the server's region. (0=EU, 1=NA, 2=Asia)
**ServerCommunity**=1: Sets the server's play style (0=None, 1=Purist, 2=Relaxed, 3=Hard Core, 4=Role Playing, 5=Experimental)
**PVPBlitzServer**=False: Enables/disables Blitz mode. (accelerated progression)
**PVPEnabled**=True: Enables/disables PvP on the server.
**NetServerMaxTickRate**=30: Sets the maximum tick rate (update rate) for the server. **WARNING**: High values can cause unwanted behavior.
|
+| **ServerConfig** | Allows you to configure common server settings from your server thrall config. If the config differs from expected, the config will be edited and the server restarted. |**enabled**: Set to true or false to prevent this plugin from running
**ServerName**=My Server: Sets the name that will be displayed in the server list.
**ServerPassword**=Password123: Sets the server password that will need to be entered to join the server. Leave blank for no password.
**QueryPort**=27015: Sets the query port for Steam matchmaking. Same as setting -QueryPort in the command line.
**Port**=7777: Sets the game server port.
**MaxPlayers**=70: Sets the maximum number of players.
**AdminPassword**=SecretPassword: Sets the administrative password for the server. This will grant players administrative rights when used from the settings menu in-game.
**MaxNudity**=2: Sets the maximum nudity level allowed on the server. (0=None, 1=Partial, 2=Full)
**IsBattleEyeEnabled**=True: Enables/disables BattlEye protection for the server.
**ServerRegion**=1: Sets the server's region. (0=EU, 1=NA, 2=Asia)
**ServerCommunity**=1: Sets the server's play style (0=None, 1=Purist, 2=Relaxed, 3=Hard Core, 4=Role Playing, 5=Experimental)
**PVPBlitzServer**=False: Enables/disables Blitz mode. (accelerated progression)
**PVPEnabled**=True: Enables/disables PvP on the server.
**NetServerMaxTickRate**=30: Sets the maximum tick rate (update rate) for the server. **WARNING**: High values can cause unwanted behavior.
|
### Example Config
diff --git a/serverthrall/conanconfig/__init__.py b/serverthrall/conanconfig/__init__.py
index 4796aed..9f83354 100644
--- a/serverthrall/conanconfig/__init__.py
+++ b/serverthrall/conanconfig/__init__.py
@@ -26,7 +26,6 @@ def __init__(self, conan_server_directory):
}
self.logger = logging.getLogger('serverthrall.conan_config')
- self.logger.setLevel(logging.DEBUG)
def refresh(self):
groups = {}
@@ -91,6 +90,8 @@ def set(self, group, section, option, value, first=False):
self.dirty[group][index][section][option] = value
self.groups[group][index].set(section, option, value)
+ return self.group_paths[group][index]
+
def setboolean(self, group, section, option, value):
self.set(group, section, option, 'True' if value else 'False')
diff --git a/serverthrall/conanserver.py b/serverthrall/conanserver.py
index 21c6a99..4763349 100644
--- a/serverthrall/conanserver.py
+++ b/serverthrall/conanserver.py
@@ -1,4 +1,3 @@
-from .conanconfig import ConanConfig
import subprocess
import psutil
import time
@@ -13,7 +12,7 @@ def __init__(self, path, steamcmd, arguments, high_priority):
self.path = path
self.steamcmd = steamcmd
self.arguments = arguments
- self.high_priority = high_priority;
+ self.high_priority = high_priority
self.logger = logging.getLogger('serverthrall')
self.process = None
diff --git a/serverthrall/plugins/serverconfig.py b/serverthrall/plugins/serverconfig.py
index eebd440..da7b973 100644
--- a/serverthrall/plugins/serverconfig.py
+++ b/serverthrall/plugins/serverconfig.py
@@ -1,5 +1,5 @@
from .thrallplugin import ThrallPlugin
-from configparser import NoOptionError, NoSectionError
+from configparser import NoOptionError
class ServerConfig(ThrallPlugin):
@@ -7,7 +7,7 @@ class ServerConfig(ThrallPlugin):
CONFIG_MAPPING = {
'ServerName': ('Engine', 'OnlineSubsystemSteam', 'ServerName'),
'ServerPassword': ('Engine', 'OnlineSubsystemSteam', 'ServerPassword'),
- 'GameServerQueryPort': ('Engine', 'OnlineSubsystemSteam', 'GameServerQueryPort'),
+ 'QueryPort': ('Engine', 'OnlineSubsystemSteam', 'QueryPort'),
'Port': ('Engine', 'URL', 'Port'),
'MaxPlayers': ('Game', '/Script/Engine.GameSession', 'MaxPlayers'),
'AdminPassword': ('ServerSettings', 'ServerSettings', 'AdminPassword'),
@@ -20,7 +20,7 @@ class ServerConfig(ThrallPlugin):
'NetServerMaxTickRate': ('Engine', '/Script/OnlineSubsystemUtils.IpNetDriver', 'NetServerMaxTickRate'),
}
- FIRST_WHITE_LIST = ('NetServerMaxTickRate',)
+ DEFAULT_WHITE_LIST = []
def config_get_safe(self, src):
try:
@@ -28,7 +28,7 @@ def config_get_safe(self, src):
except NoOptionError:
return None
- def sync_mapping(self,mapping):
+ def sync_mapping(self, mapping):
changed = False
for src, dest in self.CONFIG_MAPPING.items():
@@ -37,20 +37,20 @@ def sync_mapping(self,mapping):
value = self.config_get_safe(src)
original = self.thrall.conan_config.get(group, section, option)
- path = '%s/%s/%s=%s'
-
if value is not None and value != original:
- self.logger.info('Syncing option %s to %s/%s/%s as %s' % (src, group, section, option, value))
- self.thrall.conan_config.set(group, section, option, value, option in self.FIRST_WHITE_LIST)
+ use_default_config = option in self.DEFAULT_WHITE_LIST
+ path = self.thrall.conan_config.set(group, section, option, value, use_default_config)
+ self.logger.info('Syncing %s.%s=%s, %s' % (section, option, value, path))
changed = True
return changed
def tick(self):
+ self.thrall.conan_config.refresh()
changed = self.sync_mapping(self.CONFIG_MAPPING)
if changed:
- self.thrall.conan_config.save()
self.logger.info('Restarting server for config to take into affect')
self.server.close()
- self.server.start()
\ No newline at end of file
+ self.thrall.conan_config.save()
+ self.server.start()
diff --git a/serverthrall/plugins/serverupdater.py b/serverthrall/plugins/serverupdater.py
index 3eafa54..0043ab1 100644
--- a/serverthrall/plugins/serverupdater.py
+++ b/serverthrall/plugins/serverupdater.py
@@ -3,7 +3,7 @@
from datetime import datetime
import time
import subprocess
-import os
+import os
class ServerUpdater(IntervalTickPlugin):
@@ -19,7 +19,7 @@ def __init__(self, config):
def ready(self, steamcmd, server, thrall):
super(ServerUpdater, self).ready(steamcmd, server, thrall)
self.installed_version = self.config.get('installed_version')
-
+
if self.installed_version == self.NO_INSTALLED_VERSION:
self.detect_existing_version()
@@ -109,6 +109,5 @@ def tick_interval(self):
self.logger.info('An update is available from build %s to %s' % (current, target))
self.server.close()
self.update_server(target)
- self.server.start()
-
-
+ self.thrall.conan_config.refresh()
+ self.server.start()
\ No newline at end of file
diff --git a/serverthrall/settings.py b/serverthrall/settings.py
index 74a3613..abfa635 100644
--- a/serverthrall/settings.py
+++ b/serverthrall/settings.py
@@ -27,4 +27,4 @@
steamcmd_logger.setLevel(logging.WARNING)
conan_config_logger = logging.getLogger('serverthrall.conan_config')
-conan_config_logger.setLevel(logging.WARNING)
\ No newline at end of file
+conan_config_logger.setLevel(logging.INFO)
\ No newline at end of file
diff --git a/tests/test_conanconfig.py b/tests/test_conanconfig.py
index a63077d..cef59bc 100644
--- a/tests/test_conanconfig.py
+++ b/tests/test_conanconfig.py
@@ -97,7 +97,9 @@ def test_set_hierarchy(self):
self.config.group_paths = {'Test': [parent, child]}
self.config.refresh()
+
assert self.config.get('Test', 'URL', 'Port') == '7777'
+
self.config.set('Test', 'URL', 'Port', '7778', first=True)
self.config.set('Test', 'URL', 'Port', '7778')
self.config.save()