From a1e8b7afe71d690a049cb5f451687a6b9db61af3 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 17 Dec 2022 12:21:15 -0500 Subject: [PATCH 01/11] Make server directories non-configurable --- app/classes/web/panel_handler.py | 14 +++++++++----- app/classes/web/routes/api/servers/server/index.py | 3 ++- app/frontend/templates/panel/server_config.html | 7 ++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 6c6b398f..322ca807 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -808,9 +808,15 @@ class PanelHandler(BaseHandler): user_roles_list = self.controller.users.get_user_roles_names( user.user_id ) - user_servers = self.controller.servers.get_authorized_servers( - user.user_id - ) + try: + user_servers = self.controller.servers.get_authorized_servers( + user.user_id + ) + except: + return self.redirect( + "/panel/error?error=Cannot load panel config" + " while servers are unloaded" + ) servers = [] for server in user_servers: if server.name not in servers: @@ -1606,7 +1612,6 @@ class PanelHandler(BaseHandler): if Helpers.validate_traversal( self.helper.get_servers_root_dir(), server_path ): - server_obj.path = server_path server_obj.log_path = log_path if Helpers.validate_traversal( self.helper.get_servers_root_dir(), executable @@ -1618,7 +1623,6 @@ class PanelHandler(BaseHandler): server_obj.executable_update_url = executable_update_url server_obj.show_status = show_status else: - server_obj.path = server_obj.path server_obj.log_path = server_obj.log_path server_obj.executable = server_obj.executable server_obj.execution_command = execution_command diff --git a/app/classes/web/routes/api/servers/server/index.py b/app/classes/web/routes/api/servers/server/index.py index 11f8620b..3d5e3e2f 100644 --- a/app/classes/web/routes/api/servers/server/index.py +++ b/app/classes/web/routes/api/servers/server/index.py @@ -90,7 +90,8 @@ class ApiServersServerIndexHandler(BaseApiHandler): server_obj = self.controller.servers.get_server_obj(server_id) for key in data: # If we don't validate the input there could be security issues - setattr(server_obj, key, data[key]) + if key != "path": + setattr(server_obj, key, data[key]) self.controller.servers.update_server(server_obj) self.controller.management.add_to_audit_log( diff --git a/app/frontend/templates/panel/server_config.html b/app/frontend/templates/panel/server_config.html index d0c0d42f..d1310a91 100644 --- a/app/frontend/templates/panel/server_config.html +++ b/app/frontend/templates/panel/server_config.html @@ -62,9 +62,10 @@ - +
+ {{ data['server_stats']['server_id']['path'] }} + 🔒 +
{% if data['server_stats']['server_type'] != "minecraft-bedrock" %} From 76cedc9392bca8af587671577c1644cf0ce3a32b Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Mon, 19 Dec 2022 11:54:24 -0500 Subject: [PATCH 02/11] Fix stats error on mac M1 chips --- app/classes/minecraft/stats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/classes/minecraft/stats.py b/app/classes/minecraft/stats.py index 5ef9550d..e3611509 100644 --- a/app/classes/minecraft/stats.py +++ b/app/classes/minecraft/stats.py @@ -86,7 +86,7 @@ class Stats: def get_node_stats(self) -> NodeStatsReturnDict: try: cpu_freq = psutil.cpu_freq() - except NotImplementedError: + except (NotImplementedError, FileNotFoundError): cpu_freq = None if cpu_freq is None: cpu_freq = psutil._common.scpufreq(current=-1, min=-1, max=-1) From 9004feff370531ce0470063c6bd0cfa0e34c3013 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Mon, 19 Dec 2022 17:44:04 -0500 Subject: [PATCH 03/11] Fix windows slash escape java override --- app/classes/web/panel_handler.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 6c6b398f..90155712 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -1554,7 +1554,10 @@ class PanelHandler(BaseHandler): return if java_selection: try: - execution_list = shlex.split(execution_command) + if self.helper.is_os_windows(): + execution_list = shlex.split(execution_command, posix=False) + else: + execution_list = shlex.split(execution_command, posix=True) except ValueError: self.redirect( "/panel/error?error=Invalid execution command. Java path" @@ -1589,6 +1592,7 @@ class PanelHandler(BaseHandler): execution_list[0] = "java" execution_command = "" for item in execution_list: + print(item) execution_command += item + " " server_obj: Servers = self.controller.servers.get_server_obj(server_id) From 262ec80db8ebd8b5c9044e6ef71d46a08920304b Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Mon, 19 Dec 2022 17:47:31 -0500 Subject: [PATCH 04/11] Remove print statement --- app/classes/web/panel_handler.py | 1 - 1 file changed, 1 deletion(-) diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 90155712..8651de40 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -1592,7 +1592,6 @@ class PanelHandler(BaseHandler): execution_list[0] = "java" execution_command = "" for item in execution_list: - print(item) execution_command += item + " " server_obj: Servers = self.controller.servers.get_server_obj(server_id) From 0bd4dd7e69089f35c156403ea511e5f08be2bfba Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 19 Dec 2022 18:42:05 -0500 Subject: [PATCH 05/11] Add popover to server port to explain it's purpose --- app/frontend/static/assets/css/dark/style.css | 2 +- .../templates/panel/server_config.html | 21 ++++++++++++++++++- app/translations/en_EN.json | 4 +++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/frontend/static/assets/css/dark/style.css b/app/frontend/static/assets/css/dark/style.css index dbd6ea8b..c8ac5eb9 100755 --- a/app/frontend/static/assets/css/dark/style.css +++ b/app/frontend/static/assets/css/dark/style.css @@ -22155,7 +22155,7 @@ ul li { } .popover .popover-body { - color: #000; + color: var(--base-text); background: var(--card-banner-bg); } diff --git a/app/frontend/templates/panel/server_config.html b/app/frontend/templates/panel/server_config.html index d0c0d42f..604cf1dc 100644 --- a/app/frontend/templates/panel/server_config.html +++ b/app/frontend/templates/panel/server_config.html @@ -157,7 +157,6 @@ -
{% end %} @@ -522,6 +527,20 @@ }); } + $("#server_port").focus(function () { + + $('[data-toggle="popover"]').popover(); + if ($(window).width() < 1000) { + $('.port-hint').attr("data-placement", "top") + } else { + $('.port-hint').attr("data-placement", "right") + } + $('.port-hint').popover("show"); + }); + $("#server_port").focusout(function () { + $('.port-hint').popover("hide"); + }); + $(document).ready(function () { webSocket.on('remove_spinner', function () { document.getElementById("update-spinner").style.visibility = "hidden"; diff --git a/app/translations/en_EN.json b/app/translations/en_EN.json index da2a083b..233e4ad0 100644 --- a/app/translations/en_EN.json +++ b/app/translations/en_EN.json @@ -340,7 +340,9 @@ "yesDeleteFiles": "Yes, delete files", "shutdownTimeout": "Shutdown Timeout", "timeoutExplain1": "How long Crafty will wait for your server to shutdown after executing the", - "timeoutExplain2": "command before it forces the process down." + "timeoutExplain2": "command before it forces the process down.", + "statsHint1": "The port your server is running on should go here.", + "statsHint2": "This does not change the port of your server. You must still change the port in your server config file." }, "serverConfigHelp": { "desc": "Here is where you can change the configuration of your server", From 7f629d21e948692f881e2d0d101b5df42e5f2cd6 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 19 Dec 2022 19:42:40 -0500 Subject: [PATCH 06/11] Update translation Make it so warning appears all the time --- app/frontend/templates/panel/server_config.html | 2 -- app/translations/en_EN.json | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/frontend/templates/panel/server_config.html b/app/frontend/templates/panel/server_config.html index 604cf1dc..5100fed5 100644 --- a/app/frontend/templates/panel/server_config.html +++ b/app/frontend/templates/panel/server_config.html @@ -164,12 +164,10 @@ - {% if data['user_data']['hints'] %} - {% end %} {% end %} diff --git a/app/translations/en_EN.json b/app/translations/en_EN.json index 233e4ad0..49271004 100644 --- a/app/translations/en_EN.json +++ b/app/translations/en_EN.json @@ -341,7 +341,7 @@ "shutdownTimeout": "Shutdown Timeout", "timeoutExplain1": "How long Crafty will wait for your server to shutdown after executing the", "timeoutExplain2": "command before it forces the process down.", - "statsHint1": "The port your server is running on should go here.", + "statsHint1": "The port your server is running on should go here. This is just how Crafty opens a connection to your server for stats.", "statsHint2": "This does not change the port of your server. You must still change the port in your server config file." }, "serverConfigHelp": { From ec50a80e1fb6127442c08929210123499e47fe8e Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 19 Dec 2022 19:48:15 -0500 Subject: [PATCH 07/11] Add warning icon --- app/frontend/templates/panel/server_config.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/frontend/templates/panel/server_config.html b/app/frontend/templates/panel/server_config.html index 5100fed5..d406ad08 100644 --- a/app/frontend/templates/panel/server_config.html +++ b/app/frontend/templates/panel/server_config.html @@ -164,10 +164,11 @@ - + translate('serverConfig', 'statsHint1' , data['lang'])}}

{{ translate('serverConfig', 'statsHint2', data['lang'])}}" , + data-placement="right"> {% end %} From 8b5cbad8ab7c51c1bcf8faaba8ec090d785b700b Mon Sep 17 00:00:00 2001 From: Zedifus Date: Wed, 21 Dec 2022 15:51:07 +0000 Subject: [PATCH 08/11] Update changelog !511 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 390dd0fa..242a88e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ TBD - Remove Pathlib from sub path check ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/507)) - Fix root dir selection in Upload Zip Import ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/508)) ### Tweaks -TBD +- Make server directories non-configurable ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/511)) ### Lang TBD

From 15db119572b5a82e6bca9cd4308ad3a5a1ebce79 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Wed, 21 Dec 2022 15:57:34 +0000 Subject: [PATCH 09/11] Update changelog !512 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 242a88e2..b50495ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ TBD - Be sure a user cannot server import crafty dir. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/506)) - Remove Pathlib from sub path check ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/507)) - Fix root dir selection in Upload Zip Import ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/508)) +- Fix stats error on mac M1 chips ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/512)) ### Tweaks - Make server directories non-configurable ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/511)) ### Lang From 6d97a09b621cede9f395821cb19264eb7fb0d9f7 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Wed, 21 Dec 2022 16:05:46 +0000 Subject: [PATCH 10/11] Update changelog !513 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b50495ce..8a3b87b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ TBD - Remove Pathlib from sub path check ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/507)) - Fix root dir selection in Upload Zip Import ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/508)) - Fix stats error on mac M1 chips ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/512)) +- Fix window path escape on java override ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/513)) ### Tweaks - Make server directories non-configurable ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/511)) ### Lang From cf514788b30a8bd4e9e8e8c8dae02f43429493b5 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Wed, 21 Dec 2022 16:12:36 +0000 Subject: [PATCH 11/11] Update changelog !514 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a3b87b8..a61a3c7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ TBD - Fix window path escape on java override ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/513)) ### Tweaks - Make server directories non-configurable ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/511)) +- Add popover to server port to detail it's purpose ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/514)) ### Lang TBD