From 9dffc25cc8c37fa6a0df18c79f8fad99e11fee15 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Tue, 19 Mar 2024 00:08:55 +0000 Subject: [PATCH 01/48] Prepare 4.3.2 release base --- CHANGELOG.md | 11 +++++++++++ README.md | 2 +- app/config/version.json | 2 +- sonar-project.properties | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46128266..44750a39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,15 @@ # Changelog +## --- [4.3.2] - 2024/TBD +### New features +TBD +### Bug fixes +TBD +### Tweaks +TBD +### Lang +TBD +

+ ## --- [4.3.1] - 2024/03/18 ### Bug fixes - Fix Server ID Rework for backups, schedules, and roles (INT ID to UUID migration) ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/729)) diff --git a/README.md b/README.md index bc621c7d..ae70bd0e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![Crafty Logo](app/frontend/static/assets/images/logo_long.svg)](https://craftycontrol.com) -# Crafty Controller 4.3.1 +# Crafty Controller 4.3.2 > Python based Control Panel for your Minecraft Server ## What is Crafty Controller? diff --git a/app/config/version.json b/app/config/version.json index 9a8d1a7f..8dffa727 100644 --- a/app/config/version.json +++ b/app/config/version.json @@ -1,5 +1,5 @@ { "major": 4, "minor": 3, - "sub": 1 + "sub": 2 } diff --git a/sonar-project.properties b/sonar-project.properties index b6fa060c..a5f5e258 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -3,7 +3,7 @@ sonar.organization=crafty-controller # This is the name and version displayed in the SonarCloud UI. sonar.projectName=Crafty 4 -sonar.projectVersion=4.3.1 +sonar.projectVersion=4.3.2 sonar.python.version=3.9, 3.10, 3.11 sonar.exclusions=app/migrations/**, app/frontend/static/assets/vendors/** From 912785b28014f7817b584eea606e517bb42f4aa7 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Thu, 21 Mar 2024 18:10:39 -0400 Subject: [PATCH 02/48] Remove http references from codebase --- app/classes/web/routes/api/crafty/config/index.py | 1 - app/classes/web/tornado_handler.py | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/app/classes/web/routes/api/crafty/config/index.py b/app/classes/web/routes/api/crafty/config/index.py index c901732c..4a9cbd63 100644 --- a/app/classes/web/routes/api/crafty/config/index.py +++ b/app/classes/web/routes/api/crafty/config/index.py @@ -9,7 +9,6 @@ from app.classes.web.base_api_handler import BaseApiHandler config_json_schema = { "type": "object", "properties": { - "http_port": {"type": "integer"}, "https_port": {"type": "integer"}, "language": { "type": "string", diff --git a/app/classes/web/tornado_handler.py b/app/classes/web/tornado_handler.py index f65f4fca..6285edfc 100644 --- a/app/classes/web/tornado_handler.py +++ b/app/classes/web/tornado_handler.py @@ -98,7 +98,6 @@ class Webserver: # let's verify we have an SSL cert self.helper.create_self_signed_cert() - http_port = self.helper.get_setting("http_port") https_port = self.helper.get_setting("https_port") debug_errors = self.helper.get_setting("show_errors") @@ -110,9 +109,6 @@ class Webserver: cookie_secret = self.helper.random_string_generator(32) HelpersManagement.set_cookie_secret(cookie_secret) - if not http_port and http_port != 0: - http_port = 8000 - if not https_port: https_port = 8443 @@ -125,7 +121,7 @@ class Webserver: ), } - logger.info(f"Starting Web Server on ports http:{http_port} https:{https_port}") + logger.info(f"Starting Web Server on ports https:{https_port}") asyncio.set_event_loop(asyncio.new_event_loop()) From d39f93bfa5f80eeea9faef0276ac830272b24906 Mon Sep 17 00:00:00 2001 From: Silversthorn Date: Sat, 23 Mar 2024 11:25:05 +0100 Subject: [PATCH 03/48] trying loading only the diff migrations at constructor --- app/classes/shared/migration.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/classes/shared/migration.py b/app/classes/shared/migration.py index 6a93802b..9cf52857 100644 --- a/app/classes/shared/migration.py +++ b/app/classes/shared/migration.py @@ -372,11 +372,9 @@ class MigrationManager(object): Create migrator """ migrator = Migrator(self.database) - # Removing the up_one to prevent running all - # migrations each time we got a new one. - # It's handled by migration.up() function. - # for name in self.done: - # self.up_one(name, migrator, True) + # Creating false migrations from the + for name in self.diff: + self.up_one(name, migrator, True) return migrator def compile(self, name, migrate="", rollback=""): From c00cb1a61d2615354b36db0469dd979fac744a19 Mon Sep 17 00:00:00 2001 From: Silversthorn Date: Sat, 23 Mar 2024 11:30:24 +0100 Subject: [PATCH 04/48] Splitting migration in 2 files to remove migrator.run from it --- .../20240216_rework_servers_uuid.py | 114 ----------- .../20240216_rework_servers_uuid_part2.py | 184 ++++++++++++++++++ 2 files changed, 184 insertions(+), 114 deletions(-) create mode 100644 app/migrations/20240216_rework_servers_uuid_part2.py diff --git a/app/migrations/20240216_rework_servers_uuid.py b/app/migrations/20240216_rework_servers_uuid.py index c741a84c..eea3f336 100644 --- a/app/migrations/20240216_rework_servers_uuid.py +++ b/app/migrations/20240216_rework_servers_uuid.py @@ -87,8 +87,6 @@ def migrate(migrator: Migrator, database, **kwargs): ), ) - migrator.run() - logger.info("Migrating Data from Int to UUID (Type Change) : SUCCESS") Console.info("Migrating Data from Int to UUID (Type Change) : SUCCESS") @@ -101,118 +99,6 @@ def migrate(migrator: Migrator, database, **kwargs): last_migration.delete() return - try: - logger.info("Migrating Data from Int to UUID (Foreign Keys)") - Console.info("Migrating Data from Int to UUID (Foreign Keys)") - # Changes on Audit Log Table - for audit_log in AuditLog.select(): - old_server_id = audit_log.server_id_id - if old_server_id == "0" or old_server_id is None: - server_uuid = None - else: - try: - server = Servers.get_by_id(old_server_id) - server_uuid = server.server_uuid - except: - server_uuid = old_server_id - AuditLog.update(server_id=server_uuid).where( - AuditLog.audit_id == audit_log.audit_id - ).execute() - - # Changes on Webhooks Log Table - for webhook in Webhooks.select(): - old_server_id = webhook.server_id_id - try: - server = Servers.get_by_id(old_server_id) - server_uuid = server.server_uuid - except: - server_uuid = old_server_id - Webhooks.update(server_id=server_uuid).where( - Webhooks.id == webhook.id - ).execute() - - # Changes on Schedules Log Table - for schedule in Schedules.select(): - old_server_id = schedule.server_id_id - try: - server = Servers.get_by_id(old_server_id) - server_uuid = server.server_uuid - except: - server_uuid = old_server_id - Schedules.update(server_id=server_uuid).where( - Schedules.schedule_id == schedule.schedule_id - ).execute() - - # Changes on Backups Log Table - for backup in Backups.select(): - old_server_id = backup.server_id_id - try: - server = Servers.get_by_id(old_server_id) - server_uuid = server.server_uuid - except: - server_uuid = old_server_id - Backups.update(server_id=server_uuid).where( - Backups.server_id == old_server_id - ).execute() - - # Changes on RoleServers Log Table - for role_servers in RoleServers.select(): - old_server_id = role_servers.server_id_id - try: - server = Servers.get_by_id(old_server_id) - server_uuid = server.server_uuid - except: - server_uuid = old_server_id - RoleServers.update(server_id=server_uuid).where( - RoleServers.role_id == role_servers.id - and RoleServers.server_id == old_server_id - ).execute() - - logger.info("Migrating Data from Int to UUID (Foreign Keys) : SUCCESS") - Console.info("Migrating Data from Int to UUID (Foreign Keys) : SUCCESS") - - except Exception as ex: - logger.error("Error while migrating Data from Int to UUID (Foreign Keys)") - logger.error(ex) - Console.error("Error while migrating Data from Int to UUID (Foreign Keys)") - Console.error(ex) - last_migration = MigrateHistory.get_by_id(MigrateHistory.select().count()) - last_migration.delete() - return - - try: - logger.info("Migrating Data from Int to UUID (Primary Keys)") - Console.info("Migrating Data from Int to UUID (Primary Keys)") - # Migrating servers from the old id type to the new one - for server in Servers.select(): - Servers.update(server_id=server.server_uuid).where( - Servers.server_id == server.server_id - ).execute() - - logger.info("Migrating Data from Int to UUID (Primary Keys) : SUCCESS") - Console.info("Migrating Data from Int to UUID (Primary Keys) : SUCCESS") - - except Exception as ex: - logger.error("Error while migrating Data from Int to UUID (Primary Keys)") - logger.error(ex) - Console.error("Error while migrating Data from Int to UUID (Primary Keys)") - Console.error(ex) - last_migration = MigrateHistory.get_by_id(MigrateHistory.select().count()) - last_migration.delete() - return - - # Changes on Server Table - logger.info("Migrating Data from Int to UUID (Removing UUID Field from Servers)") - Console.info("Migrating Data from Int to UUID (Removing UUID Field from Servers)") - migrator.drop_columns("servers", ["server_uuid"]) - migrator.run() - logger.info( - "Migrating Data from Int to UUID (Removing UUID Field from Servers) : SUCCESS" - ) - Console.info( - "Migrating Data from Int to UUID (Removing UUID Field from Servers) : SUCCESS" - ) - return diff --git a/app/migrations/20240216_rework_servers_uuid_part2.py b/app/migrations/20240216_rework_servers_uuid_part2.py new file mode 100644 index 00000000..6cba7298 --- /dev/null +++ b/app/migrations/20240216_rework_servers_uuid_part2.py @@ -0,0 +1,184 @@ +import datetime +import uuid +import peewee +import logging + +from app.classes.shared.console import Console +from app.classes.shared.migration import Migrator, MigrateHistory +from app.classes.models.management import ( + AuditLog, + Webhooks, + Schedules, + Backups, +) +from app.classes.models.server_permissions import RoleServers + +logger = logging.getLogger(__name__) + + +def migrate(migrator: Migrator, database, **kwargs): + """ + Write your migrations here. + """ + db = database + + # ********************************************************************************** + # Servers New Model from Old (easier to migrate without dunmping Database) + # ********************************************************************************** + class Servers(peewee.Model): + server_id = peewee.CharField(primary_key=True, default=str(uuid.uuid4())) + created = peewee.DateTimeField(default=datetime.datetime.now) + server_uuid = peewee.CharField(default="", index=True) + server_name = peewee.CharField(default="Server", index=True) + path = peewee.CharField(default="") + backup_path = peewee.CharField(default="") + executable = peewee.CharField(default="") + log_path = peewee.CharField(default="") + execution_command = peewee.CharField(default="") + auto_start = peewee.BooleanField(default=0) + auto_start_delay = peewee.IntegerField(default=10) + crash_detection = peewee.BooleanField(default=0) + stop_command = peewee.CharField(default="stop") + executable_update_url = peewee.CharField(default="") + server_ip = peewee.CharField(default="127.0.0.1") + server_port = peewee.IntegerField(default=25565) + logs_delete_after = peewee.IntegerField(default=0) + type = peewee.CharField(default="minecraft-java") + show_status = peewee.BooleanField(default=1) + created_by = peewee.IntegerField(default=-100) + shutdown_timeout = peewee.IntegerField(default=60) + ignored_exits = peewee.CharField(default="0") + + class Meta: + table_name = "servers" + database = db + + try: + logger.info("Migrating Data from Int to UUID (Foreign Keys)") + Console.info("Migrating Data from Int to UUID (Foreign Keys)") + # Changes on Audit Log Table + for audit_log in AuditLog.select(): + old_server_id = audit_log.server_id_id + if old_server_id == "0" or old_server_id is None: + server_uuid = None + else: + try: + server = Servers.get_by_id(old_server_id) + server_uuid = server.server_uuid + except: + server_uuid = old_server_id + AuditLog.update(server_id=server_uuid).where( + AuditLog.audit_id == audit_log.audit_id + ).execute() + + # Changes on Webhooks Log Table + for webhook in Webhooks.select(): + old_server_id = webhook.server_id_id + try: + server = Servers.get_by_id(old_server_id) + server_uuid = server.server_uuid + except: + server_uuid = old_server_id + Webhooks.update(server_id=server_uuid).where( + Webhooks.id == webhook.id + ).execute() + + # Changes on Schedules Log Table + for schedule in Schedules.select(): + old_server_id = schedule.server_id_id + try: + server = Servers.get_by_id(old_server_id) + server_uuid = server.server_uuid + except: + server_uuid = old_server_id + Schedules.update(server_id=server_uuid).where( + Schedules.schedule_id == schedule.schedule_id + ).execute() + + # Changes on Backups Log Table + for backup in Backups.select(): + old_server_id = backup.server_id_id + try: + server = Servers.get_by_id(old_server_id) + server_uuid = server.server_uuid + except: + server_uuid = old_server_id + Backups.update(server_id=server_uuid).where( + Backups.server_id == old_server_id + ).execute() + + # Changes on RoleServers Log Table + for role_servers in RoleServers.select(): + old_server_id = role_servers.server_id_id + try: + server = Servers.get_by_id(old_server_id) + server_uuid = server.server_uuid + except: + server_uuid = old_server_id + RoleServers.update(server_id=server_uuid).where( + RoleServers.role_id == role_servers.id + and RoleServers.server_id == old_server_id + ).execute() + + logger.info("Migrating Data from Int to UUID (Foreign Keys) : SUCCESS") + Console.info("Migrating Data from Int to UUID (Foreign Keys) : SUCCESS") + + except Exception as ex: + logger.error("Error while migrating Data from Int to UUID (Foreign Keys)") + logger.error(ex) + Console.error("Error while migrating Data from Int to UUID (Foreign Keys)") + Console.error(ex) + last_migration = MigrateHistory.get_by_id(MigrateHistory.select().count()) + last_migration.delete() + return + + try: + logger.info("Migrating Data from Int to UUID (Primary Keys)") + Console.info("Migrating Data from Int to UUID (Primary Keys)") + # Migrating servers from the old id type to the new one + for server in Servers.select(): + Servers.update(server_id=server.server_uuid).where( + Servers.server_id == server.server_id + ).execute() + + logger.info("Migrating Data from Int to UUID (Primary Keys) : SUCCESS") + Console.info("Migrating Data from Int to UUID (Primary Keys) : SUCCESS") + + except Exception as ex: + logger.error("Error while migrating Data from Int to UUID (Primary Keys)") + logger.error(ex) + Console.error("Error while migrating Data from Int to UUID (Primary Keys)") + Console.error(ex) + last_migration = MigrateHistory.get_by_id(MigrateHistory.select().count()) + last_migration.delete() + return + + return + + +def rollback(migrator: Migrator, database, **kwargs): + """ + Write your rollback migrations here. + """ + db = database + + # Changes on Server Table + migrator.alter_column_type( + "servers", + "server_id", + peewee.AutoField(), + ) + + # Changes on Audit Log Table + migrator.alter_column_type( + AuditLog, + "server_id", + peewee.IntegerField(default=None, index=True), + ) + + # Changes on Webhook Table + migrator.alter_column_type( + Webhooks, + "server_id", + peewee.IntegerField(null=True), + ) From 8f8feef6de222fbcadf5ea185e66f6bb9529cdd4 Mon Sep 17 00:00:00 2001 From: Silversthorn Date: Sat, 23 Mar 2024 12:11:43 +0100 Subject: [PATCH 05/48] Solution is disabling update if already done --- app/classes/shared/migration.py | 6 ++++-- app/migrations/20240216_rework_servers_uuid_part2.py | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/classes/shared/migration.py b/app/classes/shared/migration.py index 9cf52857..287bb4f3 100644 --- a/app/classes/shared/migration.py +++ b/app/classes/shared/migration.py @@ -372,8 +372,10 @@ class MigrationManager(object): Create migrator """ migrator = Migrator(self.database) - # Creating false migrations from the - for name in self.diff: + # Running false migrations to retrives the schemes of + # the precedents created tables in the table_dict element + # It's useful to run the new migrations + for name in self.done: self.up_one(name, migrator, True) return migrator diff --git a/app/migrations/20240216_rework_servers_uuid_part2.py b/app/migrations/20240216_rework_servers_uuid_part2.py index 6cba7298..58f2ebb8 100644 --- a/app/migrations/20240216_rework_servers_uuid_part2.py +++ b/app/migrations/20240216_rework_servers_uuid_part2.py @@ -22,6 +22,13 @@ def migrate(migrator: Migrator, database, **kwargs): """ db = database + this_migration = MigrateHistory.get(MigrateHistory.name == "20240216_rework_servers_uuid_part2") + if this_migration: + Console.debug("Update database already done, skipping this migration") + return + else : + Console.debug("Update database not done, doing : Migration Data from Int to UUID") + # ********************************************************************************** # Servers New Model from Old (easier to migrate without dunmping Database) # ********************************************************************************** From 5e4dbb1902c93f0ab1051ccfeaaf266f52c34e38 Mon Sep 17 00:00:00 2001 From: Silversthorn Date: Sat, 23 Mar 2024 12:28:22 +0100 Subject: [PATCH 06/48] Disabling code if already updated to prevent unnecessary errors messages --- app/migrations/20240216_rework_servers_uuid_part2.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/migrations/20240216_rework_servers_uuid_part2.py b/app/migrations/20240216_rework_servers_uuid_part2.py index 58f2ebb8..a3e30cd8 100644 --- a/app/migrations/20240216_rework_servers_uuid_part2.py +++ b/app/migrations/20240216_rework_servers_uuid_part2.py @@ -22,12 +22,10 @@ def migrate(migrator: Migrator, database, **kwargs): """ db = database - this_migration = MigrateHistory.get(MigrateHistory.name == "20240216_rework_servers_uuid_part2") - if this_migration: - Console.debug("Update database already done, skipping this migration") + this_migration = MigrateHistory.get_or_none(MigrateHistory.name == "20240216_rework_servers_uuid_part2") + if this_migration is not None: + Console.debug("Update database already done, skipping this part") return - else : - Console.debug("Update database not done, doing : Migration Data from Int to UUID") # ********************************************************************************** # Servers New Model from Old (easier to migrate without dunmping Database) From 64a1defb9558bc90da86f24e35873110bd58a24b Mon Sep 17 00:00:00 2001 From: Silversthorn Date: Sat, 23 Mar 2024 12:29:16 +0100 Subject: [PATCH 07/48] Removing logging and console to prevent unnecessary messages --- app/migrations/20240216_rework_servers_uuid.py | 6 ------ app/migrations/20240310_fixing_rework_servers_uuid.py | 8 -------- 2 files changed, 14 deletions(-) diff --git a/app/migrations/20240216_rework_servers_uuid.py b/app/migrations/20240216_rework_servers_uuid.py index eea3f336..facd0e42 100644 --- a/app/migrations/20240216_rework_servers_uuid.py +++ b/app/migrations/20240216_rework_servers_uuid.py @@ -54,9 +54,6 @@ def migrate(migrator: Migrator, database, **kwargs): database = db try: - logger.info("Migrating Data from Int to UUID (Type Change)") - Console.info("Migrating Data from Int to UUID (Type Change)") - # Changes on Server Table migrator.alter_column_type( Servers, @@ -87,9 +84,6 @@ def migrate(migrator: Migrator, database, **kwargs): ), ) - logger.info("Migrating Data from Int to UUID (Type Change) : SUCCESS") - Console.info("Migrating Data from Int to UUID (Type Change) : SUCCESS") - except Exception as ex: logger.error("Error while migrating Data from Int to UUID (Type Change)") logger.error(ex) diff --git a/app/migrations/20240310_fixing_rework_servers_uuid.py b/app/migrations/20240310_fixing_rework_servers_uuid.py index 3c613e52..111b43f9 100644 --- a/app/migrations/20240310_fixing_rework_servers_uuid.py +++ b/app/migrations/20240310_fixing_rework_servers_uuid.py @@ -48,9 +48,6 @@ def migrate(migrator: Migrator, database, **kwargs): database = db try: - logger.info("Migrating Data from Int to UUID (Fixing Issue)") - Console.info("Migrating Data from Int to UUID (Fixing Issue)") - # Changes on Servers Roles Table migrator.alter_column_type( RoleServers, @@ -87,11 +84,6 @@ def migrate(migrator: Migrator, database, **kwargs): ), ) - migrator.run() - - logger.info("Migrating Data from Int to UUID (Fixing Issue) : SUCCESS") - Console.info("Migrating Data from Int to UUID (Fixing Issue) : SUCCESS") - except Exception as ex: logger.error("Error while migrating Data from Int to UUID (Fixing Issue)") logger.error(ex) From f0086c70f789be4048896149cecd0b77947967fe Mon Sep 17 00:00:00 2001 From: Silversthorn Date: Sat, 23 Mar 2024 12:37:46 +0100 Subject: [PATCH 08/48] importing class instead of copy pasting it --- .../20240216_rework_servers_uuid.py | 32 +--------------- .../20240216_rework_servers_uuid_part2.py | 32 +--------------- .../20240310_fixing_rework_servers_uuid.py | 38 ++++--------------- 3 files changed, 10 insertions(+), 92 deletions(-) diff --git a/app/migrations/20240216_rework_servers_uuid.py b/app/migrations/20240216_rework_servers_uuid.py index facd0e42..7e93ebf8 100644 --- a/app/migrations/20240216_rework_servers_uuid.py +++ b/app/migrations/20240216_rework_servers_uuid.py @@ -12,6 +12,7 @@ from app.classes.models.management import ( Backups, ) from app.classes.models.server_permissions import RoleServers +from app.classes.models.servers import Servers logger = logging.getLogger(__name__) @@ -22,37 +23,6 @@ def migrate(migrator: Migrator, database, **kwargs): """ db = database - # ********************************************************************************** - # Servers New Model from Old (easier to migrate without dunmping Database) - # ********************************************************************************** - class Servers(peewee.Model): - server_id = peewee.CharField(primary_key=True, default=str(uuid.uuid4())) - created = peewee.DateTimeField(default=datetime.datetime.now) - server_uuid = peewee.CharField(default="", index=True) - server_name = peewee.CharField(default="Server", index=True) - path = peewee.CharField(default="") - backup_path = peewee.CharField(default="") - executable = peewee.CharField(default="") - log_path = peewee.CharField(default="") - execution_command = peewee.CharField(default="") - auto_start = peewee.BooleanField(default=0) - auto_start_delay = peewee.IntegerField(default=10) - crash_detection = peewee.BooleanField(default=0) - stop_command = peewee.CharField(default="stop") - executable_update_url = peewee.CharField(default="") - server_ip = peewee.CharField(default="127.0.0.1") - server_port = peewee.IntegerField(default=25565) - logs_delete_after = peewee.IntegerField(default=0) - type = peewee.CharField(default="minecraft-java") - show_status = peewee.BooleanField(default=1) - created_by = peewee.IntegerField(default=-100) - shutdown_timeout = peewee.IntegerField(default=60) - ignored_exits = peewee.CharField(default="0") - - class Meta: - table_name = "servers" - database = db - try: # Changes on Server Table migrator.alter_column_type( diff --git a/app/migrations/20240216_rework_servers_uuid_part2.py b/app/migrations/20240216_rework_servers_uuid_part2.py index a3e30cd8..a778ce28 100644 --- a/app/migrations/20240216_rework_servers_uuid_part2.py +++ b/app/migrations/20240216_rework_servers_uuid_part2.py @@ -12,6 +12,7 @@ from app.classes.models.management import ( Backups, ) from app.classes.models.server_permissions import RoleServers +from app.classes.models.servers import Servers logger = logging.getLogger(__name__) @@ -27,37 +28,6 @@ def migrate(migrator: Migrator, database, **kwargs): Console.debug("Update database already done, skipping this part") return - # ********************************************************************************** - # Servers New Model from Old (easier to migrate without dunmping Database) - # ********************************************************************************** - class Servers(peewee.Model): - server_id = peewee.CharField(primary_key=True, default=str(uuid.uuid4())) - created = peewee.DateTimeField(default=datetime.datetime.now) - server_uuid = peewee.CharField(default="", index=True) - server_name = peewee.CharField(default="Server", index=True) - path = peewee.CharField(default="") - backup_path = peewee.CharField(default="") - executable = peewee.CharField(default="") - log_path = peewee.CharField(default="") - execution_command = peewee.CharField(default="") - auto_start = peewee.BooleanField(default=0) - auto_start_delay = peewee.IntegerField(default=10) - crash_detection = peewee.BooleanField(default=0) - stop_command = peewee.CharField(default="stop") - executable_update_url = peewee.CharField(default="") - server_ip = peewee.CharField(default="127.0.0.1") - server_port = peewee.IntegerField(default=25565) - logs_delete_after = peewee.IntegerField(default=0) - type = peewee.CharField(default="minecraft-java") - show_status = peewee.BooleanField(default=1) - created_by = peewee.IntegerField(default=-100) - shutdown_timeout = peewee.IntegerField(default=60) - ignored_exits = peewee.CharField(default="0") - - class Meta: - table_name = "servers" - database = db - try: logger.info("Migrating Data from Int to UUID (Foreign Keys)") Console.info("Migrating Data from Int to UUID (Foreign Keys)") diff --git a/app/migrations/20240310_fixing_rework_servers_uuid.py b/app/migrations/20240310_fixing_rework_servers_uuid.py index 111b43f9..cae0dec4 100644 --- a/app/migrations/20240310_fixing_rework_servers_uuid.py +++ b/app/migrations/20240310_fixing_rework_servers_uuid.py @@ -7,6 +7,7 @@ from app.classes.shared.console import Console from app.classes.shared.migration import Migrator, MigrateHistory from app.classes.models.management import Schedules, Backups from app.classes.models.server_permissions import RoleServers +from app.classes.models.servers import Servers logger = logging.getLogger(__name__) @@ -17,36 +18,6 @@ def migrate(migrator: Migrator, database, **kwargs): """ db = database - # ********************************************************************************** - # Servers New Model from Old (easier to migrate without dunmping Database) - # ********************************************************************************** - class Servers(peewee.Model): - server_id = peewee.CharField(primary_key=True, default=str(uuid.uuid4())) - created = peewee.DateTimeField(default=datetime.datetime.now) - server_name = peewee.CharField(default="Server", index=True) - path = peewee.CharField(default="") - backup_path = peewee.CharField(default="") - executable = peewee.CharField(default="") - log_path = peewee.CharField(default="") - execution_command = peewee.CharField(default="") - auto_start = peewee.BooleanField(default=0) - auto_start_delay = peewee.IntegerField(default=10) - crash_detection = peewee.BooleanField(default=0) - stop_command = peewee.CharField(default="stop") - executable_update_url = peewee.CharField(default="") - server_ip = peewee.CharField(default="127.0.0.1") - server_port = peewee.IntegerField(default=25565) - logs_delete_after = peewee.IntegerField(default=0) - type = peewee.CharField(default="minecraft-java") - show_status = peewee.BooleanField(default=1) - created_by = peewee.IntegerField(default=-100) - shutdown_timeout = peewee.IntegerField(default=60) - ignored_exits = peewee.CharField(default="0") - - class Meta: - table_name = "servers" - database = db - try: # Changes on Servers Roles Table migrator.alter_column_type( @@ -84,6 +55,9 @@ def migrate(migrator: Migrator, database, **kwargs): ), ) + # Drop Column after migration + migrator.drop_columns("servers", ["server_uuid"]) + except Exception as ex: logger.error("Error while migrating Data from Int to UUID (Fixing Issue)") logger.error(ex) @@ -122,3 +96,7 @@ def rollback(migrator: Migrator, database, **kwargs): "server_id", peewee.IntegerField(null=True), ) + + migrator.add_columns( + "servers", server_uuid=peewee.CharField(default="", index=True) + ) # Recreating the column for roll back From 3a4037a3323e9bb8dc6b15c46b483ef05a7acf6f Mon Sep 17 00:00:00 2001 From: Silversthorn Date: Sat, 23 Mar 2024 12:57:41 +0100 Subject: [PATCH 09/48] trying to add rollback methods --- .../20240216_rework_servers_uuid_part2.py | 160 ++++++++++++++++-- 1 file changed, 142 insertions(+), 18 deletions(-) diff --git a/app/migrations/20240216_rework_servers_uuid_part2.py b/app/migrations/20240216_rework_servers_uuid_part2.py index a778ce28..94c78454 100644 --- a/app/migrations/20240216_rework_servers_uuid_part2.py +++ b/app/migrations/20240216_rework_servers_uuid_part2.py @@ -13,6 +13,7 @@ from app.classes.models.management import ( ) from app.classes.models.server_permissions import RoleServers from app.classes.models.servers import Servers +from app.classes.models.base_model import BaseModel logger = logging.getLogger(__name__) @@ -137,23 +138,146 @@ def rollback(migrator: Migrator, database, **kwargs): """ db = database - # Changes on Server Table - migrator.alter_column_type( - "servers", - "server_id", - peewee.AutoField(), - ) + # Condition to prevent running rollback each time we've got a rollback to do + this_migration = MigrateHistory.get_or_none(MigrateHistory.name == "20240216_rework_servers_uuid_part2") + if this_migration is None: + Console.debug("Update database already done, skipping this part") + return - # Changes on Audit Log Table - migrator.alter_column_type( - AuditLog, - "server_id", - peewee.IntegerField(default=None, index=True), - ) + # ********************************************************************************** + # Old Servers Model + # ********************************************************************************** + class OldServers(BaseModel): + server_id = peewee.AutoField() + created = peewee.DateTimeField(default=datetime.datetime.now) + server_uuid = peewee.CharField(default="", index=True) + path = peewee.CharField(default="") + backup_path = peewee.CharField(default="") + executable = peewee.CharField(default="") + log_path = peewee.CharField(default="") + execution_command = peewee.CharField(default="") + auto_start = peewee.BooleanField(default=0) + auto_start_delay = peewee.IntegerField(default=10) + crash_detection = peewee.BooleanField(default=0) + stop_command = peewee.CharField(default="stop") + executable_update_url = peewee.CharField(default="") + server_ip = peewee.CharField(default="127.0.0.1") + server_port = peewee.IntegerField(default=25565) + logs_delete_after = peewee.IntegerField(default=0) + type = peewee.CharField(default="minecraft-java") + show_status = peewee.BooleanField(default=1) + created_by = peewee.IntegerField(default=-100) + # created_by = ForeignKeyField(Users, backref="creator_server", null=True) + shutdown_timeout = peewee.IntegerField(default=60) + ignored_exits = peewee.CharField(default="0") + count_players = peewee.BooleanField(default=True) - # Changes on Webhook Table - migrator.alter_column_type( - Webhooks, - "server_id", - peewee.IntegerField(null=True), - ) + class Meta: + table_name = "servers" + + try: + logger.info("Migrating Data from UUID to Int (Primary Keys)") + Console.info("Migrating Data from UUID to Int (Primary Keys)") + # Migrating servers from the old id type to the new one + new_id = 0 + for server in Servers.select(): + new_id += 1 + Servers.update(server_uuid=server.server_id).where( + Servers.server_id == server.server_id + ).execute() + Servers.update(server_id=new_id).where( + Servers.server_id == server.server_id + ).execute() + + logger.info("Migrating Data from UUID to Int (Primary Keys) : SUCCESS") + Console.info("Migrating Data from UUID to Int (Primary Keys) : SUCCESS") + + except Exception as ex: + logger.error("Error while migrating Data from UUID to Int (Primary Keys)") + logger.error(ex) + Console.error("Error while migrating Data from UUID to Int (Primary Keys)") + Console.error(ex) + last_migration = MigrateHistory.get_by_id(MigrateHistory.select().count()) + last_migration.delete() + return + + try: + logger.info("Migrating Data from UUID to Int (Foreign Keys)") + Console.info("Migrating Data from UUID to Int (Foreign Keys)") + # Changes on Audit Log Table + for audit_log in AuditLog.select(): + old_server_id = audit_log.server_id_id + if old_server_id is None: + new_server_id = 0 + else: + try: + server = OldServers.get_or_none(OldServers.server_uuid == old_server_id) + new_server_id = server.server_id + except: + new_server_id = old_server_id + AuditLog.update(server_id=new_server_id).where( + AuditLog.audit_id == audit_log.audit_id + ).execute() + + # Changes on Webhooks Log Table + for webhook in Webhooks.select(): + old_server_id = webhook.server_id_id + try: + server = OldServers.get_or_none(OldServers.server_uuid == old_server_id) + new_server_id = server.server_id + except: + new_server_id = old_server_id + Webhooks.update(server_id=new_server_id).where( + Webhooks.id == webhook.id + ).execute() + + # Changes on Schedules Log Table + for schedule in Schedules.select(): + old_server_id = schedule.server_id_id + try: + server = OldServers.get_or_none(OldServers.server_uuid == old_server_id) + new_server_id = server.server_id + except: + new_server_id = old_server_id + Schedules.update(server_id=new_server_id).where( + Schedules.schedule_id == schedule.schedule_id + ).execute() + + # Changes on Backups Log Table + for backup in Backups.select(): + old_server_id = backup.server_id_id + try: + server = OldServers.get_or_none(OldServers.server_uuid == old_server_id) + new_server_id = server.server_id + except: + new_server_id = old_server_id + Backups.update(server_id=new_server_id).where( + Backups.server_id == old_server_id + ).execute() + + # Changes on RoleServers Log Table + for role_servers in RoleServers.select(): + old_server_id = role_servers.server_id_id + try: + server = OldServers.get_or_none(OldServers.server_uuid == old_server_id) + new_server_id = server.server_id + except: + new_server_id = old_server_id + RoleServers.update(server_id=new_server_id).where( + RoleServers.role_id == role_servers.id + and RoleServers.server_id == old_server_id + ).execute() + + logger.info("Migrating Data from UUID to Int (Foreign Keys) : SUCCESS") + Console.info("Migrating Data from UUID to Int (Foreign Keys) : SUCCESS") + + except Exception as ex: + logger.error("Error while migrating Data from UUID to Int (Foreign Keys)") + logger.error(ex) + Console.error("Error while migrating Data from UUID to Int (Foreign Keys)") + Console.error(ex) + last_migration = MigrateHistory.get_by_id(MigrateHistory.select().count()) + last_migration.delete() + return + + return From 8ff83fa04546d9e5e15101962e6befec973eaa87 Mon Sep 17 00:00:00 2001 From: Silversthorn Date: Sat, 23 Mar 2024 13:14:47 +0100 Subject: [PATCH 10/48] appease black lint --- app/migrations/20240216_rework_servers_uuid_part2.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/migrations/20240216_rework_servers_uuid_part2.py b/app/migrations/20240216_rework_servers_uuid_part2.py index 94c78454..b2e91f92 100644 --- a/app/migrations/20240216_rework_servers_uuid_part2.py +++ b/app/migrations/20240216_rework_servers_uuid_part2.py @@ -24,7 +24,9 @@ def migrate(migrator: Migrator, database, **kwargs): """ db = database - this_migration = MigrateHistory.get_or_none(MigrateHistory.name == "20240216_rework_servers_uuid_part2") + this_migration = MigrateHistory.get_or_none( + MigrateHistory.name == "20240216_rework_servers_uuid_part2" + ) if this_migration is not None: Console.debug("Update database already done, skipping this part") return @@ -139,7 +141,9 @@ def rollback(migrator: Migrator, database, **kwargs): db = database # Condition to prevent running rollback each time we've got a rollback to do - this_migration = MigrateHistory.get_or_none(MigrateHistory.name == "20240216_rework_servers_uuid_part2") + this_migration = MigrateHistory.get_or_none( + MigrateHistory.name == "20240216_rework_servers_uuid_part2" + ) if this_migration is None: Console.debug("Update database already done, skipping this part") return @@ -211,7 +215,9 @@ def rollback(migrator: Migrator, database, **kwargs): new_server_id = 0 else: try: - server = OldServers.get_or_none(OldServers.server_uuid == old_server_id) + server = OldServers.get_or_none( + OldServers.server_uuid == old_server_id + ) new_server_id = server.server_id except: new_server_id = old_server_id From d30b3356378e512f2fb86f72e3f4c7382b9aa7f1 Mon Sep 17 00:00:00 2001 From: Silversthorn Date: Sat, 23 Mar 2024 13:32:54 +0100 Subject: [PATCH 11/48] renaming the file to run part 1 before part 2 --- ...rs_uuid_part2.py => 20240217_rework_servers_uuid_part2.py} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename app/migrations/{20240216_rework_servers_uuid_part2.py => 20240217_rework_servers_uuid_part2.py} (98%) diff --git a/app/migrations/20240216_rework_servers_uuid_part2.py b/app/migrations/20240217_rework_servers_uuid_part2.py similarity index 98% rename from app/migrations/20240216_rework_servers_uuid_part2.py rename to app/migrations/20240217_rework_servers_uuid_part2.py index b2e91f92..7414dfef 100644 --- a/app/migrations/20240216_rework_servers_uuid_part2.py +++ b/app/migrations/20240217_rework_servers_uuid_part2.py @@ -25,7 +25,7 @@ def migrate(migrator: Migrator, database, **kwargs): db = database this_migration = MigrateHistory.get_or_none( - MigrateHistory.name == "20240216_rework_servers_uuid_part2" + MigrateHistory.name == "20240217_rework_servers_uuid_part2" ) if this_migration is not None: Console.debug("Update database already done, skipping this part") @@ -142,7 +142,7 @@ def rollback(migrator: Migrator, database, **kwargs): # Condition to prevent running rollback each time we've got a rollback to do this_migration = MigrateHistory.get_or_none( - MigrateHistory.name == "20240216_rework_servers_uuid_part2" + MigrateHistory.name == "20240217_rework_servers_uuid_part2" ) if this_migration is None: Console.debug("Update database already done, skipping this part") From f71aaeb870ade8e8d8f9f33672034fa994aca7b7 Mon Sep 17 00:00:00 2001 From: Silversthorn Date: Sat, 23 Mar 2024 13:47:57 +0100 Subject: [PATCH 12/48] Adding back the Servers Model --- .../20240216_rework_servers_uuid.py | 32 ++++++++++- .../20240217_rework_servers_uuid_part2.py | 54 ++++++++++++++----- 2 files changed, 73 insertions(+), 13 deletions(-) diff --git a/app/migrations/20240216_rework_servers_uuid.py b/app/migrations/20240216_rework_servers_uuid.py index 7e93ebf8..facd0e42 100644 --- a/app/migrations/20240216_rework_servers_uuid.py +++ b/app/migrations/20240216_rework_servers_uuid.py @@ -12,7 +12,6 @@ from app.classes.models.management import ( Backups, ) from app.classes.models.server_permissions import RoleServers -from app.classes.models.servers import Servers logger = logging.getLogger(__name__) @@ -23,6 +22,37 @@ def migrate(migrator: Migrator, database, **kwargs): """ db = database + # ********************************************************************************** + # Servers New Model from Old (easier to migrate without dunmping Database) + # ********************************************************************************** + class Servers(peewee.Model): + server_id = peewee.CharField(primary_key=True, default=str(uuid.uuid4())) + created = peewee.DateTimeField(default=datetime.datetime.now) + server_uuid = peewee.CharField(default="", index=True) + server_name = peewee.CharField(default="Server", index=True) + path = peewee.CharField(default="") + backup_path = peewee.CharField(default="") + executable = peewee.CharField(default="") + log_path = peewee.CharField(default="") + execution_command = peewee.CharField(default="") + auto_start = peewee.BooleanField(default=0) + auto_start_delay = peewee.IntegerField(default=10) + crash_detection = peewee.BooleanField(default=0) + stop_command = peewee.CharField(default="stop") + executable_update_url = peewee.CharField(default="") + server_ip = peewee.CharField(default="127.0.0.1") + server_port = peewee.IntegerField(default=25565) + logs_delete_after = peewee.IntegerField(default=0) + type = peewee.CharField(default="minecraft-java") + show_status = peewee.BooleanField(default=1) + created_by = peewee.IntegerField(default=-100) + shutdown_timeout = peewee.IntegerField(default=60) + ignored_exits = peewee.CharField(default="0") + + class Meta: + table_name = "servers" + database = db + try: # Changes on Server Table migrator.alter_column_type( diff --git a/app/migrations/20240217_rework_servers_uuid_part2.py b/app/migrations/20240217_rework_servers_uuid_part2.py index 7414dfef..2303960c 100644 --- a/app/migrations/20240217_rework_servers_uuid_part2.py +++ b/app/migrations/20240217_rework_servers_uuid_part2.py @@ -12,7 +12,6 @@ from app.classes.models.management import ( Backups, ) from app.classes.models.server_permissions import RoleServers -from app.classes.models.servers import Servers from app.classes.models.base_model import BaseModel logger = logging.getLogger(__name__) @@ -24,6 +23,37 @@ def migrate(migrator: Migrator, database, **kwargs): """ db = database + # ********************************************************************************** + # Servers New Model from Old (easier to migrate without dunmping Database) + # ********************************************************************************** + class Servers(peewee.Model): + server_id = peewee.CharField(primary_key=True, default=str(uuid.uuid4())) + created = peewee.DateTimeField(default=datetime.datetime.now) + server_uuid = peewee.CharField(default="", index=True) + server_name = peewee.CharField(default="Server", index=True) + path = peewee.CharField(default="") + backup_path = peewee.CharField(default="") + executable = peewee.CharField(default="") + log_path = peewee.CharField(default="") + execution_command = peewee.CharField(default="") + auto_start = peewee.BooleanField(default=0) + auto_start_delay = peewee.IntegerField(default=10) + crash_detection = peewee.BooleanField(default=0) + stop_command = peewee.CharField(default="stop") + executable_update_url = peewee.CharField(default="") + server_ip = peewee.CharField(default="127.0.0.1") + server_port = peewee.IntegerField(default=25565) + logs_delete_after = peewee.IntegerField(default=0) + type = peewee.CharField(default="minecraft-java") + show_status = peewee.BooleanField(default=1) + created_by = peewee.IntegerField(default=-100) + shutdown_timeout = peewee.IntegerField(default=60) + ignored_exits = peewee.CharField(default="0") + + class Meta: + table_name = "servers" + database = db + this_migration = MigrateHistory.get_or_none( MigrateHistory.name == "20240217_rework_servers_uuid_part2" ) @@ -149,12 +179,13 @@ def rollback(migrator: Migrator, database, **kwargs): return # ********************************************************************************** - # Old Servers Model + # Servers New Model from Old (easier to migrate without dunmping Database) # ********************************************************************************** - class OldServers(BaseModel): - server_id = peewee.AutoField() + class Servers(peewee.Model): + server_id = peewee.CharField(primary_key=True, default=str(uuid.uuid4())) created = peewee.DateTimeField(default=datetime.datetime.now) server_uuid = peewee.CharField(default="", index=True) + server_name = peewee.CharField(default="Server", index=True) path = peewee.CharField(default="") backup_path = peewee.CharField(default="") executable = peewee.CharField(default="") @@ -171,13 +202,12 @@ def rollback(migrator: Migrator, database, **kwargs): type = peewee.CharField(default="minecraft-java") show_status = peewee.BooleanField(default=1) created_by = peewee.IntegerField(default=-100) - # created_by = ForeignKeyField(Users, backref="creator_server", null=True) shutdown_timeout = peewee.IntegerField(default=60) ignored_exits = peewee.CharField(default="0") - count_players = peewee.BooleanField(default=True) class Meta: table_name = "servers" + database = db try: logger.info("Migrating Data from UUID to Int (Primary Keys)") @@ -215,8 +245,8 @@ def rollback(migrator: Migrator, database, **kwargs): new_server_id = 0 else: try: - server = OldServers.get_or_none( - OldServers.server_uuid == old_server_id + server = Servers.get_or_none( + Servers.server_uuid == old_server_id ) new_server_id = server.server_id except: @@ -229,7 +259,7 @@ def rollback(migrator: Migrator, database, **kwargs): for webhook in Webhooks.select(): old_server_id = webhook.server_id_id try: - server = OldServers.get_or_none(OldServers.server_uuid == old_server_id) + server = Servers.get_or_none(Servers.server_uuid == old_server_id) new_server_id = server.server_id except: new_server_id = old_server_id @@ -241,7 +271,7 @@ def rollback(migrator: Migrator, database, **kwargs): for schedule in Schedules.select(): old_server_id = schedule.server_id_id try: - server = OldServers.get_or_none(OldServers.server_uuid == old_server_id) + server = Servers.get_or_none(Servers.server_uuid == old_server_id) new_server_id = server.server_id except: new_server_id = old_server_id @@ -253,7 +283,7 @@ def rollback(migrator: Migrator, database, **kwargs): for backup in Backups.select(): old_server_id = backup.server_id_id try: - server = OldServers.get_or_none(OldServers.server_uuid == old_server_id) + server = Servers.get_or_none(Servers.server_uuid == old_server_id) new_server_id = server.server_id except: new_server_id = old_server_id @@ -265,7 +295,7 @@ def rollback(migrator: Migrator, database, **kwargs): for role_servers in RoleServers.select(): old_server_id = role_servers.server_id_id try: - server = OldServers.get_or_none(OldServers.server_uuid == old_server_id) + server = Servers.get_or_none(Servers.server_uuid == old_server_id) new_server_id = server.server_id except: new_server_id = old_server_id From 2bb8e185de2dd77fadd4d6685a3352f27fffe82d Mon Sep 17 00:00:00 2001 From: Silversthorn Date: Sat, 23 Mar 2024 14:13:45 +0100 Subject: [PATCH 13/48] Checking if the column is already deleted --- app/migrations/20240310_fixing_rework_servers_uuid.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/migrations/20240310_fixing_rework_servers_uuid.py b/app/migrations/20240310_fixing_rework_servers_uuid.py index cae0dec4..e524ab75 100644 --- a/app/migrations/20240310_fixing_rework_servers_uuid.py +++ b/app/migrations/20240310_fixing_rework_servers_uuid.py @@ -56,7 +56,11 @@ def migrate(migrator: Migrator, database, **kwargs): ) # Drop Column after migration - migrator.drop_columns("servers", ["server_uuid"]) + + servers_columns = db.get_columns('servers') + if not any(column_data.name == "server_uuid" for column_data in servers_columns): + Console.debug("Servers.server_uuid already deleted in Crafty version 4.3.0, skipping this part") + migrator.drop_columns("servers", ["server_uuid"]) except Exception as ex: logger.error("Error while migrating Data from Int to UUID (Fixing Issue)") From 9aad5e3d8fb718323f688fbdf93ae1e04bd4d0d7 Mon Sep 17 00:00:00 2001 From: Silversthorn Date: Sat, 23 Mar 2024 14:20:31 +0100 Subject: [PATCH 14/48] trying something to works form differents update version --- app/migrations/20240217_rework_servers_uuid_part2.py | 5 +++++ app/migrations/20240310_fixing_rework_servers_uuid.py | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/migrations/20240217_rework_servers_uuid_part2.py b/app/migrations/20240217_rework_servers_uuid_part2.py index 2303960c..c55334e7 100644 --- a/app/migrations/20240217_rework_servers_uuid_part2.py +++ b/app/migrations/20240217_rework_servers_uuid_part2.py @@ -60,6 +60,11 @@ def migrate(migrator: Migrator, database, **kwargs): if this_migration is not None: Console.debug("Update database already done, skipping this part") return + else: + servers_columns = db.get_columns('servers') + if not any(column_data.name == "server_uuid" for column_data in servers_columns): + Console.debug("Servers.server_uuid already deleted in Crafty version 4.3.0, skipping this part") + return try: logger.info("Migrating Data from Int to UUID (Foreign Keys)") diff --git a/app/migrations/20240310_fixing_rework_servers_uuid.py b/app/migrations/20240310_fixing_rework_servers_uuid.py index e524ab75..2dd5111e 100644 --- a/app/migrations/20240310_fixing_rework_servers_uuid.py +++ b/app/migrations/20240310_fixing_rework_servers_uuid.py @@ -56,10 +56,9 @@ def migrate(migrator: Migrator, database, **kwargs): ) # Drop Column after migration - servers_columns = db.get_columns('servers') - if not any(column_data.name == "server_uuid" for column_data in servers_columns): - Console.debug("Servers.server_uuid already deleted in Crafty version 4.3.0, skipping this part") + if any(column_data.name == "server_uuid" for column_data in servers_columns): + Console.debug("Servers.server_uuid not deleted before Crafty version 4.3.2, skipping this part") migrator.drop_columns("servers", ["server_uuid"]) except Exception as ex: From 7a7f2371879b91de905beb007fde88ccc9c8cd42 Mon Sep 17 00:00:00 2001 From: Silversthorn Date: Sat, 23 Mar 2024 14:30:48 +0100 Subject: [PATCH 15/48] appease lint --- .../20240217_rework_servers_uuid_part2.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/migrations/20240217_rework_servers_uuid_part2.py b/app/migrations/20240217_rework_servers_uuid_part2.py index c55334e7..eab04c28 100644 --- a/app/migrations/20240217_rework_servers_uuid_part2.py +++ b/app/migrations/20240217_rework_servers_uuid_part2.py @@ -61,9 +61,13 @@ def migrate(migrator: Migrator, database, **kwargs): Console.debug("Update database already done, skipping this part") return else: - servers_columns = db.get_columns('servers') - if not any(column_data.name == "server_uuid" for column_data in servers_columns): - Console.debug("Servers.server_uuid already deleted in Crafty version 4.3.0, skipping this part") + servers_columns = db.get_columns("servers") + if not any( + column_data.name == "server_uuid" for column_data in servers_columns + ): + Console.debug( + "Servers.server_uuid already deleted in Crafty version 4.3.0, skipping this part" + ) return try: @@ -250,9 +254,7 @@ def rollback(migrator: Migrator, database, **kwargs): new_server_id = 0 else: try: - server = Servers.get_or_none( - Servers.server_uuid == old_server_id - ) + server = Servers.get_or_none(Servers.server_uuid == old_server_id) new_server_id = server.server_id except: new_server_id = old_server_id From a87daa6ef3be1e6c956f0b1266ca67f72f2597dc Mon Sep 17 00:00:00 2001 From: Silversthorn Date: Sat, 23 Mar 2024 14:32:39 +0100 Subject: [PATCH 16/48] Format with Black for lint apeasing --- app/migrations/20240310_fixing_rework_servers_uuid.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/migrations/20240310_fixing_rework_servers_uuid.py b/app/migrations/20240310_fixing_rework_servers_uuid.py index 2dd5111e..cbde833b 100644 --- a/app/migrations/20240310_fixing_rework_servers_uuid.py +++ b/app/migrations/20240310_fixing_rework_servers_uuid.py @@ -56,9 +56,11 @@ def migrate(migrator: Migrator, database, **kwargs): ) # Drop Column after migration - servers_columns = db.get_columns('servers') + servers_columns = db.get_columns("servers") if any(column_data.name == "server_uuid" for column_data in servers_columns): - Console.debug("Servers.server_uuid not deleted before Crafty version 4.3.2, skipping this part") + Console.debug( + "Servers.server_uuid not deleted before Crafty version 4.3.2, skipping this part" + ) migrator.drop_columns("servers", ["server_uuid"]) except Exception as ex: From 3edfd4320dda7b473920ed7e7c64f4f598aa0dce Mon Sep 17 00:00:00 2001 From: Silversthorn Date: Sun, 24 Mar 2024 20:39:10 +0100 Subject: [PATCH 17/48] Replacing server_id=0 to server_id=None for AuditLog --- app/classes/web/panel_handler.py | 2 +- app/classes/web/public_handler.py | 4 ++-- app/classes/web/routes/api/auth/login.py | 4 ++-- app/classes/web/routes/api/crafty/config/index.py | 4 ++-- app/classes/web/routes/api/crafty/config/server_dir.py | 2 +- app/classes/web/routes/api/roles/index.py | 2 +- app/classes/web/routes/api/roles/role/index.py | 4 ++-- app/classes/web/routes/api/users/index.py | 2 +- app/classes/web/routes/api/users/user/api.py | 6 +++--- app/classes/web/routes/api/users/user/index.py | 4 ++-- app/classes/web/websocket_handler.py | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index d61e3c0e..716671c8 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -1403,7 +1403,7 @@ class PanelHandler(BaseHandler): self.controller.management.add_to_audit_log( exec_user["user_id"], f"Removed user {target_user['username']} (UID:{user_id})", - server_id=0, + server_id=None, source_ip=self.get_remote_ip(), ) self.redirect("/panel/panel_config") diff --git a/app/classes/web/public_handler.py b/app/classes/web/public_handler.py index 467765ea..21e2d495 100644 --- a/app/classes/web/public_handler.py +++ b/app/classes/web/public_handler.py @@ -228,7 +228,7 @@ class PublicHandler(BaseHandler): ) # log this login self.controller.management.add_to_audit_log( - user_data.user_id, "Logged in", 0, self.get_remote_ip() + user_data.user_id, "Logged in", None, self.get_remote_ip() ) return self.finish_json( @@ -254,7 +254,7 @@ class PublicHandler(BaseHandler): ) # log this failed login attempt self.controller.management.add_to_audit_log( - user_data.user_id, "Tried to log in", 0, self.get_remote_ip() + user_data.user_id, "Tried to log in", None, self.get_remote_ip() ) return self.finish_json( 403, diff --git a/app/classes/web/routes/api/auth/login.py b/app/classes/web/routes/api/auth/login.py index 7a27c6f8..7e8131f3 100644 --- a/app/classes/web/routes/api/auth/login.py +++ b/app/classes/web/routes/api/auth/login.py @@ -101,7 +101,7 @@ class ApiAuthLoginHandler(BaseApiHandler): # log this login self.controller.management.add_to_audit_log( - user_data.user_id, "logged in via the API", 0, self.get_remote_ip() + user_data.user_id, "logged in via the API", None, self.get_remote_ip() ) self.finish_json( @@ -119,7 +119,7 @@ class ApiAuthLoginHandler(BaseApiHandler): else: # log this failed login attempt self.controller.management.add_to_audit_log( - user_data.user_id, "Tried to log in", 0, self.get_remote_ip() + user_data.user_id, "Tried to log in", None, self.get_remote_ip() ) self.finish_json( 401, diff --git a/app/classes/web/routes/api/crafty/config/index.py b/app/classes/web/routes/api/crafty/config/index.py index c901732c..e7e0b42f 100644 --- a/app/classes/web/routes/api/crafty/config/index.py +++ b/app/classes/web/routes/api/crafty/config/index.py @@ -129,7 +129,7 @@ class ApiCraftyConfigIndexHandler(BaseApiHandler): self.controller.management.add_to_audit_log( user["user_id"], "edited config.json", - server_id=0, + server_id=None, source_ip=self.get_remote_ip(), ) @@ -226,7 +226,7 @@ class ApiCraftyCustomizeIndexHandler(BaseApiHandler): self.controller.management.add_to_audit_log( user["user_id"], f"customized login photo: {data['photo']}/{data['opacity']}", - server_id=0, + server_id=None, source_ip=self.get_remote_ip(), ) self.controller.management.set_login_opacity(int(data["opacity"])) diff --git a/app/classes/web/routes/api/crafty/config/server_dir.py b/app/classes/web/routes/api/crafty/config/server_dir.py index 91c4cc89..87835d35 100644 --- a/app/classes/web/routes/api/crafty/config/server_dir.py +++ b/app/classes/web/routes/api/crafty/config/server_dir.py @@ -109,7 +109,7 @@ class ApiCraftyConfigServerDirHandler(BaseApiHandler): self.controller.management.add_to_audit_log( auth_data[4]["user_id"], f"updated master servers dir to {new_dir}/servers", - server_id=0, + server_id=None, source_ip=self.get_remote_ip(), ) diff --git a/app/classes/web/routes/api/roles/index.py b/app/classes/web/routes/api/roles/index.py index 266afb23..0f656dbb 100644 --- a/app/classes/web/routes/api/roles/index.py +++ b/app/classes/web/routes/api/roles/index.py @@ -161,7 +161,7 @@ class ApiRolesIndexHandler(BaseApiHandler): self.controller.management.add_to_audit_log( user["user_id"], f"created role {role_name} (RID:{role_id})", - server_id=0, + server_id=None, source_ip=self.get_remote_ip(), ) diff --git a/app/classes/web/routes/api/roles/role/index.py b/app/classes/web/routes/api/roles/role/index.py index 5ed12d69..a45c297f 100644 --- a/app/classes/web/routes/api/roles/role/index.py +++ b/app/classes/web/routes/api/roles/role/index.py @@ -112,7 +112,7 @@ class ApiRolesRoleIndexHandler(BaseApiHandler): self.controller.management.add_to_audit_log( user["user_id"], f"deleted role with ID {role_id}", - server_id=0, + server_id=None, source_ip=self.get_remote_ip(), ) @@ -172,7 +172,7 @@ class ApiRolesRoleIndexHandler(BaseApiHandler): self.controller.management.add_to_audit_log( user["user_id"], f"modified role with ID {role_id}", - server_id=0, + server_id=None, source_ip=self.get_remote_ip(), ) diff --git a/app/classes/web/routes/api/users/index.py b/app/classes/web/routes/api/users/index.py index f7341d38..fef154a0 100644 --- a/app/classes/web/routes/api/users/index.py +++ b/app/classes/web/routes/api/users/index.py @@ -177,7 +177,7 @@ class ApiUsersIndexHandler(BaseApiHandler): self.controller.management.add_to_audit_log( user["user_id"], f"added user {username} (UID:{user_id}) with roles {roles}", - server_id=0, + server_id=None, source_ip=self.get_remote_ip(), ) diff --git a/app/classes/web/routes/api/users/user/api.py b/app/classes/web/routes/api/users/user/api.py index 1c7635f2..9bdafadf 100644 --- a/app/classes/web/routes/api/users/user/api.py +++ b/app/classes/web/routes/api/users/user/api.py @@ -43,7 +43,7 @@ class ApiUsersUserKeyHandler(BaseApiHandler): auth_data[4]["user_id"], f"Generated a new API token for the key {key.name} " f"from user with UID: {key.user_id}", - server_id=0, + server_id=None, source_ip=self.get_remote_ip(), ) data_key = self.controller.authentication.generate( @@ -173,7 +173,7 @@ class ApiUsersUserKeyHandler(BaseApiHandler): f"Added API key {data['name']} with crafty permissions " f"{data['crafty_permissions_mask']}" f" and {data['server_permissions_mask']} for user with UID: {user_id}", - server_id=0, + server_id=None, source_ip=self.get_remote_ip(), ) self.finish_json(200, {"status": "ok", "data": {"id": key_id}}) @@ -233,7 +233,7 @@ class ApiUsersUserKeyHandler(BaseApiHandler): auth_data[4]["user_id"], f"Removed API key {target_key} " f"(ID: {key_id}) from user {auth_data[4]['user_id']}", - server_id=0, + server_id=None, source_ip=self.get_remote_ip(), ) diff --git a/app/classes/web/routes/api/users/user/index.py b/app/classes/web/routes/api/users/user/index.py index 1b7f6f91..6efee93e 100644 --- a/app/classes/web/routes/api/users/user/index.py +++ b/app/classes/web/routes/api/users/user/index.py @@ -94,7 +94,7 @@ class ApiUsersUserIndexHandler(BaseApiHandler): self.controller.management.add_to_audit_log( user["user_id"], f"deleted the user {user_id}", - server_id=0, + server_id=None, source_ip=self.get_remote_ip(), ) @@ -283,7 +283,7 @@ class ApiUsersUserIndexHandler(BaseApiHandler): f"edited user {user_obj.username} (UID: {user_id})" f"with roles {user_obj.roles}" ), - server_id=0, + server_id=None, source_ip=self.get_remote_ip(), ) diff --git a/app/classes/web/websocket_handler.py b/app/classes/web/websocket_handler.py index cde97584..3e426797 100644 --- a/app/classes/web/websocket_handler.py +++ b/app/classes/web/websocket_handler.py @@ -55,7 +55,7 @@ class WebSocketHandler(tornado.websocket.WebSocketHandler): self.controller.management.add_to_audit_log_raw( "unknown", 0, - 0, + None, "Someone tried to connect via WebSocket without proper authentication", self.get_remote_ip(), ) From 25b64e353c15d40525a7d00da2d601b433a04454 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Sun, 24 Mar 2024 17:55:58 -0400 Subject: [PATCH 18/48] Fix backup restores after uuid server IDs --- app/classes/controllers/server_perms_controller.py | 2 +- app/classes/shared/main_controller.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/classes/controllers/server_perms_controller.py b/app/classes/controllers/server_perms_controller.py index f6632cd7..37893e9e 100644 --- a/app/classes/controllers/server_perms_controller.py +++ b/app/classes/controllers/server_perms_controller.py @@ -47,7 +47,7 @@ class ServerPermsController: new_server_id, role.role_id, PermissionsServers.get_permissions_mask( - int(role.role_id), int(old_server_id) + int(role.role_id), old_server_id ), ) # Permissions_Servers.add_role_server( diff --git a/app/classes/shared/main_controller.py b/app/classes/shared/main_controller.py index b6e824a5..938ff748 100644 --- a/app/classes/shared/main_controller.py +++ b/app/classes/shared/main_controller.py @@ -1131,7 +1131,7 @@ class Controller: server_obj.path = new_local_server_path failed = False for s in self.servers.failed_servers: - if int(s["server_id"]) == int(server.get("server_id")): + if s["server_id"] == server.get("server_id"): failed = True if not failed: self.servers.update_server(server_obj) From 3639ab92601ffd6474ac048dbe684d8a360f65fa Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Sun, 24 Mar 2024 17:56:10 -0400 Subject: [PATCH 19/48] Catch more specific exception --- .../web/routes/api/servers/server/backups/backup/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/classes/web/routes/api/servers/server/backups/backup/index.py b/app/classes/web/routes/api/servers/server/backups/backup/index.py index 05edd3a9..70ceb2b2 100644 --- a/app/classes/web/routes/api/servers/server/backups/backup/index.py +++ b/app/classes/web/routes/api/servers/server/backups/backup/index.py @@ -203,7 +203,7 @@ class ApiServersServerBackupsBackupIndexHandler(BaseApiHandler): except JobLookupError as e: logger.info("No active tasks found for server: {e}") self.controller.remove_server(server_id, True) - except Exception as e: + except (FileNotFoundError, NotADirectoryError) as e: return self.finish_json( 400, {"status": "error", "error": f"NO BACKUP FOUND {e}"} ) From 4a134278aeb725bcdb98fe60f2109b96a4602789 Mon Sep 17 00:00:00 2001 From: Dylan Oonk Date: Sun, 24 Mar 2024 22:49:47 +0000 Subject: [PATCH 20/48] remove version disclosure from login --- app/frontend/templates/public/login.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/frontend/templates/public/login.html b/app/frontend/templates/public/login.html index 5a54ecca..275d2000 100644 --- a/app/frontend/templates/public/login.html +++ b/app/frontend/templates/public/login.html @@ -111,8 +111,7 @@
From 95490d50677318743a9305d92a278281827b8c6d Mon Sep 17 00:00:00 2001 From: Analicia Abernathy Date: Sun, 31 Mar 2024 13:25:17 -0500 Subject: [PATCH 21/48] Updating Italian translation --- .../{it_IT_incomplete.json => it_IT.json} | 140 +++++++++++++++++- 1 file changed, 138 insertions(+), 2 deletions(-) rename app/translations/{it_IT_incomplete.json => it_IT.json} (78%) diff --git a/app/translations/it_IT_incomplete.json b/app/translations/it_IT.json similarity index 78% rename from app/translations/it_IT_incomplete.json rename to app/translations/it_IT.json index 99b29d7e..adb59c7d 100644 --- a/app/translations/it_IT_incomplete.json +++ b/app/translations/it_IT.json @@ -53,6 +53,20 @@ "translationTitle": "Traduttore in lingua", "translator": "Traduttori" }, + "customLogin": { + "apply": "Applica", + "backgroundUpload": "Carica sfondo", + "customLoginPage": "Personalizza la pagina di accesso", + "delete": "Cancella", + "labelLoginImage": "Scegli lo sfondo della finestra di accesso", + "loginBackground": "Immagini di sfondo della finestra di accesso", + "loginImage": "Carica un'immagine di sfondo per la schermata di accesso.", + "loginOpacity": "Seleziona l'opacità della finestra di accesso", + "pageTitle": "Pagina di accesso personalizzata", + "preview": "Anteprima", + "select": "Seleziona", + "selectImage": "Seleziona un'immagine" + }, "dashboard": { "actions": "Azioni", "allServers": "Tutti i Server", @@ -75,6 +89,7 @@ "dashboard": "Pannello di Controllo", "delay-explained": "Il servizio/agente è stato avviato di recente e sta ritardando l'avvio del server di Minecraft", "host": "Host", + "installing": "Installazione...", "kill": "Termina il Processo", "killing": "Terminando il processo...", "lastBackup": "Ultimo:", @@ -96,6 +111,7 @@ "starting": "Avvio ritardato", "status": "Stato", "stop": "Stop", + "storage": "Archiviazione", "version": "Versione", "welcome": "Benvenuto su Crafty Controller" }, @@ -164,20 +180,33 @@ } }, "error": { + "agree": "Conferma", + "bedrockError": "I download di Bedrock non sono disponibili. Si prega di controllare", + "cancel": "Annulla", "contact": "Contact Crafty Control Support via Discord", + "craftyStatus": "Stato di Crafty", + "cronFormat": "Rilevato formato Cron non valido", "embarassing": "Oh my, well, this is embarrassing.", "error": "Error!", "eulaAgree": "Do you agree?", "eulaMsg": "You must agree to the EULA. A copy of the Minecraft EULA is linked under this message.", "eulaTitle": "Agree To EULA", + "fileError": "Il tipo di file deve essere un'immagine.", "fileTooLarge": "Caricamento fallito. File da caricare troppo grande. Contatta un amministratore di sistema per assistenza.", "hereIsTheError": "Here is the error", + "installerJava": "Installazione fallita {} : L'installazione di server Forge richiede Java. Abbiamo rilevato che Java non è installato. Installa Java e riprova.", "internet": "We have detected the machine running Crafty has no connection to the internet. Client connections to the server may be limited.", + "migration": "Lo spazio di archiviazione del server principale di Crafty verrà migrato in una nuova posizione. Durante questo periodo tutti gli avvii dei server sono stati sospesi. Aspetta mentre completiamo la migrazione", "no-file": "We can't seem to locate the requested file. Double check the path. Does Crafty have proper permissions?", + "noInternet": "Crafty ha problemi ad accedere a internet. La creazione di server è stata disabilitata. Controlla la tua connessione a internet e aggiorna la pagina.", "noJava": "Server {} failed to start with error code: We have detected Java is not installed. Please install java then start the server.", "not-downloaded": "We can't seem to find your executable file. Has it finished downloading? Are the permissions set to executable?", "portReminder": "We have detected this is the first time {} has been run. Make sure to forward port {} through your router/firewall to make this remotely accessible from the internet.", + "privMsg": "e il ", + "serverJars1": "API JAR del server non raggiungibile. Si prega di controllare", + "serverJars2": "per informazioni più aggiornate.", "start-error": "Server {} failed to start with error code: {}", + "superError": "Devi essere un super utente per eseguire questa azione.", "terribleFailure": "What a Terrible Failure!" }, "footer": { @@ -186,10 +215,14 @@ "version": "Versione" }, "login": { + "defaultPath": "La password immessa è il percorso delle credenziali predefinite, non la password. Trova la password predefinita in quella posizione.", + "disabled": "Account utente disabilitato. Per ulteriori informazioni, contatta l'amministratore di sistema.", "forgotPassword": "Password dimenticata", + "incorrect": "nome utente o password errati", "login": "Accedi", "password": "Password", - "username": "Nome utente" + "username": "Nome utente", + "viewStatus": "Visualizza la pagina di stato pubblica" }, "notify": { "activityLog": "Registri di Attività", @@ -201,24 +234,38 @@ "preparingLogs": "Per favore aspetta mentre prepariamo i tuoi registri... Ti invieremo una notifica quando saranno pronti. Potrebbe volerci un po' per installazioni grosse.", "supportLogs": "Registri di supporto" }, + "offline": { + "offline": "Disconnesso", + "pleaseConnect": "Connettiti a internet per usare Crafty." + }, "panelConfig": { "adminControls": "Controllo admin", "allowedServers": "Server permessi", + "apply": "Applica", "assignedRoles": "Ruoli assegnati", "cancel": "Cancella", "clearComms": "Pulisci i comandi non eseguiti", + "custom": "Personalizza Crafty", "delete": "Elimina", "edit": "Modifica", + "enableLang": "Abilita tutte le lingue", "enabled": "Abilitato", + "globalExplain": "Dove Crafty memorizza tutti i file del tuo server. (Aggiungeremo il percorso con /servers/[uuid of server])", + "globalServer": "Directory dei server globali", + "json": "Config.json", + "match": "Le password devono corrispondere", "newRole": "Aggiungi nuovo ruolo", "newUser": "Aggiungi nuovo utente", + "noMounts": "Non mostrare supporti su Dash", "pageTitle": "Configurazioni del pannello", "role": "Ruolo", "roleUsers": "Utenti del ruolo", "roles": "Ruoli", "save": "Salva", + "select": "Seleziona", "superConfirm": "Procedi solo se vuoi che questo utente abbia accesso a TUTTO (tutti gli utenti, server, impostazioni del pannello, ecc...). Può anche revocare i tuoi poteri da superuser.", "superConfirmTitle": "Abilitare lo superuser? Sei sicuro?", + "title": "Configurazione di Crafty", "user": "Utente", "users": "Utenti" }, @@ -242,14 +289,17 @@ "roleTitle": "Impostazioni del ruolo", "roleUserName": "Nome Utente", "roleUsers": "Utenti con il ruolo: ", + "selectManager": "Seleziona un gestore per questo ruolo", "serverAccess": "Abilitato?", "serverName": "Nome del Server", "serversDesc": "Server a cui questo ruolo è consentito l'accesso" }, "serverBackups": { + "after": "Esegui il comando prima del backup", "backupAtMidnight": "Auto-backup a mezzanotte?", "backupNow": "Effettua il Backup Ora!", "backupTask": "Un'azione di backup è cominciata.", + "before": "Esegui il comando dopo il backup", "cancel": "Cancella", "clickExclude": "Clicca per selezionare le esclusioni", "compress": "Comprimi backup", @@ -280,6 +330,7 @@ "bePatientDeleteFiles": "Per favore sii paziente mentre rimuoviamo il tuo server dal pannello di Crafty e cancelliamo tutti i files. Questa schermata si chiuderà in pochi istanti.", "bePatientUpdate": "Per favore sii paziente mentre aggiorniamo il server. I tempi di download possono variare dalla tua velocità di internet.
Questa schermata si aggiornerà a breve", "cancel": "Cancella", + "countPlayers": "Includi il server nel conteggio totale dei giocatori", "crashTime": "Crash Timeout", "crashTimeDesc": "Quanto dobbiamo aspettare per considerare il tuo server crashato per colpa di un timeout?", "deleteFilesQuestion": "Eliminare i file del server dalla macchina?", @@ -289,6 +340,8 @@ "deleteServerQuestionMessage": "Sei sicuro di voler eliminare questo server? Dopo la conferma non puoi tornare indietro...", "exeUpdateURL": "URL di aggiornamento dell'eseguibile del server", "exeUpdateURLDesc": "URL di download diretto per gli aggiornamenti del server.", + "ignoredExits": "Codici di arresto anomalo ignorati", + "ignoredExitsExplain": "I codici di arresto anomalo per il rilevamento degli incidenti di Crafty dovrebbero essere ignorati come un normale 'stop' (separato da virgole)", "javaNoChange": "Non cambiare la versione di Java", "javaVersion": "Cambia la versione di Java attualmente in uso", "javaVersionDesc": "Se vuoi cambiare versione di Java, assicurati che la path dell'eseguibile di Java sia immessa tra 'apostrofi' ('java' di default è esclusa)", @@ -319,7 +372,13 @@ "serverPortDesc": "La Porta a cui Crafty si dovrà collegare per le statistiche", "serverStopCommand": "Comando d'arresto del server", "serverStopCommandDesc": "Comando inviato al server per l'arresto", + "showStatus": "Mostra nella pagina di stato pubblica", + "shutdownTimeout": "Tempo di attesa dello spegnimento", + "statsHint1": "la porta che sta usando il server dovrebbe essere qui. Questo è il modo in cui Crafty apre una connessione al tuo server per le statistiche.", + "statsHint2": "Ciò non modifica la porta del tuo server. È comunque necessario modificare la porta nel file di configurazione del server.", "stopBeforeDeleting": "Per favore arresta il server prima di eliminarlo", + "timeoutExplain1": "Per quanto tempo Crafty attenderà lo spegnimento del tuo server dopo averlo eseguito", + "timeoutExplain2": "comando prima di forzare l'arresto del processo.", "update": "Aggiorna l'eseguibile", "yesDelete": "Sì, elimina", "yesDeleteFiles": "Sì, elimina i files" @@ -345,8 +404,12 @@ "backup": "Backup", "config": "Configura", "files": "Files", + "filter": "Filtra registri", + "filterList": "Parole filtrate", "logs": "Registri", + "metrics": "Metrica", "playerControls": "Gestisci i giocatori", + "reset": "Ripristina scorrimento", "schedule": "Programma", "serverDetails": "Dettagli del Server", "terminal": "Terminale" @@ -383,6 +446,11 @@ "waitUpload": "Per favore aspetta mentre carichiamo i tuoi files... Potrebbe volerci un momento.", "yesDelete": "Sì, conosco le conseguenze" }, + "serverMetrics": { + "resetZoom": "Ripristina ingrandimento", + "zoomHint1": "Per ingrandire il grafico, tieni premuto il tasto Maiusc, quindi usa la rotella di scorrimento.", + "zoomHint2": "In alternativa, tieni premuto il tasto Maiusc, quindi fai clic e trascina l'area su cui desideri ingrandire." + }, "serverPlayerManagement": { "bannedPlayers": "Giocatori Banditi", "loadingBannedPlayers": "Carico i giocatori banditi", @@ -410,23 +478,44 @@ "parent-explain": "Quale azione dovrebbe far eseguire questa?", "reaction": "Reazione", "restart": "Riavvia il Server", + "select": "Seleziona Base / Cron / Reazione a catena", "start": "Avvia il server", "stop": "Arresta il Server", "time": "Orario", "time-explain": "A che ora vuoi eseguire la tua azione programmata?" }, "serverSchedules": { + "action": "Azione", "areYouSure": "Eliminare l'azione programmata?", "cancel": "Cancella", "cannotSee": "Non vedi tutto?", "cannotSeeOnMobile": "Prova a cliccare su un'azione programmata per tutti i dettagli.", + "child": "Schedario secondario con ID ", + "close": "Chiudi", + "command": "Comando", "confirm": "Conferma", - "confirmDelete": "Vuoi eliminare l'azione programmata? Non puoi tornare indietro." + "confirmDelete": "Vuoi eliminare l'azione programmata? Non puoi tornare indietro.", + "create": "Crea nuovo schedario", + "cron": "Stringa Cron", + "delete": "Cancella", + "details": "Dettagli dello schedario", + "edit": "Modifica", + "enabled": "Abilitato", + "every": "Tutto", + "interval": "Intervallo", + "name": "Nome", + "newSchedule": "Nuovo schedario", + "nextRun": "Prossima operazione", + "no": "No", + "no-schedule": "Non sono attualmente presenti schedari per questo server. Per iniziare, clicca", + "scheduledTasks": "Attività schedate", + "yes": "Sì" }, "serverStats": { "cpuUsage": "Utilizzo del Processore", "description": "Descrizione", "errorCalculatingUptime": "Errore nel calcolo dei tempi di operazione", + "loadingMotd": "Caricamento MOTD", "memUsage": "Utilizzo della memoria", "offline": "Offline", "online": "Online", @@ -444,6 +533,8 @@ "commandInput": "Inserisci il comando", "delay-explained": "Il servizio/agente è stato avviato di recente e sta ritardando l'avvio del server di Minecraft", "downloading": "Scaricando...", + "importing": "Importazione...", + "installing": "Installazione...", "restart": "Riavvia", "sendCommand": "Invia il comando", "start": "Avvia", @@ -468,6 +559,7 @@ "importServerButton": "Importa Server!", "importZip": "Importa da un File Zip", "importing": "Importando il Server...", + "labelZipFile": "Scegli il tuo file zip", "maxMem": "Memoria Massima", "minMem": "Memoria minima", "myNewServer": "Il mio nuovo Server", @@ -478,6 +570,7 @@ "save": "Salva", "selectRole": "Seleziona i Ruoli", "selectRoot": "Seleziona la directory radice dell'archivio", + "selectServer": "Seleziona un server", "selectType": "Seleziona un Tipo", "selectVersion": "Seleziona una versione", "selectZipDir": "Seleziona il percorso in memoria in cui scompatteremo i file", @@ -485,9 +578,14 @@ "serverName": "Nome Server", "serverPath": "Percorso del Server", "serverPort": "Porta del Server", + "serverSelect": "Server selezionato", "serverType": "Tipo di Server", + "serverUpload": "Carica server zippato", "serverVersion": "Versione del Server", "sizeInGB": "Dimensione in GB", + "unsupported": "Le versioni di Minecraft inferiori alla 1.8 non sono supportate da Crafty. Puoi comunque installarlo. I risultati varieranno.", + "uploadButton": "Carica", + "uploadZip": "Carica file zip per l'importazione del server", "zipPath": "Percorso del Server" }, "sidebar": { @@ -495,10 +593,20 @@ "credits": "Crediti", "dashboard": "Pannello di controllo", "documentation": "Documentazione", + "inApp": "Documenti in app", "navigation": "Navigazione", "newServer": "Crea un Nuovo Server", "servers": "Servers" }, + "startup": { + "almost": "Finalizzazione. Tieniti forte...", + "internals": "Configurazione e avvio dei componenti interni di Crafty", + "internet": "Controllo connessione a internet", + "server": "Inizializzazione ", + "serverInit": "Inizializzazione server", + "starting": "Avvio di Crafty...", + "tasks": "Avvio attività schedate" + }, "userConfig": { "apiKey": "Chiavi API", "auth": "Autorizzato? ", @@ -519,6 +627,7 @@ "lastLogin": "Ultimo accesso: ", "lastUpdate": "Ultimo aggiornamento: ", "leaveBlank": "Per modificare l'utente senza cambiare la passowrd, lascia il campo in bianco.", + "manager": "Gestore", "member": "È membro?", "notExist": "Non puoi eliminare qualcosa che non esiste!", "pageTitle": "Modifica Utente", @@ -527,6 +636,7 @@ "permName": "Nome del Permesso", "repeat": "Ripeti la Password", "roleName": "Nome del ruolo", + "selectManager": "Seleziona un gestore per l'utente", "super": "Super User", "userLang": "Linguaggio dell'utente", "userName": "Nome utente", @@ -534,6 +644,32 @@ "userRoles": "Ruoli dell'utente", "userRolesDesc": "Ruoli di cui l'utente fa parte.", "userSettings": "Impostazioni Utente", + "userTheme": "Tema IU", "uses": "Numero di usi permessi (-1==Nessun limite)" + }, + "webhooks": { + "areYouSureDel": "Sei sicuro di voler eliminare questo webhook?", + "areYouSureRun": "Sei sicuro di voler testare questo webhook?", + "backup_server": "Backup del server completato", + "bot_name": "Nome del bot", + "color": "Seleziona l'accentuazione del colore", + "crash_detected": "Il server si è arrestato in modo anomalo", + "edit": "Modifica", + "enabled": "Abilitato", + "jar_update": "Eseguibile del server aggiornato", + "kill": "Server arrestato", + "name": "Nome", + "new": "Nuovo webhook", + "newWebhook": "Nuovo webhook", + "no-webhook": "Attualmente non ci sono webhook in questo server. Per iniziare, clicca", + "run": "Testa il webhook", + "send_command": "Comando del server ricevuto", + "start_server": "Server avviato", + "stop_server": "Server spento", + "trigger": "Attivazione a", + "type": "Tipo di Webhook", + "url": "URL del Webhook", + "webhook_body": "Corpo del Webhook", + "webhooks": "Webhook" } } From 50d4b045e702c1ef0e2c4ac91731affebd22e23d Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Mon, 1 Apr 2024 16:16:33 -0400 Subject: [PATCH 22/48] Update permissions script to include progress --- .gitlab/scripts/linux_perms_fix.sh | 39 +++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/.gitlab/scripts/linux_perms_fix.sh b/.gitlab/scripts/linux_perms_fix.sh index 24b92176..41993fc3 100644 --- a/.gitlab/scripts/linux_perms_fix.sh +++ b/.gitlab/scripts/linux_perms_fix.sh @@ -3,13 +3,44 @@ # Prompt the user for the directory path read -p "Enter the directory path to set permissions (/var/opt/minecraft/crafty): " directory_path +# Count the total number of directories +total_dirs=$(find "$directory_path" -type d | wc -l) + +# Count the total number of files +total_files=$(find "$directory_path" -type f | wc -l) + +# Initialize a counter for directories and files +dir_count=0 +file_count=0 + +# Function to print progress +print_progress() { + echo -ne "\rDirectories: $dir_count/$total_dirs Files: $file_count/$total_files" +} + # Check if the script is running within a Docker container if [ -f "/.dockerenv" ]; then echo "Script is running within a Docker container. Exiting with error." exit 1 # Exit with an error code if running in Docker else echo "Script is not running within a Docker container. Executing permissions changes..." - # Run the commands to set permissions - sudo chmod 700 $(find "$directory_path" -type d) - sudo chmod 644 $(find "$directory_path" -type f) -fi \ No newline at end of file + + # Run the commands to set permissions for directories + echo "Changing permissions for directories:" + for dir in $(find "$directory_path" -type d); do + sudo chmod 700 "$dir" + ((dir_count++)) + print_progress + done + + # Run the commands to set permissions for files + echo -e "\nChanging permissions for files:" + for file in $(find "$directory_path" -type f); do + sudo chmod 644 "$file" + ((file_count++)) + print_progress + done + echo "You will now need to execute a chmod +x on all bedrock executables" +fi + +echo "" # Adding a new line after the loop for better readability \ No newline at end of file From 91a601fb5f13efa73d0d7a444abd0242f522f911 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Mon, 1 Apr 2024 16:30:12 -0400 Subject: [PATCH 23/48] Remove console spam --- .gitlab/scripts/linux_perms_fix.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.gitlab/scripts/linux_perms_fix.sh b/.gitlab/scripts/linux_perms_fix.sh index 41993fc3..d727b16b 100644 --- a/.gitlab/scripts/linux_perms_fix.sh +++ b/.gitlab/scripts/linux_perms_fix.sh @@ -4,10 +4,10 @@ read -p "Enter the directory path to set permissions (/var/opt/minecraft/crafty): " directory_path # Count the total number of directories -total_dirs=$(find "$directory_path" -type d | wc -l) +total_dirs=$(find "$directory_path" -type d 2>/dev/null | wc -l) # Count the total number of files -total_files=$(find "$directory_path" -type f | wc -l) +total_files=$(find "$directory_path" -type f 2>/dev/null | wc -l) # Initialize a counter for directories and files dir_count=0 @@ -27,17 +27,19 @@ else # Run the commands to set permissions for directories echo "Changing permissions for directories:" - for dir in $(find "$directory_path" -type d); do - sudo chmod 700 "$dir" - ((dir_count++)) + for dir in $(find "$directory_path" -type d 2>/dev/null); do + if [ -e "$dir" ]; then + sudo chmod 700 "$dir" && ((dir_count++)) + fi print_progress done # Run the commands to set permissions for files echo -e "\nChanging permissions for files:" - for file in $(find "$directory_path" -type f); do - sudo chmod 644 "$file" - ((file_count++)) + for file in $(find "$directory_path" -type f 2>/dev/null); do + if [ -e "$file" ]; then + sudo chmod 644 "$file" && ((file_count++)) + fi print_progress done echo "You will now need to execute a chmod +x on all bedrock executables" From 432421f36241cfe62174f906f079140c7f2b986b Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Mon, 1 Apr 2024 17:02:27 -0400 Subject: [PATCH 24/48] Fix server clones following uuid migration --- .../web/routes/api/servers/server/action.py | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/app/classes/web/routes/api/servers/server/action.py b/app/classes/web/routes/api/servers/server/action.py index 01ce45c4..7de2697d 100644 --- a/app/classes/web/routes/api/servers/server/action.py +++ b/app/classes/web/routes/api/servers/server/action.py @@ -67,20 +67,29 @@ class ApiServersServerActionHandler(BaseApiHandler): name_counter += 1 new_server_name = server_data.get("server_name") + f" (Copy {name_counter})" - new_server_id = self.controller.servers.create_server( - new_server_name, - None, - "", - None, - server_data.get("executable"), - None, - server_data.get("stop_command"), - server_data.get("type"), - user_id, - server_data.get("server_port"), + new_server_id = self.helper.create_uuid() + new_server_path = os.path.join(self.helper.servers_dir, new_server_id) + new_backup_path = os.path.join(self.helper.backup_path, new_server_id) + new_server_command = str(server_data.get("execution_command")).replace( + server_id, new_server_id + ) + new_server_log_path = server_data.get("log_path").replace( + server_id, new_server_id ) - new_server_path = os.path.join(self.helper.servers_dir, new_server_id) + self.controller.register_server( + new_server_name, + new_server_id, + new_server_path, + new_backup_path, + new_server_command, + server_data.get("executable"), + new_server_log_path, + server_data.get("stop_command"), + server_data.get("server_port"), + user_id, + server_data.get("type"), + ) self.controller.management.add_to_audit_log( user_id, @@ -92,18 +101,6 @@ class ApiServersServerActionHandler(BaseApiHandler): # copy the old server FileHelpers.copy_dir(server_data.get("path"), new_server_path) - # TODO get old server DB data to individual variables - new_server_command = str(server_data.get("execution_command")) - new_server_log_file = str( - self.helper.get_os_understandable_path(server_data.get("log_path")) - ) - - server: Servers = self.controller.servers.get_server_obj(new_server_id) - server.path = new_server_path - server.log_path = new_server_log_file - server.execution_command = new_server_command - self.controller.servers.update_server(server) - for role in self.controller.server_perms.get_server_roles(server_id): mask = self.controller.server_perms.get_permissions_mask( role.role_id, server_id From 50ccac8ea5faa0550f1f6176a8859e9fdb49d692 Mon Sep 17 00:00:00 2001 From: Analicia Abernathy Date: Mon, 1 Apr 2024 16:58:37 -0500 Subject: [PATCH 25/48] update czech language --- .../{cs_CS_incomplete.json => cs_CS.json} | 90 ++++++++++++++++++- 1 file changed, 89 insertions(+), 1 deletion(-) rename app/translations/{cs_CS_incomplete.json => cs_CS.json} (85%) diff --git a/app/translations/cs_CS_incomplete.json b/app/translations/cs_CS.json similarity index 85% rename from app/translations/cs_CS_incomplete.json rename to app/translations/cs_CS.json index 879b78cd..2229d5cb 100644 --- a/app/translations/cs_CS_incomplete.json +++ b/app/translations/cs_CS.json @@ -53,6 +53,20 @@ "translationTitle": "Překlad do jazyků", "translator": "Překladatelé" }, + "customLogin": { + "apply": "použít", + "backgroundUpload": "Nahrání pozadí", + "customLoginPage": "Udělej si vlastní přihlašovací stránku", + "delete": "Smazat", + "labelLoginImage": "Vyber si svoji přihlašovací stránku", + "loginBackground": "Pozadí pro přihlášeni", + "loginImage": "Nahrání pozadí pro přihlašovací stránku.", + "loginOpacity": "Nastavení transparentnosti přihlašovacího okna", + "pageTitle": "Vlastní přihlašovací stránka", + "preview": "Náhled", + "select": "Vybrat", + "selectImage": "Vybrat obrázek" + }, "dashboard": { "actions": "Akce", "allServers": "Všechny servery", @@ -97,6 +111,7 @@ "starting": "Zpožděný start", "status": "Stav", "stop": "Zastavit", + "storage": "úložiště", "version": "Verze", "welcome": "Vítejte v Crafty Controlleru" }, @@ -181,8 +196,11 @@ }, "error": { "agree": "Souhlasím", + "bedrockError": "Stažení Bedrocku není dostupné. Prosím zkontrolujte", "cancel": "Zrušit", "contact": "Kontaktujte podporu Crafty přes Discord", + "craftyStatus": "Crafty stav systémů", + "cronFormat": "Neplatný formát Cron", "embarassing": "Ach jo, no, to je trapné.", "error": "Chyba!", "eulaAgree": "Souhlasíte?", @@ -191,12 +209,17 @@ "fileError": "Typ souboru musí být obrázek.", "fileTooLarge": "Odeslání se nezdařilo. Příliš velký nahraný soubor. Obraťte se na správce systému.", "hereIsTheError": "Zde je chyba", + "installerJava": "Selhala instalace {} : Forge servery potřebují k instalaci Javu. Zjistili jsme že java není nainstalovaná. Prosím nainstalujte java na server.", "internet": "Zjistili jsme, že počítač se spuštěným programem Crafty není připojen k internetu. Připojení klientů k serveru může být omezeno.", + "migration": "Crafty's hlavní úložiště se přesouvá do jiné lokace. Všechny servry budou pozastaveny v tento čas. Prosím počkejte než se dokončí migrace", "no-file": "Zdá se, že nemůžeme najít požadovaný soubor. Překontrolujte cestu. Má Crafty správné oprávnění?", + "noInternet": "Crafty se nemůže připojit k internetu. Vytváření serverů je pozastaveno. Prosím zkontrolujte připojení k internetu a potom obnovte tuto stránku.", "noJava": "Server {} se nepodařilo spustit s kódem chyby: Zjistili jsme, že Java není nainstalována. Nainstalujte prosím Javu a poté spusťte server.", "not-downloaded": "Zdá se, že nemůžeme najít váš spustitelný soubor. Bylo jeho stahování dokončeno? Jsou oprávnění nastavena na spustitelný soubor?", "portReminder": "Zjistili jsme, že server {} byl spuštěn poprvé. Ujistěte se, že jste přesměrovali port {} přes váš směrovač/firewall, aby byl tento port vzdáleně přístupný z internetu.", "privMsg": "a ", + "serverJars1": "Server JAR api je nepřístupná. Prosím zkontrolujte", + "serverJars2": "pro aktualní informace.", "start-error": "Server {} se nepodařilo spustit s kódem chyby: {}", "superError": "Pro dokončení této akce musíte být super uživatel.", "terribleFailure": "Jaké strašné selhání!" @@ -207,10 +230,14 @@ "version": "Verze" }, "login": { + "defaultPath": "Heslo které jste vložili je výchozí cesta k pověření. Prosím najděte výchozí heslo v této lokaci.", + "disabled": "Uživatelský účet byl pozastaven. Prosím kontaktujte vašeho správce systému pro více informací.", "forgotPassword": "Zapomenuté heslo", + "incorrect": "Nesprávné uživatelské jméno nebo heslo", "login": "Přihlásit se", "password": "Heslo", - "username": "Uživatelské jméno" + "username": "Uživatelské jméno", + "viewStatus": "Podívejte se na statusy systému" }, "notify": { "activityLog": "Záznamy o činnosti", @@ -222,21 +249,32 @@ "preparingLogs": " Počkejte prosím, než připravíme vaše protokoly... Až budou připraveny, pošleme vám oznámení. U rozsáhlých zavádění to může chvíli trvat.", "supportLogs": "Protokoly podpory" }, + "offline": { + "offline": "Offline", + "pleaseConnect": "Prosím připojte se k internetu ať můžete používat Crafty." + }, "panelConfig": { "adminControls": "Ovládání správce", "allowedServers": "Povolené servery", + "apply": "Použít", "assignedRoles": "Přidělené role", "backgroundUpload": "Nahrání pozadí", "cancel": "Zrušit", "clearComms": "Vymazat nevykonané příkazy", + "custom": "Upravit Crafty", "delete": "Smazat", "edit": "Upravit", + "enableLang": "Povolit všechny jazyky", "enabled": "Zapnuto", + "globalExplain": "Kde má Crafty ukládat všechny soubory serverů. (Cestu doplníme o /server/[uuid serveru])", + "globalServer": "Globalní cesta k serverům", + "json": "Config.json", "loginBackground": "Přihlašovací obrázek na pozadí", "loginImage": "Nahrajte obrázek na pozadí přihlašovací obrazovky.", "match": "Hesla musí být stejná", "newRole": "Přidat novou roli", "newUser": "Přidat nového uživatele", + "noMounts": "Ukazatel zaplněnosti disků na hlavní stránce", "pageTitle": "Nastavení panelu", "preview": "Náhled", "role": "Role", @@ -247,6 +285,7 @@ "selectImage": "Vyberte obrázek", "superConfirm": "Postupujte pouze v případě, že chcete, aby měl tento uživatel přístup ke VŠEM (ke všem uživatelským účtům, serverům, nastavení panelu atd.). Může vám dokonce odebrat práva superuživatele.", "superConfirmTitle": "Povolit superuživatele? Jste si jisti?", + "title": "Crafty Konfigurace", "user": "Uživatel", "users": "Uživatelé" }, @@ -276,9 +315,11 @@ "serversDesc": "servery, ke kterým má tato role přístup" }, "serverBackups": { + "after": "Spustit příkaz po záloze", "backupAtMidnight": "Automatické zálohování o půlnoci?", "backupNow": "Zálohovat nyní!", "backupTask": "Bylo spuštěno zálohování.", + "before": "Spustit příkaz před zálohou", "cancel": "Zrušit", "clickExclude": "Kliknutím vyberete výjimku", "compress": "Komprimovat zálohu", @@ -309,6 +350,7 @@ "bePatientDeleteFiles": "Buďte prosím trpěliví, než odstraníme váš server z panelu Crafty a všechny jeho soubory. Tato obrazovka se za chvíli zavře.", "bePatientUpdate": "Prosím, buďte trpěliví, dokud server neaktualizujeme. Doba stahování se může lišit v závislosti na rychlosti vašeho internetu.
Tato obrazovka se za chvíli aktualizuje", "cancel": "Zrušit", + "countPlayers": "Počítat server v globálních statistikách", "crashTime": "Časový limit havárie", "crashTimeDesc": "Jak dlouho bychom měli čekat, než budeme váš server považovat za havarovaný?", "deleteFilesQuestion": "Odstranit soubory serveru z přístroje?", @@ -318,6 +360,8 @@ "deleteServerQuestionMessage": "Opravdu chcete tento server odstranit? Po tomto kroku již není cesty zpět...", "exeUpdateURL": "Adresa URL pro aktualizaci spustitelných souborů serveru", "exeUpdateURLDesc": "Adresa URL pro přímé stahování aktualizací.", + "ignoredExits": "Ignorovat kódy pádu serveru", + "ignoredExitsExplain": "Ukončovací kódy kteŕe Crafty bude ignorovat a brát jako normálně ukončený server (odělte čárkou)", "javaNoChange": "Nepřepisujte", "javaVersion": "Přepsat aktuální verzi Javy", "javaVersionDesc": "Pokud se chystáte přepsat Javu, ujistěte se, že je aktuální cesta k Javě v příkazu 'execution command' zabalena do uvozovek (výchozí proměnná 'java' je vyloučena).", @@ -350,6 +394,8 @@ "serverStopCommandDesc": "Příkaz k odeslání programu pro jeho zastavení", "showStatus": "Zobrazit na veřejné stavové stránce", "shutdownTimeout": "Časový limit pro vypnutí", + "statsHint1": "Zde by měl být uveden port, na kterém běží váš serv.er. Tímto způsobem Crafty otevře spojení s vaším serverem pro statistiky.", + "statsHint2": "Toto nezmění tvůj port pro tvůj server. Musíš to také změnit v konfiguračním souboru tvého serveru.", "stopBeforeDeleting": "Před odstraněním serveru jej prosím zastavte", "timeoutExplain1": "Jak dlouho bude Crafty čekat na vypnutí serveru po provedení příkazu", "timeoutExplain2": "než proces ukončí.", @@ -478,8 +524,10 @@ "every": "Každý", "interval": "Interval", "name": "Název", + "newSchedule": "Nový úkol", "nextRun": "Příští spuštění", "no": "Ne", + "no-schedule": "Teď tu nejsou žádné úkoly pro tento server. Pro nový úkol klini", "scheduledTasks": "Naplánované úlohy", "yes": "Ano" }, @@ -487,6 +535,7 @@ "cpuUsage": "Využití CPU", "description": "Popis", "errorCalculatingUptime": "Chyba při výpočtu doby provozu", + "loadingMotd": "Načítaní MOTD", "memUsage": "Využití paměti", "offline": "Offline", "online": "Online", @@ -529,6 +578,7 @@ "importServerButton": "Importovat server!", "importZip": "Imporovat ze souboru Zip", "importing": "Importování serveru...", + "labelZipFile": "Vybrat zip soubor", "maxMem": "Maximální paměť", "minMem": "Minimální paměť", "myNewServer": "Nový server", @@ -549,8 +599,11 @@ "serverPort": "Port serveru", "serverSelect": "Výběr serveru", "serverType": "Typ serveru", + "serverUpload": "Nahrát zazipovány Server", "serverVersion": "Verze serveru", "sizeInGB": "Velikost v GB", + "unsupported": "Verze Minecraftu nižší než 1.8 nejsou v Crafty podporovány. Přesto si ji můžete nainstalovat. Není zaručena funkčnost", + "uploadButton": "Nahrát", "uploadZip": "Nahrání souboru Zip pro importování serveru", "zipPath": "Cesta k serveru" }, @@ -559,10 +612,20 @@ "credits": "Zásluhy", "dashboard": "Ovládací panel", "documentation": "Dokumentace", + "inApp": "V app dokumentaci", "navigation": "Navigace", "newServer": "Vytvořit nový server", "servers": "Servery" }, + "startup": { + "almost": "Dokončuji. Držte se...", + "internals": "Nastavuji a startuji Crafty interní komponenty", + "internet": "Kontroluju připojení k internetu", + "server": "Konfigurace ", + "serverInit": "Konfigurace serveru", + "starting": "Crafty se startuje...", + "tasks": "Startuji plány" + }, "userConfig": { "apiKey": "Klíče API", "auth": "Autorizovaný? ", @@ -602,5 +665,30 @@ "userSettings": "Nastavení uživatele", "userTheme": "Motiv UI", "uses": "Počet povolených použití (-1==bez omezení)" + }, + "webhooks": { + "areYouSureDel": "Seš si jistý že chceš smazat tento webhook?", + "areYouSureRun": "Seš si jistý že chceš otestovat tento webhook?", + "backup_server": "Záloha serveru je hotova.", + "bot_name": "Název bota", + "color": "Vyberte barvu ", + "crash_detected": "Server spadl", + "edit": "Upravit", + "enabled": "Aktivní", + "jar_update": "Server byl aktualizován", + "kill": "Server byl násilně ukončen", + "name": "Název", + "new": "Nový Webhook", + "newWebhook": "Nový Webhook", + "no-webhook": "Teď tu nejsou žádné webhooky pro tento server. Pro nový webhook klikni.", + "run": "Spustit test webhooku", + "send_command": "Server příkaz obdržel", + "start_server": "Server zapnut", + "stop_server": "Server vypnut", + "trigger": "Spustit", + "type": "Typ webhooku", + "url": "Webhook URL", + "webhook_body": "Webhook Body", + "webhooks": "Webhooky" } } From e564208140bc8881a722d59219f83d4404dcd9a1 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Tue, 2 Apr 2024 23:56:05 +0100 Subject: [PATCH 26/48] Update changelog !733 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44750a39..c3b07600 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ TBD ### Bug fixes TBD ### Tweaks -TBD +- Clean up remaining http handler references ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/733)) ### Lang TBD

From 655546446501b1af6521e7253d9b133b5b6395c4 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Wed, 3 Apr 2024 00:24:54 +0100 Subject: [PATCH 27/48] Update changelog !737 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3b07600..9c879e67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ TBD TBD ### Tweaks - Clean up remaining http handler references ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/733)) +- Remove version disclosure on login page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/737)) ### Lang TBD

From a137cebb69d07127eb644a50ae07c665dc29cfb3 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Wed, 3 Apr 2024 00:31:53 +0100 Subject: [PATCH 28/48] Update changelog !739 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c879e67..7f64d986 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ TBD - Clean up remaining http handler references ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/733)) - Remove version disclosure on login page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/737)) ### Lang -TBD +- Update `it_IT, cs_CS` ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/739) | [Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/742))

## --- [4.3.1] - 2024/03/18 From 0fab5cd0f399b185d5eb5c6180cd01be4399794c Mon Sep 17 00:00:00 2001 From: Zedifus Date: Fri, 5 Apr 2024 20:01:37 +0100 Subject: [PATCH 29/48] Refactor for temporary hardcoded types, use new health check response. api.serverjars.com not providing fetchTypes route currently, Will revert when available. NOTE: New api does not incl Spigot / Bukkit. Announce this. --- app/classes/minecraft/serverjars.py | 64 +++++++++++++++++++-------- app/classes/shared/main_controller.py | 2 +- app/classes/web/server_handler.py | 2 +- 3 files changed, 47 insertions(+), 21 deletions(-) diff --git a/app/classes/minecraft/serverjars.py b/app/classes/minecraft/serverjars.py index 83731b52..903ce046 100644 --- a/app/classes/minecraft/serverjars.py +++ b/app/classes/minecraft/serverjars.py @@ -12,13 +12,15 @@ from app.classes.shared.file_helpers import FileHelpers from app.classes.shared.websocket_manager import WebSocketManager logger = logging.getLogger(__name__) +# Temp type var, see line(s) #215 #257 #285 +SERVERJARS_TYPES = ["modded", "proxies", "servers", "vanilla"] PAPERJARS = ["paper", "folia"] class ServerJars: def __init__(self, helper): self.helper = helper - self.base_url = "https://serverjars.com" + self.base_url = "https://api.serverjars.com" self.paper_base = "https://api.papermc.io" @staticmethod @@ -168,21 +170,28 @@ class ServerJars: data = self._read_cache() return data.get("types") - def _check_api_alive(self): + def _check_sjars_api_alive(self): logger.info("Checking serverjars.com API status") - check_url = f"{self.base_url}/api/fetchTypes" + check_url = f"{self.base_url}" try: response = requests.get(check_url, timeout=2) + response_json = response.json() - if response.status_code in [200, 201]: - logger.info("Serverjars.com API is alive") + if ( + response.status_code in [200, 201] + and response_json.get("status") == "success" + and response_json.get("response", {}).get("status") == "ok" + ): + logger.info("Serverjars.com API is alive and responding as expected") return True except Exception as e: - logger.error(f"Unable to connect to serverjar.com api due to error: {e}") - return {} + logger.error(f"Unable to connect to serverjar.com API due to error: {e}") + return False - logger.error("unable to contact serverjars.com api") + logger.error( + "Serverjars.com API is not responding as expected or unable to contact" + ) return False def manual_refresh_cache(self): @@ -192,7 +201,7 @@ class ServerJars: # cache_old = True # if the API is down... we bomb out - if not self._check_api_alive(): + if not self._check_sjars_api_alive(): return False logger.info("Manual Refresh requested.") @@ -202,7 +211,14 @@ class ServerJars: "types": {}, } - jar_types = self._get_server_type_list() + # jar_types = self._get_server_type_list() + jar_types = { + type_: ( + {paperjar: [] for paperjar in PAPERJARS} if type_ == "servers" else {} + ) + for type_ in SERVERJARS_TYPES + } + data["types"].update(jar_types) for s in data["types"]: data["types"].update({s: dict.fromkeys(data["types"].get(s), {})}) @@ -228,7 +244,7 @@ class ServerJars: # cache_old = True # if the API is down... we bomb out - if not self._check_api_alive(): + if not self._check_sjars_api_alive(): return False logger.info("Checking Cache file age") @@ -242,7 +258,16 @@ class ServerJars: "types": {}, } - jar_types = self._get_server_type_list() + # jar_types = self._get_server_type_list() + jar_types = { + type_: ( + {paperjar: [] for paperjar in PAPERJARS} + if type_ == "servers" + else {} + ) + for type_ in SERVERJARS_TYPES + } + data["types"].update(jar_types) for s in data["types"]: data["types"].update({s: dict.fromkeys(data["types"].get(s), {})}) @@ -269,13 +294,14 @@ class ServerJars: time.sleep(0.5) return temp - def _get_server_type_list(self): - url = "/api/fetchTypes/" - response = self._get_api_result(url) - if "bedrock" in response.keys(): - # remove pocketmine from options - del response["bedrock"] - return response + # Disabled temporarily until api.serverjars.com resolve their fetchTypes route + # def _get_server_type_list(self): + # url = "/api/fetchTypes/" + # response = self._get_api_result(url) + # if "bedrock" in response.keys(): + # # remove pocketmine from options + # del response["bedrock"] + # return response def download_jar(self, jar, server, version, path, server_id): update_thread = threading.Thread( diff --git a/app/classes/shared/main_controller.py b/app/classes/shared/main_controller.py index b6e824a5..47e4f6ce 100644 --- a/app/classes/shared/main_controller.py +++ b/app/classes/shared/main_controller.py @@ -575,7 +575,7 @@ class Controller: ): server_obj = self.servers.get_server_obj(new_server_id) url = ( - "https://serverjars.com/api/fetchJar/" + "https://api.serverjars.com/api/fetchJar/" f"{create_data['category']}" f"/{create_data['type']}/{create_data['version']}" ) diff --git a/app/classes/web/server_handler.py b/app/classes/web/server_handler.py index 545029aa..62b76f3c 100644 --- a/app/classes/web/server_handler.py +++ b/app/classes/web/server_handler.py @@ -147,7 +147,7 @@ class ServerHandler(BaseHandler): page_data["server_api"] = False if page_data["online"]: page_data["server_api"] = self.helper.check_address_status( - "https://serverjars.com/api/fetchTypes" + "https://api.serverjars.com" ) page_data["server_types"] = self.controller.server_jars.get_serverjar_data() page_data["js_server_types"] = json.dumps( From cc67ebef76cbb0af9e89c4122a342839a940ebf1 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sat, 6 Apr 2024 01:38:45 +0100 Subject: [PATCH 30/48] A further clean up and refactor of server jars cache logic Reordered code, and tidy'd based on DRY (Don't Repeat Yourself) --- app/classes/minecraft/serverjars.py | 339 ++++++++++++++-------------- 1 file changed, 169 insertions(+), 170 deletions(-) diff --git a/app/classes/minecraft/serverjars.py b/app/classes/minecraft/serverjars.py index 903ce046..4a9883a9 100644 --- a/app/classes/minecraft/serverjars.py +++ b/app/classes/minecraft/serverjars.py @@ -12,7 +12,7 @@ from app.classes.shared.file_helpers import FileHelpers from app.classes.shared.websocket_manager import WebSocketManager logger = logging.getLogger(__name__) -# Temp type var, see line(s) #215 #257 #285 +# Temp type var until sjars restores generic fetchTypes SERVERJARS_TYPES = ["modded", "proxies", "servers", "vanilla"] PAPERJARS = ["paper", "folia"] @@ -84,6 +84,174 @@ class ServerJars: builds = api_data.get("builds", []) return builds[-1] if builds else None + def _read_cache(self): + cache_file = self.helper.serverjar_cache + cache = {} + try: + with open(cache_file, "r", encoding="utf-8") as f: + cache = json.load(f) + + except Exception as e: + logger.error(f"Unable to read serverjars.com cache file: {e}") + + return cache + + def get_serverjar_data(self): + data = self._read_cache() + return data.get("types") + + def _check_sjars_api_alive(self): + logger.info("Checking serverjars.com API status") + + check_url = f"{self.base_url}" + try: + response = requests.get(check_url, timeout=2) + response_json = response.json() + + if ( + response.status_code in [200, 201] + and response_json.get("status") == "success" + and response_json.get("response", {}).get("status") == "ok" + ): + logger.info("Serverjars.com API is alive and responding as expected") + return True + except Exception as e: + logger.error(f"Unable to connect to serverjar.com API due to error: {e}") + return False + + logger.error( + "Serverjars.com API is not responding as expected or unable to contact" + ) + return False + + def _fetch_projects_for_type(self, server_type): + """ + Fetches projects for a given server type from the ServerJars API. + """ + try: + response = requests.get( + f"{self.base_url}/api/fetchTypes/{server_type}", timeout=5 + ) + response.raise_for_status() # Ensure HTTP errors are caught + data = response.json() + if data.get("status") == "success": + return data["response"].get("servers", []) + except requests.RequestException as e: + print(f"Error fetching projects for type {server_type}: {e}") + return [] + + def _get_server_type_list(self): + """ + Builds the type structure with projects fetched for each type. + """ + type_structure = {} + for server_type in SERVERJARS_TYPES: + projects = self._fetch_projects_for_type(server_type) + type_structure[server_type] = {project: [] for project in projects} + return type_structure + + def _get_jar_versions(self, server_type, project_name): + """ + Grabs available versions per project + """ + url = f"{self.base_url}/api/fetchAll/{server_type}/{project_name}" + try: + response = requests.get(url, timeout=5) + response.raise_for_status() # Ensure HTTP errors are caught + data = response.json() + logger.debug(f"Received data for {server_type}/{project_name}: {data}") + + if data.get("status") == "success": + versions = [ + item.get("version") + for item in data.get("response", []) + if "version" in item + ] + logger.debug(f"Versions extracted: {versions}") + return versions + except requests.RequestException as e: + logger.error( + f"Error fetching jar versions for {server_type}/{project_name}: {e}" + ) + + return [] + + def _refresh_cache(self): + """ + Contains the shared logic for refreshing the cache. + This method is called by both manual_refresh_cache and refresh_cache methods. + """ + now = datetime.now() + cache_data = { + "last_refreshed": now.strftime("%m/%d/%Y, %H:%M:%S"), + "types": self._get_server_type_list(), + } + + for server_type, projects in cache_data["types"].items(): + for project_name in projects: + versions = self._get_jar_versions(server_type, project_name) + cache_data["types"][server_type][project_name] = versions + + for paper_project in PAPERJARS: + cache_data["types"]["servers"][paper_project] = self.get_paper_versions( + paper_project + ) + + return cache_data + + def manual_refresh_cache(self): + """ + Manually triggers the cache refresh process. + """ + if not self._check_sjars_api_alive(): + logger.error("ServerJars API is not available.") + return False + + logger.info("Manual cache refresh requested.") + cache_data = self._refresh_cache() + + # Save the updated cache data + try: + with open(self.helper.serverjar_cache, "w", encoding="utf-8") as cache_file: + json.dump(cache_data, cache_file, indent=4) + logger.info("Cache file successfully refreshed manually.") + except Exception as e: + logger.error(f"Failed to update cache file manually: {e}") + + def refresh_cache(self): + """ + Automatically trigger cache refresh process based age. + + This method checks if the cache file is older than a specified number of days + before deciding to refresh. + """ + cache_file_path = self.helper.serverjar_cache + + # Determine if the cache is old and needs refreshing + cache_old = self.helper.is_file_older_than_x_days(cache_file_path) + + # debug override + # cache_old = True + + if not self._check_sjars_api_alive(): + logger.error("ServerJars API is not available.") + return False + + if not cache_old: + logger.info("Cache file is not old enough to require automatic refresh.") + return False + + logger.info("Automatic cache refresh initiated due to old cache.") + cache_data = self._refresh_cache() + + # Save the updated cache data + try: + with open(cache_file_path, "w", encoding="utf-8") as cache_file: + json.dump(cache_data, cache_file, indent=4) + logger.info("Cache file successfully refreshed automatically.") + except Exception as e: + logger.error(f"Failed to update cache file automatically: {e}") + def get_fetch_url(self, jar, server, version): """ Constructs the URL for downloading a server JAR file based on the server type. @@ -134,175 +302,6 @@ class ServerJars: logger.error(f"An error occurred while constructing fetch URL: {e}") return None - def _get_api_result(self, call_url: str): - full_url = f"{self.base_url}{call_url}" - - try: - response = requests.get(full_url, timeout=2) - response.raise_for_status() - api_data = json.loads(response.content) - except Exception as e: - logger.error(f"Unable to load {full_url} api due to error: {e}") - return {} - - api_result = api_data.get("status") - api_response = api_data.get("response", {}) - - if api_result != "success": - logger.error(f"Api returned a failed status: {api_result}") - return {} - - return api_response - - def _read_cache(self): - cache_file = self.helper.serverjar_cache - cache = {} - try: - with open(cache_file, "r", encoding="utf-8") as f: - cache = json.load(f) - - except Exception as e: - logger.error(f"Unable to read serverjars.com cache file: {e}") - - return cache - - def get_serverjar_data(self): - data = self._read_cache() - return data.get("types") - - def _check_sjars_api_alive(self): - logger.info("Checking serverjars.com API status") - - check_url = f"{self.base_url}" - try: - response = requests.get(check_url, timeout=2) - response_json = response.json() - - if ( - response.status_code in [200, 201] - and response_json.get("status") == "success" - and response_json.get("response", {}).get("status") == "ok" - ): - logger.info("Serverjars.com API is alive and responding as expected") - return True - except Exception as e: - logger.error(f"Unable to connect to serverjar.com API due to error: {e}") - return False - - logger.error( - "Serverjars.com API is not responding as expected or unable to contact" - ) - return False - - def manual_refresh_cache(self): - cache_file = self.helper.serverjar_cache - - # debug override - # cache_old = True - - # if the API is down... we bomb out - if not self._check_sjars_api_alive(): - return False - - logger.info("Manual Refresh requested.") - now = datetime.now() - data = { - "last_refreshed": now.strftime("%m/%d/%Y, %H:%M:%S"), - "types": {}, - } - - # jar_types = self._get_server_type_list() - jar_types = { - type_: ( - {paperjar: [] for paperjar in PAPERJARS} if type_ == "servers" else {} - ) - for type_ in SERVERJARS_TYPES - } - - data["types"].update(jar_types) - for s in data["types"]: - data["types"].update({s: dict.fromkeys(data["types"].get(s), {})}) - for j in data["types"].get(s): - versions = self._get_jar_details(j, s) - data["types"][s].update({j: versions}) - for item in PAPERJARS: - data["types"]["servers"][item] = self.get_paper_versions(item) - # save our cache - try: - with open(cache_file, "w", encoding="utf-8") as f: - f.write(json.dumps(data, indent=4)) - logger.info("Cache file refreshed") - - except Exception as e: - logger.error(f"Unable to update serverjars.com cache file: {e}") - - def refresh_cache(self): - cache_file = self.helper.serverjar_cache - cache_old = self.helper.is_file_older_than_x_days(cache_file) - - # debug override - # cache_old = True - - # if the API is down... we bomb out - if not self._check_sjars_api_alive(): - return False - - logger.info("Checking Cache file age") - # if file is older than 1 day - - if cache_old: - logger.info("Cache file is over 1 day old, refreshing") - now = datetime.now() - data = { - "last_refreshed": now.strftime("%m/%d/%Y, %H:%M:%S"), - "types": {}, - } - - # jar_types = self._get_server_type_list() - jar_types = { - type_: ( - {paperjar: [] for paperjar in PAPERJARS} - if type_ == "servers" - else {} - ) - for type_ in SERVERJARS_TYPES - } - - data["types"].update(jar_types) - for s in data["types"]: - data["types"].update({s: dict.fromkeys(data["types"].get(s), {})}) - for j in data["types"].get(s): - versions = self._get_jar_details(j, s) - data["types"][s].update({j: versions}) - for item in PAPERJARS: - data["types"]["servers"][item] = self.get_paper_versions(item) - # save our cache - try: - with open(cache_file, "w", encoding="utf-8") as f: - f.write(json.dumps(data, indent=4)) - logger.info("Cache file refreshed") - - except Exception as e: - logger.error(f"Unable to update serverjars.com cache file: {e}") - - def _get_jar_details(self, server_type, jar_type="servers"): - url = f"/api/fetchAll/{jar_type}/{server_type}" - response = self._get_api_result(url) - temp = [] - for v in response: - temp.append(v.get("version")) - time.sleep(0.5) - return temp - - # Disabled temporarily until api.serverjars.com resolve their fetchTypes route - # def _get_server_type_list(self): - # url = "/api/fetchTypes/" - # response = self._get_api_result(url) - # if "bedrock" in response.keys(): - # # remove pocketmine from options - # del response["bedrock"] - # return response - def download_jar(self, jar, server, version, path, server_id): update_thread = threading.Thread( name=f"server_download-{server_id}-{server}-{version}", From afb75753988ee13177a0fc46cae20ade7c2036f6 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Sat, 6 Apr 2024 15:05:26 -0400 Subject: [PATCH 31/48] Fix API perms request returning stack --- app/classes/web/routes/api/users/user/permissions.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/classes/web/routes/api/users/user/permissions.py b/app/classes/web/routes/api/users/user/permissions.py index b6c8703a..5981eaf4 100644 --- a/app/classes/web/routes/api/users/user/permissions.py +++ b/app/classes/web/routes/api/users/user/permissions.py @@ -52,6 +52,8 @@ class ApiUsersUserPermissionsHandler(BaseApiHandler): }, ) + counter_data = PermissionsCrafty.get_created_quantity_list(user_id) + self.finish_json( 200, { @@ -59,9 +61,9 @@ class ApiUsersUserPermissionsHandler(BaseApiHandler): "data": { "permissions": res_data.permissions, "counters": { - SERVER_CREATION: res_data.created_server, - USER_CONFIG: res_data.created_user, - ROLES_CONFIG: res_data.created_role, + SERVER_CREATION: counter_data["SERVER_CREATION"], + USER_CONFIG: counter_data["USER_CONFIG"], + ROLES_CONFIG: counter_data["ROLES_CONFIG"], }, "limits": { SERVER_CREATION: res_data.limit_server_creation, From 20d5f856020273152a7f00ae17ea515fb0935473 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sat, 6 Apr 2024 20:20:45 +0100 Subject: [PATCH 32/48] Increase max versions returned --- app/classes/minecraft/serverjars.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/classes/minecraft/serverjars.py b/app/classes/minecraft/serverjars.py index 4a9883a9..d0e90024 100644 --- a/app/classes/minecraft/serverjars.py +++ b/app/classes/minecraft/serverjars.py @@ -12,7 +12,7 @@ from app.classes.shared.file_helpers import FileHelpers from app.classes.shared.websocket_manager import WebSocketManager logger = logging.getLogger(__name__) -# Temp type var until sjars restores generic fetchTypes +# Temp type var until sjars restores generic fetchTypes0 SERVERJARS_TYPES = ["modded", "proxies", "servers", "vanilla"] PAPERJARS = ["paper", "folia"] @@ -150,11 +150,19 @@ class ServerJars: type_structure[server_type] = {project: [] for project in projects} return type_structure - def _get_jar_versions(self, server_type, project_name): + def _get_jar_versions(self, server_type, project_name, max_ver=50): """ - Grabs available versions per project + Grabs available versions for specified project + + Args: + server_type (str): Server Type Category (modded, servers, etc) + project_name (str): Target project (paper, forge, magma, etc) + max (int, optional): Max versions returned. Defaults to 50. + + Returns: + list: An array of versions """ - url = f"{self.base_url}/api/fetchAll/{server_type}/{project_name}" + url = f"{self.base_url}/api/fetchAll/{server_type}/{project_name}?max={max_ver}" try: response = requests.get(url, timeout=5) response.raise_for_status() # Ensure HTTP errors are caught From b34e0c813ee3f0c8a29cf2fd0a29b7393c89b640 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sat, 6 Apr 2024 20:38:29 +0100 Subject: [PATCH 33/48] Update changelog !734 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f64d986..924018e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ### New features TBD ### Bug fixes -TBD +- Fix migrator issues when jumping versions ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/734)) ### Tweaks - Clean up remaining http handler references ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/733)) - Remove version disclosure on login page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/737)) From 52a4ba4a972302525abb93b3644ca20e61466dfd Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sat, 6 Apr 2024 20:53:56 +0100 Subject: [PATCH 34/48] Update changelog !736 --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 924018e8..b0c03e23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ ### New features TBD ### Bug fixes -- Fix migrator issues when jumping versions ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/734)) +- Fix migrator issue when jumping versions ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/734)) +- Fix backend issue causing error when restoring backups in 4.3.x ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/736)) ### Tweaks - Clean up remaining http handler references ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/733)) - Remove version disclosure on login page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/737)) From 5d9a3b57ec458cb67a7dce904a740679a642a4b1 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sat, 6 Apr 2024 21:08:10 +0100 Subject: [PATCH 35/48] Update changelog !744 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0c03e23..b8450118 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## --- [4.3.2] - 2024/TBD ### New features TBD +### Refactor +- Refactor ServerJars caching and move to api.serverjars.com ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/744)) ### Bug fixes - Fix migrator issue when jumping versions ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/734)) - Fix backend issue causing error when restoring backups in 4.3.x ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/736)) From 4f469f3df1d08692172283bc5a1099f4e8d30e25 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Sat, 6 Apr 2024 16:24:55 -0400 Subject: [PATCH 36/48] Do not allow clone while server is running --- app/classes/web/routes/api/servers/server/action.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/classes/web/routes/api/servers/server/action.py b/app/classes/web/routes/api/servers/server/action.py index 7de2697d..526899b5 100644 --- a/app/classes/web/routes/api/servers/server/action.py +++ b/app/classes/web/routes/api/servers/server/action.py @@ -33,6 +33,17 @@ class ApiServersServerActionHandler(BaseApiHandler): self.controller.crafty_perms.can_create_server(auth_data[4]["user_id"]) or auth_data[4]["superuser"] ): + srv_object = self.controller.servers.get_server_instance_by_id( + server_id + ) + if srv_object.check_running(): + return self.finish_json( + 409, + { + "status": "error", + "error": "Server Running!", + }, + ) self._clone_server(server_id, auth_data[4]["user_id"]) return self.finish_json(200, {"status": "ok"}) return self.finish_json( From b4a962b5a6b964ade91aed75bcfe1e2b001b205d Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sat, 6 Apr 2024 21:39:30 +0100 Subject: [PATCH 37/48] Update changelog !741 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8450118..74695a9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ TBD ### Bug fixes - Fix migrator issue when jumping versions ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/734)) - Fix backend issue causing error when restoring backups in 4.3.x ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/736)) +- Fix backend issue causing error when cloning servers in 4.3.x ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/741)) ### Tweaks - Clean up remaining http handler references ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/733)) - Remove version disclosure on login page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/737)) From 057139c7e11bcfc17e0669e0ae278e4f1f6ab63c Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sat, 6 Apr 2024 22:01:37 +0100 Subject: [PATCH 38/48] Rerverse order of returned server jars versions Logic I removed in my refactor, whoops! Newest -> oldest --- app/classes/minecraft/serverjars.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/classes/minecraft/serverjars.py b/app/classes/minecraft/serverjars.py index d0e90024..944ec382 100644 --- a/app/classes/minecraft/serverjars.py +++ b/app/classes/minecraft/serverjars.py @@ -175,6 +175,7 @@ class ServerJars: for item in data.get("response", []) if "version" in item ] + versions.reverse() # Reverse so versions are newest -> oldest logger.debug(f"Versions extracted: {versions}") return versions except requests.RequestException as e: From 03717d453a2613c2093ca4c4390561f9ff4862f7 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sat, 6 Apr 2024 22:06:02 +0100 Subject: [PATCH 39/48] Update changelog !746 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74695a9c..94f732ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ### New features TBD ### Refactor -- Refactor ServerJars caching and move to api.serverjars.com ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/744)) +- Refactor ServerJars caching and move to api.serverjars.com ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/744) | [Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/746)) ### Bug fixes - Fix migrator issue when jumping versions ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/734)) - Fix backend issue causing error when restoring backups in 4.3.x ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/736)) From 8f692d885f06287d00faf713bcbf23619813bd9b Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sat, 6 Apr 2024 22:32:14 +0100 Subject: [PATCH 40/48] Bump orjson for CVE-2024-27454 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e3a58bad..ed0f7698 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,5 +18,5 @@ termcolor==1.1 tornado==6.3.3 tzlocal==5.1 jsonschema==4.19.1 -orjson==3.9.7 +orjson==3.9.15 prometheus-client==0.17.1 From ff20705f32e77f4212fcc4783901b2226b69ccd5 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sat, 6 Apr 2024 22:35:10 +0100 Subject: [PATCH 41/48] Update changelog !747 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74695a9c..66b9b363 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ TBD - Fix migrator issue when jumping versions ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/734)) - Fix backend issue causing error when restoring backups in 4.3.x ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/736)) - Fix backend issue causing error when cloning servers in 4.3.x ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/741)) +- Bump orjson for CVE-2024-27454 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/747)) ### Tweaks - Clean up remaining http handler references ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/733)) - Remove version disclosure on login page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/737)) From 63133809226c73bad67e9d88008d65f93cdb1cb8 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sat, 6 Apr 2024 22:54:43 +0100 Subject: [PATCH 42/48] Fix calling of orjson .JSONDecodeError class --- app/classes/web/routes/api/crafty/config/index.py | 4 ++-- app/classes/web/routes/api/crafty/config/server_dir.py | 2 +- app/classes/web/routes/api/roles/role/index.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/classes/web/routes/api/crafty/config/index.py b/app/classes/web/routes/api/crafty/config/index.py index b95d15a0..40504d76 100644 --- a/app/classes/web/routes/api/crafty/config/index.py +++ b/app/classes/web/routes/api/crafty/config/index.py @@ -106,7 +106,7 @@ class ApiCraftyConfigIndexHandler(BaseApiHandler): try: data = orjson.loads(self.request.body) - except orjson.decoder.JSONDecodeError as e: + except orjson.JSONDecodeError as e: return self.finish_json( 400, {"status": "error", "error": "INVALID_JSON", "error_data": str(e)} ) @@ -187,7 +187,7 @@ class ApiCraftyCustomizeIndexHandler(BaseApiHandler): try: data = orjson.loads(self.request.body) - except orjson.decoder.JSONDecodeError as e: + except orjson.JSONDecodeError as e: return self.finish_json( 400, {"status": "error", "error": "INVALID_JSON", "error_data": str(e)} ) diff --git a/app/classes/web/routes/api/crafty/config/server_dir.py b/app/classes/web/routes/api/crafty/config/server_dir.py index 87835d35..07cf7c26 100644 --- a/app/classes/web/routes/api/crafty/config/server_dir.py +++ b/app/classes/web/routes/api/crafty/config/server_dir.py @@ -68,7 +68,7 @@ class ApiCraftyConfigServerDirHandler(BaseApiHandler): try: data = orjson.loads(self.request.body) - except orjson.decoder.JSONDecodeError as e: + except orjson.JSONDecodeError as e: return self.finish_json( 400, {"status": "error", "error": "INVALID_JSON", "error_data": str(e)} ) diff --git a/app/classes/web/routes/api/roles/role/index.py b/app/classes/web/routes/api/roles/role/index.py index a45c297f..97362f5b 100644 --- a/app/classes/web/routes/api/roles/role/index.py +++ b/app/classes/web/routes/api/roles/role/index.py @@ -133,7 +133,7 @@ class ApiRolesRoleIndexHandler(BaseApiHandler): try: data = orjson.loads(self.request.body) - except orjson.decoder.JSONDecodeError as e: + except orjson.JSONDecodeError as e: return self.finish_json( 400, {"status": "error", "error": "INVALID_JSON", "error_data": str(e)} ) From 21394211355191f1ba9dbc59dfecc2abe19bc76d Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sat, 6 Apr 2024 22:56:14 +0100 Subject: [PATCH 43/48] Update changelog !747 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66b9b363..7c9c1d05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ TBD - Fix backend issue causing error when restoring backups in 4.3.x ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/736)) - Fix backend issue causing error when cloning servers in 4.3.x ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/741)) - Bump orjson for CVE-2024-27454 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/747)) +- Fix calling of orjson JSONDecodeError class ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/747)) ### Tweaks - Clean up remaining http handler references ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/733)) - Remove version disclosure on login page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/737)) From 2357b9fa21dacb70a61a541f323918f1413acfba Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sat, 6 Apr 2024 23:41:24 +0100 Subject: [PATCH 44/48] Make help text in repo templates comments. People aren't removing the example text, thus MR's and issues are messy --- .gitlab/issue_templates/Bug.md | 8 ++++---- .gitlab/issue_templates/Change Request.md | 7 ++++--- .gitlab/issue_templates/Feature Request.md | 8 ++++---- .gitlab/merge_request_templates/Default.md | 18 +++++++++--------- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.gitlab/issue_templates/Bug.md b/.gitlab/issue_templates/Bug.md index 88b2a3b4..77136b69 100644 --- a/.gitlab/issue_templates/Bug.md +++ b/.gitlab/issue_templates/Bug.md @@ -3,16 +3,16 @@ - **Install Type:** Git Cloned(Manual) / Installer / WinPackage / Docker ## What Happened? -*A brief description of what happened when you tried to perform an action* + ## Expected result -*What should have happened when you performed the actions* + ## Steps to reproduce -*List the steps required to produce the error. These should be as few as possible* + ## Screenshots -Any relevant screenshots which show the issue* !-->* + ## Priority/Severity - [ ] High (anything that impacts the normal user flow or blocks app usage) diff --git a/.gitlab/issue_templates/Change Request.md b/.gitlab/issue_templates/Change Request.md index 995e7ad1..f767ee15 100644 --- a/.gitlab/issue_templates/Change Request.md +++ b/.gitlab/issue_templates/Change Request.md @@ -1,13 +1,14 @@ ## Summary -*Outline the issue being faced, and why this needs to change* + ## Area of the system -*This might only be one part, but may involve multiple sections, Login/Dashboad/Terminal/Config* + ## How does this currently work? + ## What is the desired way of working? -*After the change, what should the process/operation be?* + ## Priority/Severity - [ ] High (This will bring a huge increase in performance/productivity/usability) diff --git a/.gitlab/issue_templates/Feature Request.md b/.gitlab/issue_templates/Feature Request.md index 2450aa60..b26067d6 100644 --- a/.gitlab/issue_templates/Feature Request.md +++ b/.gitlab/issue_templates/Feature Request.md @@ -1,8 +1,8 @@ ## Problem Statement -*What is the issue being faced and needs addressing?* + ## Who will benefit? -*Will this fix a problem that only one user has, or will it benefit a lot of people* + ## Benefits and risks What benefits does this bring? @@ -16,10 +16,10 @@ ## Proposed solution -*How would you like to see this issue resolved?* + ## Examples -*Are there any examples of this which exist in other software?* + ## Priority/Severity - [ ] High (This will bring a huge increase in performance/productivity/usability) diff --git a/.gitlab/merge_request_templates/Default.md b/.gitlab/merge_request_templates/Default.md index a82cb3f8..70bcd7db 100644 --- a/.gitlab/merge_request_templates/Default.md +++ b/.gitlab/merge_request_templates/Default.md @@ -1,22 +1,22 @@ ## What does this MR do and why? -___Describe in detail what your merge request does and why.___
-> *Please keep this description updated with any discussion that takes place so*
-*that reviewers can understand your intent. Keeping the description updated is*
-*especially important if they didn't participate in the discussion.*
+ + + + ## Screenshots or screen recordings -___These are strongly recommended to assist reviewers and reduce the time to merge your change.___
-> *Please include any relevant screenshots or screen recordings that will assist*
-*reviewers and future readers. If you need help visually verifying the change,*
-*please leave a comment and ping a GitLab reviewer, maintainer, or MR coach.*
+ + + + ## How to set up and validate locally -___Numbered steps to set up and validate the change are strongly suggested.___ + ## MR acceptance checklist From d03fa57d0b949d0aa5e4b55165f7a7a3b1fdf1de Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sun, 7 Apr 2024 00:07:28 +0100 Subject: [PATCH 45/48] Update changelog !745 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7535061..ac3d0608 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ TBD - Fix backend issue causing error when cloning servers in 4.3.x ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/741)) - Bump orjson for CVE-2024-27454 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/747)) - Fix calling of orjson JSONDecodeError class ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/747)) +- Fix stack on Crafty permissions route request in API ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/745)) ### Tweaks - Clean up remaining http handler references ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/733)) - Remove version disclosure on login page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/737)) From 3c7c05b4052b0126473f35f13dc5ec01de41a93f Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sun, 7 Apr 2024 00:17:16 +0100 Subject: [PATCH 46/48] Close changelog v4.3.2 --- CHANGELOG.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac3d0608..aae03620 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,5 @@ # Changelog -## --- [4.3.2] - 2024/TBD -### New features -TBD +## --- [4.3.2] - 2024/04/07 ### Refactor - Refactor ServerJars caching and move to api.serverjars.com ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/744) | [Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/746)) ### Bug fixes From 77b0c2c9d2eac124a7504a3d3916fa22d29fa9d1 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sun, 7 Apr 2024 00:36:10 +0100 Subject: [PATCH 47/48] Add openjdk-21 to docker img --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index e8bdb102..d05cf3d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,6 +25,7 @@ RUN apt-get update \ openjdk-8-jre-headless \ openjdk-11-jre-headless \ openjdk-17-jre-headless \ + openjdk-21-jre-headless \ tzdata \ && apt-get autoremove \ && apt-get clean From 56d098ef861cd3f3e1d3fcaa6a37f34bd125f3db Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sun, 7 Apr 2024 01:04:56 +0100 Subject: [PATCH 48/48] Update changelog 3c7c05b4 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aae03620..145d869b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ ### Tweaks - Clean up remaining http handler references ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/733)) - Remove version disclosure on login page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/737)) +- Add openjdk-21 for recent versions of MC ([Commit](https://gitlab.com/crafty-controller/crafty-4/-/commit/77b0c2c9d2eac124a7504a3d3916fa22d29fa9d1)) ### Lang - Update `it_IT, cs_CS` ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/739) | [Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/742))