def get_current_settings(curPath): baseConfig = { "/Script/Astro.AstroServerSettings": { "bLoadAutoSave": "True", "MaxServerFramerate": "30.000000", "MaxServerIdleFramerate": "3.000000", "bWaitForPlayersBeforeShutdown": "False", "PublicIP": get_public_ip(), "ServerName": "Astroneer Dedicated Server", "MaximumPlayerCount": "12", "OwnerName": "", "OwnerGuid": "", "PlayerActivityTimeout": "0", "ServerPassword": "", "bDisableServerTravel": "False", "DenyUnlistedPlayers": "False", "VerbosePlayerProperties": "True", "AutoSaveGameInterval": "900", "BackupSaveGamesInterval": "7200", "ServerGuid": uuid.uuid4().hex, "ActiveSaveFileDescriptiveName": "SAVE_1", "ServerAdvertisedName": "", "ConsolePort": "1234" } } config = MultiConfig().baseline( os.path.join( curPath, r"Astro\Saved\Config\WindowsServer\AstroServerSettings.ini"), baseConfig) settings = config.getdict()['/Script/Astro.AstroServerSettings'] baseConfig = { "URL": { "Port": "7777" }, "/Script/OnlineSubsystemUtils.IpNetDriver": { "MaxClientRate": "1000000", "MaxInternetClientRate": "1000000" } } config = MultiConfig().baseline( os.path.join(curPath, r"Astro\Saved\Config\WindowsServer\Engine.ini"), baseConfig) # print(settings) settings.update(config.getdict()['URL']) # print(settings) return settings
def get_launcher_config(self, lfcg=None): if not lfcg: lfcg = self.LauncherConfig() baseConfig = {"AstroLauncher": dataclasses.asdict(lfcg)} config = MultiConfig().baseline(self.launcherINI, baseConfig) # print(settings) settings = config.getdict()['AstroLauncher'] return settings
def get_launcher_config(self): baseConfig = { "AstroLauncher": dataclasses.asdict(self.LauncherConfig()) } config = MultiConfig().baseline(self.launcherINI, baseConfig) # print(settings) settings = config.getdict()['AstroLauncher'] return settings
def get_current_settings(launcher, ovrIP=False): curPath = launcher.astroPath curLog = "AstroServerSettings.ini" confPath = os.path.join( curPath, r"Astro\Saved\Config\WindowsServer\AstroServerSettings.ini") AstroLogging.logPrint("Verifying PublicIP setting...", "debug") try: tConfig = MultiConfig().baseline(confPath, {}) bIP = tConfig.getdict()[ '/Script/Astro.AstroServerSettings'].get("PublicIP") validIP = valid_ip(bIP) if validIP and IP(bIP).iptype() != 'PUBLIC': validIP = False AstroLogging.logPrint( "PublicIP field (AstroServerSettings.ini) contained a Private IP!", "warning") AstroLogging.logPrint( "This will be automatically fixed..", "warning") except: validIP = False ovrConfig = { "/Script/Astro.AstroServerSettings": { "VerbosePlayerProperties": "True", "HeartbeatInterval": "0" } } try: if ovrIP: if launcher.launcherConfig.OverwritePublicIP or not validIP: ovrConfig["/Script/Astro.AstroServerSettings"]["PublicIP"] = get_public_ip() except: t = "warning" if not validIP: t = "error" AstroLogging.logPrint("Could not update PublicIP!", t) try: curLog = "AstroServerSettings.ini" AstroLogging.logPrint( "Forcing standardized settings in AstroServerSettings.ini...", "debug") MultiConfig().overwrite_with(confPath, ovrConfig) baseConfig = { "/Script/Astro.AstroServerSettings": { "bLoadAutoSave": "True", "MaxServerFramerate": "30.000000", "MaxServerIdleFramerate": "3.000000", "bWaitForPlayersBeforeShutdown": "False", "PublicIP": "", "ServerName": "Astroneer Dedicated Server", "MaximumPlayerCount": "12", "OwnerName": "", "OwnerGuid": "", "PlayerActivityTimeout": "0", "ServerPassword": "", "bDisableServerTravel": "False", "DenyUnlistedPlayers": "False", "VerbosePlayerProperties": "True", "AutoSaveGameInterval": "900", "BackupSaveGamesInterval": "7200", "ServerGuid": uuid.uuid4().hex, "ActiveSaveFileDescriptiveName": "SAVE_1", "ServerAdvertisedName": "", "ConsolePort": "1234", "ConsolePassword": uuid.uuid4().hex, "HeartbeatInterval": "0" } } AstroLogging.logPrint( "Baselining AstroServerSettings.ini...", "debug") config = MultiConfig().baseline(confPath, baseConfig) settings = config.getdict()['/Script/Astro.AstroServerSettings'] baseConfig = { "URL": { "Port": "7777" }, "/Script/OnlineSubsystemUtils.IpNetDriver": { "MaxClientRate": "1000000", "MaxInternetClientRate": "1000000" }, '/Game/ChatMod/ChatManager.ChatManager_C': { "WebhookUrl": f"\"http://localhost/api/{launcher.launcherConfig.RODataURL}\"" } } curLog = "Engine.ini" AstroLogging.logPrint("Baselining Engine.ini...", "debug") config = MultiConfig().baseline(os.path.join( curPath, r"Astro\Saved\Config\WindowsServer\Engine.ini"), baseConfig) # print(settings) EngineINI = config.getdict() settings.update(EngineINI['URL']) if type(EngineINI['URL']['Port']) == list: AstroLogging.logPrint("Duplicate Ports detected! Please only list one Port.", "critical") raise TypeError # print(settings) return settings except Exception as e: AstroLogging.logPrint(f"Error parsing {curLog} file!", "critical") AstroLogging.logPrint("Could not retrieve INI settings!", "critical") AstroLogging.logPrint( "Please ensure everything is correctly formatted...", "critical") AstroLogging.logPrint( "or delete the INI and allow the launcher to recreate it!", "critical") AstroLogging.logPrint(e, "critical", True) try: launcher.DedicatedServer.kill_server() except: try: launcher.kill_launcher() except: pass
def get_current_settings(launcher, ovrIP=False): curPath = launcher.astroPath confPath = os.path.join( curPath, r"Astro\Saved\Config\WindowsServer\AstroServerSettings.ini") ovrConfig = { "/Script/Astro.AstroServerSettings": { "VerbosePlayerProperties": "True", "HeartbeatInterval": "0" } } try: tConfig = MultiConfig().baseline(confPath, {}) bIP = tConfig.getdict()[ '/Script/Astro.AstroServerSettings'].get("PublicIP") validIP = valid_ip(bIP) if validIP and IP(bIP).iptype() != 'PUBLIC': validIP = False AstroLogging.logPrint( "PublicIP field (AstroServerSettings.ini) contained a Private IP!", "warning") AstroLogging.logPrint( "This will be automatically fixed..", "warning") except: validIP = False try: if ovrIP: if launcher.launcherConfig.OverwritePublicIP or not validIP: ovrConfig["/Script/Astro.AstroServerSettings"]["PublicIP"] = get_public_ip() except: t = "warning" if not validIP: t = "error" AstroLogging.logPrint("Could not update PublicIP!", t) try: MultiConfig().overwrite_with(confPath, ovrConfig) baseConfig = { "/Script/Astro.AstroServerSettings": { "bLoadAutoSave": "True", "MaxServerFramerate": "30.000000", "MaxServerIdleFramerate": "3.000000", "bWaitForPlayersBeforeShutdown": "False", "PublicIP": "", "ServerName": "Astroneer Dedicated Server", "MaximumPlayerCount": "12", "OwnerName": "", "OwnerGuid": "", "PlayerActivityTimeout": "0", "ServerPassword": "", "bDisableServerTravel": "False", "DenyUnlistedPlayers": "False", "VerbosePlayerProperties": "True", "AutoSaveGameInterval": "900", "BackupSaveGamesInterval": "7200", "ServerGuid": uuid.uuid4().hex, "ActiveSaveFileDescriptiveName": "SAVE_1", "ServerAdvertisedName": "", "ConsolePort": "1234", "ConsolePassword": uuid.uuid4().hex, "HeartbeatInterval": "0" } } config = MultiConfig().baseline(confPath, baseConfig) settings = config.getdict()['/Script/Astro.AstroServerSettings'] baseConfig = { "URL": { "Port": "7777" }, "/Script/OnlineSubsystemUtils.IpNetDriver": { "MaxClientRate": "1000000", "MaxInternetClientRate": "1000000" } } config = MultiConfig().baseline(os.path.join( curPath, r"Astro\Saved\Config\WindowsServer\Engine.ini"), baseConfig) # print(settings) settings.update(config.getdict()['URL']) # print(settings) return settings except: AstroLogging.logPrint("Could not retrieve INI settings!", "critical") AstroLogging.logPrint( "Please ensure everything is correctly formatted...", "critical") AstroLogging.logPrint( "or delete the INI and allow the launcher to recreate it!", "critical") try: launcher.DedicatedServer.kill_server() except: try: launcher.kill_launcher() except: pass