Merge branch 'dev' into dev-fixed-sidebar-V2

This commit is contained in:
Zedifus 2022-10-06 18:48:57 +01:00
commit 21d119d58e
12 changed files with 66 additions and 13 deletions

View File

@ -4,6 +4,9 @@
TBD
### Bug fixes
- Fix conditional issue with zip imports/uploads ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/476))
- Fix API Schedule updates ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/478))
- Add port constraint for all server creation & api ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/479))
- Clean up backup configs when deleting servers ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/480))
### Tweaks
- Fix sidebar to not move when scrolling ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/481))
### Lang

View File

@ -134,8 +134,13 @@ class ServersController(metaclass=Singleton):
role_id = role.role_id
role_data = RolesController.get_role_with_servers(role_id)
role_data["servers"] = {server_id}
# Remove server id permissions from role
PermissionsServers.delete_roles_permissions(role_id, role_data["servers"])
# Remove roles from server
PermissionsServers.remove_roles_of_server(server_id)
# Remove backup configs tied to server
self.management_helper.remove_backup_config(server_id)
# Finally remove server
self.servers_helper.remove_server(server_id)
@staticmethod

View File

@ -139,7 +139,7 @@ def ping(ip, port):
try:
sock.connect((ip, port))
except socket.error:
except:
return False
try:

View File

@ -367,6 +367,10 @@ class HelpersManagement:
}
return conf
@staticmethod
def remove_backup_config(server_id):
Backups.delete().where(Backups.server_id == server_id).execute()
def set_backup_config(
self,
server_id: int,

View File

@ -420,6 +420,7 @@ class Controller:
and root_create_data["create_type"] == "download_jar"
):
self.server_jars.download_jar(
create_data["category"],
create_data["type"],
create_data["version"],
full_jar_path,

View File

@ -436,7 +436,15 @@ class TasksManager:
and "cron_string" in job_data
and "interval_type" in job_data
):
return
if not "enabled" in job_data:
return
if job_data["enabled"] is True:
job_data = HelpersManagement.get_scheduled_task(sch_id)
job_data["server_id"] = job_data["server_id"]["server_id"]
else:
self.scheduler.remove_job(str(sch_id))
return
try:
if job_data["interval"] != "reaction":

View File

@ -1501,6 +1501,12 @@ class PanelHandler(BaseHandler):
execution_command = self.get_argument("execution_command", None)
server_ip = self.get_argument("server_ip", None)
server_port = self.get_argument("server_port", None)
if int(server_port) < 1 or int(server_port) > 65535:
self.redirect(
"/panel/error?error=Constraint Error: "
"Port must be greater than 0 and less than 65535"
)
return
executable_update_url = self.get_argument("executable_update_url", "")
show_status = int(float(self.get_argument("show_status", "0")))
else:

View File

@ -648,7 +648,7 @@ class ApiServersIndexHandler(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)}
)
@ -664,7 +664,22 @@ class ApiServersIndexHandler(BaseApiHandler):
"error_data": str(e),
},
)
# Check to make sure port is allowable
if data["monitoring_type"] == "minecraft_java":
try:
port = data["minecraft_java_monitoring_data"]["port"]
except:
port = 25565
else:
try:
port = data["minecraft_bedrock_monitoring_data"]["port"]
except:
port = 19132
if port > 65535 or port < 1:
self.finish_json(
405, {"status": "error", "error": "DATA CONSTRAINT FAILED"}
)
return
new_server_id, new_server_uuid = self.controller.create_api_server(
data, user["user_id"]
)

View File

@ -4,7 +4,6 @@ import json
import logging
from jsonschema import ValidationError, validate
from app.classes.models.management import HelpersManagement
from app.classes.models.server_permissions import EnumPermissionsServer
from app.classes.web.base_api_handler import BaseApiHandler
@ -97,7 +96,7 @@ class ApiServersServerTasksTaskIndexHandler(BaseApiHandler):
if str(data.get("parent")) == str(task_id) and data.get("parent") is not None:
data["parent"] = None
HelpersManagement.update_scheduled_task(task_id, data)
self.tasks_manager.update_job(task_id, data)
self.controller.management.add_to_audit_log(
auth_data[4]["user_id"],

View File

@ -311,6 +311,12 @@ class ServerHandler(BaseHandler):
min_mem = bleach.clean(self.get_argument("min_memory", ""))
max_mem = bleach.clean(self.get_argument("max_memory", ""))
port = bleach.clean(self.get_argument("port", ""))
if int(port) < 1 or int(port) > 65535:
self.redirect(
"/panel/error?error=Constraint Error: "
"Port must be greater than 0 and less than 65535"
)
return
import_type = bleach.clean(self.get_argument("create_type", ""))
import_server_path = bleach.clean(self.get_argument("server_path", ""))
import_server_jar = bleach.clean(self.get_argument("server_jar", ""))
@ -451,6 +457,12 @@ class ServerHandler(BaseHandler):
server = bleach.clean(self.get_argument("server", ""))
server_name = bleach.clean(self.get_argument("server_name", ""))
port = bleach.clean(self.get_argument("port", ""))
if int(port) < 1 or int(port) > 65535:
self.redirect(
"/panel/error?error=Constraint Error: "
"Port must be greater than 0 and less than 65535"
)
return
import_type = bleach.clean(self.get_argument("create_type", ""))
import_server_path = bleach.clean(self.get_argument("server_path", ""))
import_server_exe = bleach.clean(self.get_argument("server_jar", ""))

View File

@ -131,7 +131,7 @@
<label for="port2">{{ translate('serverWizard', 'serverPort', data['lang']) }}
<small></small></label>
<input type="number" class="form-control" id="port2" name="port" value="19132" step="1" min="1"
required>
max="65535" required>
</div>
</div>
<div class="col-sm-12">
@ -241,7 +241,7 @@
<label for="port3">{{ translate('serverWizard', 'serverPort', data['lang']) }}
<small></small></label>
<input type="number" class="form-control" id="port3" name="port" value="19132" step="1" min="1"
required>
max="65535" required>
</div>
</div>
@ -387,7 +387,7 @@
<label for="port3">{{ translate('serverWizard', 'serverPort', data['lang']) }} <small> - {{
translate('serverWizard', 'defaultPort', data['lang']) }}</small></label>
<input type="number" class="form-control" id="port4" name="port" value="19132" step="1" min="1"
required>
max="65535" required>
</div>
</div>

View File

@ -109,7 +109,7 @@
<label for="port1">{{ translate('serverWizard', 'serverPort', data['lang']) }} <small> - {{
translate('serverWizard', 'defaultPort', data['lang']) }}</small></label>
<input type="number" class="form-control" id="port1" name="port" value="25565" step="1" min="1"
required>
max="65535 " required>
</div>
</div>
<div class="col-sm-12">
@ -224,7 +224,7 @@
<label for="port2">{{ translate('serverWizard', 'serverPort', data['lang']) }} <small> - {{
translate('serverWizard', 'defaultPort', data['lang']) }}</small></label>
<input type="number" class="form-control" id="port2" name="port" value="25565" step="1" min="1"
required>
max="65535" required>
</div>
</div>
<div class="col-sm-12">
@ -351,7 +351,7 @@
<label for="port3">{{ translate('serverWizard', 'serverPort', data['lang']) }} <small> - {{
translate('serverWizard', 'defaultPort', data['lang']) }}</small></label>
<input type="number" class="form-control" id="port3" name="port" value="25565" step="1" min="1"
required>
max="65535" required>
</div>
</div>
@ -515,7 +515,7 @@
<label for="port3">{{ translate('serverWizard', 'serverPort', data['lang']) }} <small> - {{
translate('serverWizard', 'defaultPort', data['lang']) }}</small></label>
<input type="number" class="form-control" id="port3" name="port" value="25565" step="1" min="1"
required>
max="65535" required>
</div>
</div>