Merge branch 'dev' into refactor/server_ids

This commit is contained in:
Silversthorn 2024-02-03 21:12:39 +01:00
commit 2eb0eb59ef
32 changed files with 223 additions and 122 deletions

View File

@ -51,6 +51,10 @@ pylint:
- if: "$CODE_QUALITY_DISABLED" - if: "$CODE_QUALITY_DISABLED"
when: never when: never
- if: "$CI_COMMIT_TAG || $CI_COMMIT_BRANCH" - if: "$CI_COMMIT_TAG || $CI_COMMIT_BRANCH"
before_script:
- apk update
- apk add gcc python3-dev linux-headers build-base
- pip3 install --no-cache-dir -r requirements.txt
script: script:
- pylint --exit-zero --load-plugins=pylint_gitlab --output-format=gitlab-codeclimate:codeclimate.json $(find -type f -name "*.py" ! -path "**/.venv/**" ! -path "**/app/migrations/**") - pylint --exit-zero --load-plugins=pylint_gitlab --output-format=gitlab-codeclimate:codeclimate.json $(find -type f -name "*.py" ! -path "**/.venv/**" ! -path "**/app/migrations/**")
artifacts: artifacts:

View File

@ -1,12 +1,24 @@
# Changelog # Changelog
## --- [4.2.3] - 2023/TBD ## --- [4.2.4] - 2023/TBD
### New features
TBD
### Bug fixes
TBD
### Tweaks
TBD
### Lang
TBD
<br><br>
## --- [4.2.3] - 2023/02/02
### New features ### New features
- Use Papermc Group's API for `paper` & `folia` builds in server builder ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/688)) - Use Papermc Group's API for `paper` & `folia` builds in server builder ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/688))
- Allow omission of player count from Dashboard (e.g. for proxy servers) ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/692)) - Allow omission of player count from Dashboard (e.g. for proxy servers) ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/692))
- Add lockout user for forgot password ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/694)) - Add lockout user for forgot password ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/694) | [Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/706))
### Refactor ### Refactor
- Refactor subpage perm checks ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/695)) - Refactor subpage perm checks ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/695))
### Bug fixes ### Bug fixes
- [`CVE-2024-1064`] Security-related fix to resolve an issue with the HTTP listener ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/704))
- Fix bukkit and downstream fork MOTD crash ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/686)) - Fix bukkit and downstream fork MOTD crash ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/686))
- Fix bug where invalid server Id leads to stack ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/690)) - Fix bug where invalid server Id leads to stack ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/690))
- Fix indent on public status check box ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/691)) - Fix indent on public status check box ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/691))
@ -17,6 +29,10 @@
- Refactor Forge server initialisation flow for newer versions ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/687)) - Refactor Forge server initialisation flow for newer versions ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/687))
- Remove scroll bars from player management ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/693)) - Remove scroll bars from player management ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/693))
- Add warning to wizard for unsupported mc ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/701)) - Add warning to wizard for unsupported mc ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/701))
- Improve display for `th-TH` characters ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/703))
- Improve display of white text on **wssErrors** ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/703) | [50e65f6](https://gitlab.com/crafty-controller/crafty-4/-/commit/50e65f65318b12b904442aca7bc474c0b36b97af))
- Improve display of white text on **Buttons** ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/703))
- Fix dashboard motd issue #322 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/705))
### Lang ### Lang
- Update `zh_CN, pl_PL, nl_BE, lv_LV, he_IL, fr_FR, de_DE, lol_EN` translations for `4.2.3` ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/696)) - Update `zh_CN, pl_PL, nl_BE, lv_LV, he_IL, fr_FR, de_DE, lol_EN` translations for `4.2.3` ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/696))
- New `uk_UA, tr_TR, th_TH` translations for `4.2.3` ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/696)) - New `uk_UA, tr_TR, th_TH` translations for `4.2.3` ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/696))

View File

@ -1,5 +1,5 @@
[![Crafty Logo](app/frontend/static/assets/images/logo_long.svg)](https://craftycontrol.com) [![Crafty Logo](app/frontend/static/assets/images/logo_long.svg)](https://craftycontrol.com)
# Crafty Controller 4.2.3 # Crafty Controller 4.2.4
> Python based Control Panel for your Minecraft Server > Python based Control Panel for your Minecraft Server
## What is Crafty Controller? ## What is Crafty Controller?

View File

@ -90,18 +90,51 @@ class Controller:
def log_attempt(self, remote_ip, username): def log_attempt(self, remote_ip, username):
remote = self.auth_tracker.get(str(remote_ip), None) remote = self.auth_tracker.get(str(remote_ip), None)
if remote: if not remote:
remote["names"].append(username) self.auth_tracker[str(remote_ip)] = {
remote["attempts"] += 1 "login": {
remote["times"].append(datetime.now().strftime("%d/%m/%Y %H:%M:%S")) "names": [username],
"attempts": 1,
"times": [datetime.now().strftime("%d/%m/%Y %H:%M:%S")],
}
}
return
if remote.get("login", None):
remote["login"]["names"].append(username)
remote["login"]["attempts"] += 1
remote["login"]["times"].append(
datetime.now().strftime("%d/%m/%Y %H:%M:%S")
)
self.auth_tracker[str(remote_ip)] = remote self.auth_tracker[str(remote_ip)] = remote
else: else:
self.auth_tracker[str(remote_ip)] = { self.auth_tracker[str(remote_ip)]["login"] = {
"names": [username], "names": [username],
"attempts": 1, "attempts": 1,
"times": [datetime.now().strftime("%d/%m/%Y %H:%M:%S")], "times": [datetime.now().strftime("%d/%m/%Y %H:%M:%S")],
} }
def log_antilockout(self, remote_ip):
remote = self.auth_tracker.get(str(remote_ip), None)
if not remote:
self.auth_tracker[str(remote_ip)] = {
"anti-lockout": {
"attempts": 1,
"times": [datetime.now().strftime("%d/%m/%Y %H:%M:%S")],
}
}
return
if remote.get("anti-lockout", None):
remote["anti-lockout"]["attempts"] += 1
remote["anti-lockout"]["times"].append(
datetime.now().strftime("%d/%m/%Y %H:%M:%S")
)
self.auth_tracker[str(remote_ip)] = remote
else:
self.auth_tracker[str(remote_ip)]["anti-lockout"] = {
"attempts": 1,
"times": [datetime.now().strftime("%d/%m/%Y %H:%M:%S")],
}
def write_auth_tracker(self): def write_auth_tracker(self):
with open( with open(
os.path.join(os.path.curdir, "logs", "auth_tracker.log"), os.path.join(os.path.curdir, "logs", "auth_tracker.log"),

View File

@ -106,7 +106,7 @@ class BaseHandler(tornado.web.RequestHandler):
if type(text) in self.nobleach: if type(text) in self.nobleach:
logger.debug("Auto-bleaching - bypass type") logger.debug("Auto-bleaching - bypass type")
return text return text
return nh3.clean(text) return nh3.clean(text) # pylint: disable=no-member
def get_argument( def get_argument(
self, self,

View File

@ -17,7 +17,7 @@ class HTTPHandler(BaseHandler):
url = "https://" + url url = "https://" + url
db_port = self.helper.get_setting("https_port") db_port = self.helper.get_setting("https_port")
try: try:
resp = requests.get(url + ":" + str(port)) resp = requests.head(url + ":" + str(port), timeout=(0.5, 5))
resp.raise_for_status() resp.raise_for_status()
except Exception: except Exception:
port = db_port port = db_port
@ -35,7 +35,7 @@ class HTTPHandlerPage(BaseHandler):
url = "https://" + url url = "https://" + url
db_port = self.helper.get_setting("https_port") db_port = self.helper.get_setting("https_port")
try: try:
resp = requests.get(url + ":" + str(port)) resp = requests.head(url + ":" + str(port), timeout=(0.5, 5))
resp.raise_for_status() resp.raise_for_status()
except Exception: except Exception:
port = db_port port = db_port

View File

@ -25,7 +25,7 @@ class HTTPHandlerPage(BaseHandler):
backup_url = url + str(self.helper.get_setting("https_port")) backup_url = url + str(self.helper.get_setting("https_port"))
try: try:
resp = requests.get(primary_url) resp = requests.head(primary_url, timeout=(0.5, 5))
resp.raise_for_status() resp.raise_for_status()
url = primary_url url = primary_url
except Exception: except Exception:

View File

@ -80,6 +80,7 @@ class PanelHandler(BaseHandler):
) in self.controller.crafty_perms.list_defined_crafty_permissions(): ) in self.controller.crafty_perms.list_defined_crafty_permissions():
argument = int( argument = int(
float( float(
# pylint: disable=no-member
nh3.clean(self.get_argument(f"permission_{permission.name}", "0")) nh3.clean(self.get_argument(f"permission_{permission.name}", "0"))
) )
) )
@ -89,7 +90,10 @@ class PanelHandler(BaseHandler):
) )
q_argument = int( q_argument = int(
float(nh3.clean(self.get_argument(f"quantity_{permission.name}", "0"))) float(
# pylint: disable=no-member
nh3.clean(self.get_argument(f"quantity_{permission.name}", "0"))
)
) )
if q_argument: if q_argument:
server_quantity[permission.name] = q_argument server_quantity[permission.name] = q_argument
@ -503,7 +507,9 @@ class PanelHandler(BaseHandler):
template = "panel/dashboard.html" template = "panel/dashboard.html"
elif page == "server_detail": elif page == "server_detail":
# pylint: disable=no-member
subpage = nh3.clean(self.get_argument("subpage", "")) subpage = nh3.clean(self.get_argument("subpage", ""))
# pylint: enable=no-member
server_id = self.check_server_id() server_id = self.check_server_id()
# load page the user was on last # load page the user was on last
@ -1362,7 +1368,9 @@ class PanelHandler(BaseHandler):
template = "panel/panel_edit_user_apikeys.html" template = "panel/panel_edit_user_apikeys.html"
elif page == "remove_user": elif page == "remove_user":
# pylint: disable=no-member
user_id = nh3.clean(self.get_argument("id", None)) user_id = nh3.clean(self.get_argument("id", None))
# pylint: enable=no-member
if ( if (
not superuser not superuser

View File

@ -29,8 +29,10 @@ class PublicHandler(BaseHandler):
# self.clear_cookie("user_data") # self.clear_cookie("user_data")
def get(self, page=None): def get(self, page=None):
# pylint: disable=no-member
error = nh3.clean(self.get_argument("error", "Invalid Login!")) error = nh3.clean(self.get_argument("error", "Invalid Login!"))
error_msg = nh3.clean(self.get_argument("error_msg", "")) error_msg = nh3.clean(self.get_argument("error_msg", ""))
# pylint: enable=no-member
page_data = { page_data = {
"version": self.helper.get_version_string(), "version": self.helper.get_version_string(),
@ -87,8 +89,10 @@ class PublicHandler(BaseHandler):
) )
def post(self, page=None): def post(self, page=None):
# pylint: disable=no-member
error = nh3.clean(self.get_argument("error", "Invalid Login!")) error = nh3.clean(self.get_argument("error", "Invalid Login!"))
error_msg = nh3.clean(self.get_argument("error_msg", "")) error_msg = nh3.clean(self.get_argument("error_msg", ""))
# pylint: enable=no-member
page_data = { page_data = {
"version": self.helper.get_version_string(), "version": self.helper.get_version_string(),
@ -108,10 +112,11 @@ class PublicHandler(BaseHandler):
if self.request.query: if self.request.query:
next_page = "/login?" + self.request.query next_page = "/login?" + self.request.query
# pylint: disable=no-member
entered_username = nh3.clean(self.get_argument("username")) entered_username = nh3.clean(self.get_argument("username"))
entered_password = self.get_argument("password") entered_password = self.get_argument("password")
# pylint: enable=no-member
# pylint: disable=no-member
try: try:
user_id = HelperUsers.get_user_id_by_name(entered_username.lower()) user_id = HelperUsers.get_user_id_by_name(entered_username.lower())
user_data = HelperUsers.get_user_model(user_id) user_data = HelperUsers.get_user_model(user_id)

View File

@ -2,10 +2,14 @@ import logging
from app.classes.web.base_api_handler import BaseApiHandler from app.classes.web.base_api_handler import BaseApiHandler
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
auth_log = logging.getLogger("auth")
class ApiCraftyLockoutHandler(BaseApiHandler): class ApiCraftyLockoutHandler(BaseApiHandler):
def get(self): def get(self):
auth_log.warning(f"Anti-Lockout request from {self.get_remote_ip()}")
self.controller.log_antilockout(self.get_remote_ip())
if self.controller.users.get_id_by_name("anti-lockout-user"): if self.controller.users.get_id_by_name("anti-lockout-user"):
return self.finish_json( return self.finish_json(
425, {"status": "error", "data": "Lockout recovery already in progress"} 425, {"status": "error", "data": "Lockout recovery already in progress"}

View File

@ -86,6 +86,9 @@ class ServerHandler(BaseHandler):
template = "public/404.html" template = "public/404.html"
if exec_user["username"] == "anti-lockout-user":
return self.redirect("/panel/panel_config")
page_data = { page_data = {
"update_available": self.helper.update_available, "update_available": self.helper.update_available,
"version_data": self.helper.get_version_string(), "version_data": self.helper.get_version_string(),

View File

@ -112,7 +112,7 @@ class Webserver:
cookie_secret = self.helper.random_string_generator(32) cookie_secret = self.helper.random_string_generator(32)
HelpersManagement.set_cookie_secret(cookie_secret) HelpersManagement.set_cookie_secret(cookie_secret)
if not http_port: if not http_port and http_port != 0:
http_port = 8000 http_port = 8000
if not https_port: if not https_port:
@ -191,8 +191,11 @@ class Webserver:
serve_traceback=debug_errors, serve_traceback=debug_errors,
) )
self.http_server = tornado.httpserver.HTTPServer(http_app) if http_port != 0:
self.http_server.listen(http_port) self.http_server = tornado.httpserver.HTTPServer(http_app)
self.http_server.listen(http_port)
else:
logger.info("http port disabled by config")
self.https_server = tornado.httpserver.HTTPServer(app, ssl_options=cert_objects) self.https_server = tornado.httpserver.HTTPServer(app, ssl_options=cert_objects)
self.https_server.listen(https_port) self.https_server.listen(https_port)

View File

@ -1,5 +1,5 @@
{ {
"major": 4, "major": 4,
"minor": 2, "minor": 2,
"sub": 3 "sub": 4
} }

View File

@ -37,16 +37,16 @@ nav.sidebar {
width: 10px; width: 10px;
height: 10px; height: 10px;
border-radius: 100%; border-radius: 100%;
border: 2px solid #fff; border: 2px solid var(--white);
display: block; display: block;
} }
.toggle-handle { .toggle-handle {
background-color: white !important; background-color: var(--white) !important;
} }
.toggle-on { .toggle-on {
color: black !important; color: var(--dark) !important;
} }
.toggle { .toggle {
@ -61,7 +61,7 @@ nav.sidebar {
width: 10px; width: 10px;
height: 10px; height: 10px;
border-radius: 100%; border-radius: 100%;
border: 2px solid #fff; border: 2px solid var(--white);
display: block; display: block;
} }
@ -95,7 +95,7 @@ nav.sidebar {
} }
.scrollable-element { .scrollable-element {
scrollbar-color: red yellow; scrollbar-color: var(--red) var(--yellow);
} }
.term-nav-item { .term-nav-item {
@ -212,6 +212,14 @@ div>.input-group>.form-control {
top: calc(-0.125rem + 1px); top: calc(-0.125rem + 1px);
} }
a.btn-primary {
color: var(--white);
}
button.btn-primary {
color: var(--white);
}
/**************************************************************/ /**************************************************************/
/**************************************************************/ /**************************************************************/
@ -233,4 +241,30 @@ td.action .btn {
margin-bottom: 0.2rem; margin-bottom: 0.2rem;
} }
/**************************************************************/
/**************************************************************/
/* CSS for warnings Displays */
/**************************************************************/
div.warnings div.wssError {
color: var(--white);
}
div.warnings div.wssError a {
color: var(--outline);
}
div.warnings div.wssError a:hover {
color: var(--white-smoke);
}
/**************************************************************/
/**************************************************************/
/* CSS for Fonts Displays */
/**************************************************************/
*:lang(th-TH) :not(.fa, .fas, .fab, .fa-solid) {
font-family: 'Sarabun', 'roboto', sans-serif;
}
/**************************************************************/ /**************************************************************/

View File

@ -96,7 +96,7 @@ function initParser(input, output) {
var input = document.getElementById(input), var input = document.getElementById(input),
output = document.getElementById(output); output = document.getElementById(output);
if (input != null && output != null) { if (input != null && output != null) {
var parsed = parseStyle(input.innerHTML); var parsed = parseStyle(input.innerText);
output.innerHTML = ''; output.innerHTML = '';
output.appendChild(parsed); output.appendChild(parsed);
} }

View File

@ -14,6 +14,7 @@
<link rel="stylesheet" href="/static/assets/vendors/ti-icons/css/themify-icons.css"> <link rel="stylesheet" href="/static/assets/vendors/ti-icons/css/themify-icons.css">
<link rel="stylesheet" href="/static/assets/vendors/typicons/typicons.css"> <link rel="stylesheet" href="/static/assets/vendors/typicons/typicons.css">
<link rel="stylesheet" href="/static/assets/vendors/fontawesome6/css/all.css"> <link rel="stylesheet" href="/static/assets/vendors/fontawesome6/css/all.css">
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Sarabun" media="screen">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/dt-1.10.22/fh-3.1.7/r-2.2.6/sc-2.0.3/sp-1.2.2/datatables.min.css" /> <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/dt-1.10.22/fh-3.1.7/r-2.2.6/sc-2.0.3/sp-1.2.2/datatables.min.css" />
<link rel="stylesheet" href="/static/assets/vendors/css/vendor.bundle.base.css"> <link rel="stylesheet" href="/static/assets/vendors/css/vendor.bundle.base.css">
<link rel="stylesheet" href="/static/assets/css/crafty.css"> <link rel="stylesheet" href="/static/assets/css/crafty.css">
@ -53,7 +54,6 @@
<script src="../static/assets/vendors/js/chart.min.js"></script> <script src="../static/assets/vendors/js/chart.min.js"></script>
<script src="../static/assets/vendors/js/hammer.min.js"></script> <script src="../static/assets/vendors/js/hammer.min.js"></script>
<script src="../static/assets/vendors/js/chartjs-plugin-zoom.min.js"></script> <script src="../static/assets/vendors/js/chartjs-plugin-zoom.min.js"></script>
<!-- End Bootstrap Toggle --> <!-- End Bootstrap Toggle -->
</head> </head>
@ -395,7 +395,7 @@
} }
}, },
callback: function (result) { callback: function (result) {
if (result){ if (result) {
location.href = "/panel/download_support_package"; location.href = "/panel/download_support_package";
} else { } else {
bootbox.close(); bootbox.close();
@ -490,7 +490,7 @@
let linkEl = document.createElement('a') let linkEl = document.createElement('a')
linkEl.href = link; linkEl.href = link;
linkEl.innerHTML = link_msg; linkEl.innerHTML = link_msg;
linkEl.style.color = 'white'; //linkEl.style.color = 'white';
linkEl.style.textDecoration = 'underline'; linkEl.style.textDecoration = 'underline';
linkEl.target = "_blank"; linkEl.target = "_blank";
@ -586,7 +586,7 @@
'⚠You are in a recovery account. Access is limited!', '⚠You are in a recovery account. Access is limited!',
link='/logout', link='/logout',
link_msg="Click here to log out after you change your password. ⚠️", link_msg="Click here to log out after you change your password. ⚠️",
className='anti-lockout', className='anti-lockout',
bg_color='#6887dc' bg_color='#6887dc'
) )
} }

View File

@ -287,8 +287,7 @@
data['lang']) }} <br /> data['lang']) }} <br />
{% if server['stats']['desc'] != 'False' %} {% if server['stats']['desc'] != 'False' %}
<div id="desc_id" style="overflow-wrap: break-word !important; max-width: 85px !important; overflow: scroll;">{{ <div id="desc_id" style="overflow-wrap: break-word !important; max-width: 85px !important; overflow: scroll;">{{ translate('serverStats', 'loadingMotd', data['lang']) }}</div> <br />
server['stats']['desc'] }}</div> <br />
{% end %} {% end %}
{% if server['stats']['version'] != 'False' %} {% if server['stats']['version'] != 'False' %}
@ -554,6 +553,7 @@
display: none; display: none;
/* for Chrome, Safari, and Opera */ /* for Chrome, Safari, and Opera */
} }
.gray { .gray {
color: gray !important; color: gray !important;
} }
@ -736,11 +736,11 @@
try { try {
console.log(`#server_desc_${server.getAttribute("data-serverId")}`) console.log(`#server_desc_${server.getAttribute("data-serverId")}`)
$(`#server_desc_${server.getAttribute("data-serverId")}`).toggleClass("gray", server.getAttribute('data-count') === 'false') $(`#server_desc_${server.getAttribute("data-serverId")}`).toggleClass("gray", server.getAttribute('data-count') === 'false')
if (server.getAttribute('data-count') === 'true'){ if (server.getAttribute('data-count') === 'true') {
all_total_players += parseInt(server.getAttribute('data-players')); all_total_players += parseInt(server.getAttribute('data-players'));
all_total_max_players += parseInt(server.getAttribute('data-max')); all_total_max_players += parseInt(server.getAttribute('data-max'));
} }
} catch { } catch {
console.log("Player totals are not of type int"); console.log("Player totals are not of type int");
} }
}) })
@ -1006,24 +1006,24 @@
async function sendOrder(id_string) { async function sendOrder(id_string) {
const token = getCookie("_xsrf") const token = getCookie("_xsrf")
let res = await fetch(`/api/v2/users/@me`, { let res = await fetch(`/api/v2/users/@me`, {
method: 'PATCH', method: 'PATCH',
headers: { headers: {
'X-XSRFToken': token 'X-XSRFToken': token
}, },
body: JSON.stringify({ body: JSON.stringify({
server_order: id_string, server_order: id_string,
}), }),
});
let responseData = await res.json();
if (responseData.status === "ok") {
return
} else {
bootbox.alert({
title: responseData.status,
message: responseData.error
}); });
} let responseData = await res.json();
if (responseData.status === "ok") {
return
} else {
bootbox.alert({
title: responseData.status,
message: responseData.error
});
}
} }
// Inits the sortable // Inits the sortable
$("table#servers_table tbody") $("table#servers_table tbody")

View File

@ -5,42 +5,27 @@
<div class="row"> <div class="row">
<div class="col-sm-4 mr-2"> <div class="col-sm-4 mr-2">
{% if data['server_stats']['running'] %} {% if data['server_stats']['running'] %}
<b>{{ translate('serverStats', 'serverStatus', data['lang']) }}:</b> <span id="status" <b>{{ translate('serverStats', 'serverStatus', data['lang']) }}:</b> <span id="status" class="text-success">{{ translate('serverStats', 'online', data['lang']) }}</span><br />
class="text-success">{{ translate('serverStats', 'online', data['lang']) }}</span><br /> <b>{{ translate('serverStats', 'serverStarted', data['lang']) }}:</b> <span id="started">{{ data['server_stats']['started'] }}</span><br />
<b>{{ translate('serverStats', 'serverStarted', data['lang']) }}:</b> <span id="started">{{ <b>{{ translate('serverStats', 'serverUptime', data['lang']) }}:</b> <span id="uptime">{{ translate('serverStats', 'errorCalculatingUptime', data['lang']) }}</span>
data['server_stats']['started'] }}</span><br />
<b>{{ translate('serverStats', 'serverUptime', data['lang']) }}:</b> <span id="uptime">{{
translate('serverStats', 'errorCalculatingUptime', data['lang']) }}</span>
{% elif data['server_stats']['crashed'] %} {% elif data['server_stats']['crashed'] %}
<b>{{ translate('serverStats', 'serverStatus', data['lang']) }}:</b> <span id="status" class="text-danger"> <b>{{ translate('serverStats', 'serverStatus', data['lang']) }}:</b> <span id="status" class="text-danger"> <i class="fas fa-exclamation-triangle"></i> {{ translate('dashboard', 'crashed', data['lang']) }}</span><br />
<i class="fas fa-exclamation-triangle"></i> {{ translate('dashboard', 'crashed', data['lang']) <b>{{ translate('serverStats', 'serverStarted', data['lang']) }}:</b> <span id="started" class="text-danger"> <i class="fas fa-exclamation-triangle"></i> {{ translate('dashboard', 'crashed',data['lang']) }}</span><br />
}}</span><br /> <b>{{ translate('serverStats', 'serverUptime', data['lang']) }}:</b> <span id="uptime" class="text-danger"> <i class="fas fa-exclamation-triangle"></i> {{ translate('dashboard', 'crashed', data['lang']) }}</span>
<b>{{ translate('serverStats', 'serverStarted', data['lang']) }}:</b> <span id="started"
class="text-danger"> <i class="fas fa-exclamation-triangle"></i> {{ translate('dashboard', 'crashed',
data['lang']) }}</span><br />
<b>{{ translate('serverStats', 'serverUptime', data['lang']) }}:</b> <span id="uptime" class="text-danger">
<i class="fas fa-exclamation-triangle"></i> {{ translate('dashboard', 'crashed', data['lang']) }}</span>
{% else %} {% else %}
<b>{{ translate('serverStats', 'serverStatus', data['lang']) }}:</b> <span id="status" <b>{{ translate('serverStats', 'serverStatus', data['lang']) }}:</b> <span id="status" class="text-warning">{{ translate('serverStats', 'offline', data['lang']) }}</span><br />
class="text-warning">{{ translate('serverStats', 'offline', data['lang']) }}</span><br /> <b>{{ translate('serverStats', 'serverStarted', data['lang']) }}:</b> <span id="started" class="text-warning">{{ translate('serverStats', 'offline', data['lang']) }}</span><br />
<b>{{ translate('serverStats', 'serverStarted', data['lang']) }}:</b> <span id="started" <b>{{ translate('serverStats', 'serverUptime', data['lang']) }}:</b> <span id="uptime" class="text-warning">{{ translate('serverStats', 'offline', data['lang']) }}</span>
class="text-warning">{{ translate('serverStats', 'offline', data['lang']) }}</span><br />
<b>{{ translate('serverStats', 'serverUptime', data['lang']) }}:</b> <span id="uptime"
class="text-warning">{{ translate('serverStats', 'offline', data['lang']) }}</span>
{% end %} {% end %}
<br> <br>
<b>{{ translate('serverStats', 'serverTimeZone', data['lang']) }}:</b> <span class="text-info">{{ <b>{{ translate('serverStats', 'serverTimeZone', data['lang']) }}:</b> <span class="text-info">{{ data['serverTZ'] }}</span>
data['serverTZ'] }}</span>
</div> </div>
<div class="col-sm-3 mr-2"> <div class="col-sm-3 mr-2">
<b>{{ translate('serverStats', 'cpuUsage', data['lang']) }}:</b> <span id="cpu">{{ <b>{{ translate('serverStats', 'cpuUsage', data['lang']) }}:</b> <span id="cpu">{{ data['server_stats']['cpu'] }}%</span> <br />
data['server_stats']['cpu'] }}%</span> <br /> <b>{{ translate('serverStats', 'memUsage', data['lang']) }}:</b> <span id="mem">{{ data['server_stats']['mem'] }}</span> <br />
<b>{{ translate('serverStats', 'memUsage', data['lang']) }}:</b> <span id="mem">{{
data['server_stats']['mem'] }}</span> <br />
{% if data['server_stats']['int_ping_results'] %} {% if data['server_stats']['int_ping_results'] %}
<b>{{ translate('serverStats', 'players', data['lang']) }}:</b> <span id="players">{{ <b>{{ translate('serverStats', 'players', data['lang']) }}:</b> <span id="players">{{ data['server_stats']['online'] }} / {{ data['server_stats']['max'] }}</span><br />
data['server_stats']['online'] }} / {{ data['server_stats']['max'] }}</span><br />
{% else %} {% else %}
<b>{{ translate('serverStats', 'players', data['lang']) }}:</b> <span id="players">0/0</span><br /> <b>{{ translate('serverStats', 'players', data['lang']) }}:</b> <span id="players">0/0</span><br />
{% end %} {% end %}
@ -48,17 +33,12 @@
<div class="col-sm-3 mr-2"> <div class="col-sm-3 mr-2">
{% if data['server_stats']['version'] != 'False' %} {% if data['server_stats']['version'] != 'False' %}
<b>{{ translate('serverStats', 'version', data['lang']) }}:</b> <span id="version">{{ <b>{{ translate('serverStats', 'version', data['lang']) }}:</b> <span id="version">{{ data['server_stats']['version'] }}</span><br />
data['server_stats']['version'] }}</span><br /> <b>{{ translate('serverStats', 'description', data['lang']) }}:</b> <span id="input_motd" style="max-width: 10px; max-height: 10px" class="input_motd">{{ translate('serverStats', 'loadingMotd', data['lang']) }}</span>
<b>{{ translate('serverStats', 'description', data['lang']) }}:</b> <span id="input_motd"
style="max-width: 10px; max-height: 10px" class="input_motd">{{ data['server_stats']['desc'] }}</span>
<br /> <br />
{% else %} {% else %}
<b>{{ translate('serverStats', 'version', data['lang']) }}:</b> <span id="version">{{ <b>{{ translate('serverStats', 'version', data['lang']) }}:</b> <span id="version">{{ translate('serverStats', 'unableToConnect', data['lang']) }}</span> <br />
translate('serverStats', 'unableToConnect', data['lang']) }}</span> <br /> <b>{{ translate('serverStats', 'description', data['lang']) }}:</b> <span style="max-width: 10px; max-height: 10px" id="input_motd" class="input_motd">{{ translate('serverStats', 'unableToConnect', data['lang']) }}</span> <br />
<b>{{ translate('serverStats', 'description', data['lang']) }}:</b> <span
style="max-width: 10px; max-height: 10px" id="input_motd" class="input_motd">{{ translate('serverStats',
'unableToConnect', data['lang']) }}</span> <br />
{% end %} {% end %}
<b>Server Type: <span class="text-info">{{data['server_stats']['server_type']}}</span></b> <b>Server Type: <span class="text-info">{{data['server_stats']['server_type']}}</span></b>
@ -229,23 +209,23 @@
initParser('input_motd', 'input_motd'); initParser('input_motd', 'input_motd');
let text = "" let text = ""
let players = server.players_cache; let players = server.players_cache;
for(let i=0; i < players.length; i++){ for (let i = 0; i < players.length; i++) {
text += `<tr id="playerItem-${ players[i]["name"] }" class="playerItem--" style="text-align: center;">`; text += `<tr id="playerItem-${players[i]["name"]}" class="playerItem--" style="text-align: center;">`;
text += `<td class="no-scroll" style="overflow: scroll;"><strong>${players[i]["name"]}</strong></td>`; text += `<td class="no-scroll" style="overflow: scroll;"><strong>${players[i]["name"]}</strong></td>`;
if(players[i]["status"] === "Online"){ if (players[i]["status"] === "Online") {
text += `<td><span class="text-success"><i class="fas fa-signal"></i> ${ players[i]['status'] }</span></td>` text += `<td><span class="text-success"><i class="fas fa-signal"></i> ${players[i]['status']}</span></td>`
}else{ } else {
text += `<td><span class="text-warning"><i class="fa-regular fa-circle-xmark"></i><span class="offline-status">&nbsp;${ players[i]['status'] }</span><span class="conn-break"> Last connection :<br> ${ players[i]['last_seen'] }</span></td>` text += `<td><span class="text-warning"><i class="fa-regular fa-circle-xmark"></i><span class="offline-status">&nbsp;${players[i]['status']}</span><span class="conn-break"> Last connection :<br> ${players[i]['last_seen']}</span></td>`
} }
if(server["running"]){ if (server["running"]) {
text += `<td><button onclick="send_command_to_server('ban ${ players[i]['name'] }')" type="button" class="btn btn-danger controls">Ban</button><br class="mobile-break"><button onclick="send_command_to_server('kick ${ players[i]['name'] }')" type="button" class="btn btn-outline-danger controls">Kick</button><br><button onclick="send_command_to_server('op ${ players[i]['name'] }')" type="button" class="btn btn-warning controls">OP</button><br class="mobile-break"><button onclick="send_command_to_server('deop ${ players[i]['name'] }')" type="button" class="btn btn-outline-warning controls">De-OP</button></td>` text += `<td><button onclick="send_command_to_server('ban ${players[i]['name']}')" type="button" class="btn btn-danger controls">Ban</button><br class="mobile-break"><button onclick="send_command_to_server('kick ${players[i]['name']}')" type="button" class="btn btn-outline-danger controls">Kick</button><br><button onclick="send_command_to_server('op ${players[i]['name']}')" type="button" class="btn btn-warning controls">OP</button><br class="mobile-break"><button onclick="send_command_to_server('deop ${players[i]['name']}')" type="button" class="btn btn-outline-warning controls">De-OP</button></td>`
}else{ } else {
text += `<td><span> Unavailable<br> (Server Offline)</span></td>` text += `<td><span> Unavailable<br> (Server Offline)</span></td>`
} }
} }
$("#player-body").html(text); $("#player-body").html(text);
} }
//used to get cookies from browser - this is part of tornados xsrf protection - it's for extra security //used to get cookies from browser - this is part of tornados xsrf protection - it's for extra security
@ -262,24 +242,24 @@
add_server_name(); add_server_name();
//} //}
}); });
async function add_server_name(){ async function add_server_name() {
let res = await fetch(`/api/v2/servers/${serverId}`, { let res = await fetch(`/api/v2/servers/${serverId}`, {
method: 'GET', method: 'GET',
headers: { headers: {
'X-XSRFToken': token 'X-XSRFToken': token
}, },
}); });
let responseData = await res.json(); let responseData = await res.json();
if (responseData.status === "ok") { if (responseData.status === "ok") {
console.log(responseData) console.log(responseData)
$("#server-name-nav").html(`${responseData.data['server_name']}`) $("#server-name-nav").html(`${responseData.data['server_name']}`)
$("#server-name-nav").show(); $("#server-name-nav").show();
} else { } else {
bootbox.alert({ bootbox.alert({
title: responseData.error, title: responseData.error,
message: responseData.error_data message: responseData.error_data
}); });
} }
} }
</script> </script>

View File

@ -49,7 +49,7 @@
<img src="/static/assets/images/pack.png" alt="icon" style="-webkit-filter:grayscale(100%); filter:grayscale(100%)" /> <img src="/static/assets/images/pack.png" alt="icon" style="-webkit-filter:grayscale(100%); filter:grayscale(100%)" />
</div> </div>
<div class="col-auto"> <div class="col-auto">
<span id="input_motd_{{ server['stats']['server_id']['server_id'] }}" class="input_motd">{{ server['stats']['desc'] }}</span> <span id="input_motd_{{ server['stats']['server_id']['server_id'] }}" class="input_motd">{{ translate('serverStats', 'loadingMotd', data['lang']) }}</span>
</div> </div>
</div> </div>
{% end %} {% end %}
@ -133,8 +133,7 @@
<div class="media-body"> <div class="media-body">
{% if server['stats']['desc'] != 'False' %} {% if server['stats']['desc'] != 'False' %}
<div id="m_server_motd_{{ server['stats']['server_id']['server_id'] }}"> <div id="m_server_motd_{{ server['stats']['server_id']['server_id'] }}">
<span id="m_input_motd_{{ server['stats']['server_id']['server_id'] }}" class="input_motd">{{ <span id="m_input_motd_{{ server['stats']['server_id']['server_id'] }}" class="input_motd">{{ translate('serverStats', 'loadingMotd', data['lang']) }}</span> <br />
server['stats']['desc'] }}</span> <br />
</div> </div>
{% end %} {% end %}
</div> </div>

View File

@ -512,6 +512,7 @@
"cpuUsage": "CPU-Nutzung", "cpuUsage": "CPU-Nutzung",
"description": "Beschreibung", "description": "Beschreibung",
"errorCalculatingUptime": "Fehler bei der Berechnung der Betriebszeit", "errorCalculatingUptime": "Fehler bei der Berechnung der Betriebszeit",
"loadingMotd": "Nachricht des Tages lädt (MOTD)",
"memUsage": "RAM/Speicherverbrauch", "memUsage": "RAM/Speicherverbrauch",
"offline": "Offline", "offline": "Offline",
"online": "Online", "online": "Online",

View File

@ -512,6 +512,7 @@
"cpuUsage": "CPU Usage", "cpuUsage": "CPU Usage",
"description": "Description", "description": "Description",
"errorCalculatingUptime": "Error Calculating Uptime", "errorCalculatingUptime": "Error Calculating Uptime",
"loadingMotd": "Loading MOTD",
"memUsage": "Memory Usage", "memUsage": "Memory Usage",
"offline": "Offline", "offline": "Offline",
"online": "Online", "online": "Online",

View File

@ -512,6 +512,7 @@
"cpuUsage": "Utilisation CPU", "cpuUsage": "Utilisation CPU",
"description": "Description", "description": "Description",
"errorCalculatingUptime": "Erreur de Calcul du Temps de Disponibilité", "errorCalculatingUptime": "Erreur de Calcul du Temps de Disponibilité",
"loadingMotd": "Chargement MOTD",
"memUsage": "Utilisation Mémoire", "memUsage": "Utilisation Mémoire",
"offline": "Hors Ligne", "offline": "Hors Ligne",
"online": "En Ligne", "online": "En Ligne",

View File

@ -512,6 +512,7 @@
"cpuUsage": "שימוש במעבד", "cpuUsage": "שימוש במעבד",
"description": "תיאור", "description": "תיאור",
"errorCalculatingUptime": "שגיאה בחישוב זמן פעולה", "errorCalculatingUptime": "שגיאה בחישוב זמן פעולה",
"loadingMotd": "טוען MOTD",
"memUsage": "שימוש בזיכרון", "memUsage": "שימוש בזיכרון",
"offline": "לא מקוון", "offline": "לא מקוון",
"online": "פועל", "online": "פועל",

View File

@ -512,6 +512,7 @@
"cpuUsage": "CPU USAGE", "cpuUsage": "CPU USAGE",
"description": "DESCRIPSHUN", "description": "DESCRIPSHUN",
"errorCalculatingUptime": "I DUN GOOF'D WEN CALCULATIN TEH TEIM AWAEK!", "errorCalculatingUptime": "I DUN GOOF'D WEN CALCULATIN TEH TEIM AWAEK!",
"loadingMotd": "LOADIN' MEOWSSAGE OF DA DAY",
"memUsage": "HOW HARD IZ THINKIN RN", "memUsage": "HOW HARD IZ THINKIN RN",
"offline": "TURND OFF", "offline": "TURND OFF",
"online": "TURND OAN", "online": "TURND OAN",

View File

@ -513,6 +513,7 @@
"cpuUsage": "CPU Lietojums", "cpuUsage": "CPU Lietojums",
"description": "Apraksts", "description": "Apraksts",
"errorCalculatingUptime": "Kļūda aprēķinot darbības laiku", "errorCalculatingUptime": "Kļūda aprēķinot darbības laiku",
"loadingMotd": "Ielādē MOTD",
"memUsage": "Atmiņas Lietojums", "memUsage": "Atmiņas Lietojums",
"offline": "Offlinā", "offline": "Offlinā",
"online": "Onlinā", "online": "Onlinā",

View File

@ -512,6 +512,7 @@
"cpuUsage": "CPU gebruik", "cpuUsage": "CPU gebruik",
"description": "Beschrijving", "description": "Beschrijving",
"errorCalculatingUptime": "Fout bij berekenen van uptime", "errorCalculatingUptime": "Fout bij berekenen van uptime",
"loadingMotd": "MOTD laden",
"memUsage": "Geheugengebruik", "memUsage": "Geheugengebruik",
"offline": "Offline", "offline": "Offline",
"online": "Online", "online": "Online",

View File

@ -512,6 +512,7 @@
"cpuUsage": "Użycie procesora", "cpuUsage": "Użycie procesora",
"description": "Opis", "description": "Opis",
"errorCalculatingUptime": "Błąd obliczania czasu pracy", "errorCalculatingUptime": "Błąd obliczania czasu pracy",
"loadingMotd": "Wczytywanie MOTD",
"memUsage": "Użycie RAMu", "memUsage": "Użycie RAMu",
"offline": "Wyłączony", "offline": "Wyłączony",
"online": "Włączony", "online": "Włączony",

View File

@ -512,6 +512,7 @@
"cpuUsage": "การใช้งานซีพียู", "cpuUsage": "การใช้งานซีพียู",
"description": "คำอธิบาย", "description": "คำอธิบาย",
"errorCalculatingUptime": "เกิดข้อผิดพลาดในการคำนวณสถานะการออนไลน์", "errorCalculatingUptime": "เกิดข้อผิดพลาดในการคำนวณสถานะการออนไลน์",
"loadingMotd": "กำลังโหลด MOTD",
"memUsage": "การใช้งานหน่วยความจำ", "memUsage": "การใช้งานหน่วยความจำ",
"offline": "ออฟไลน์", "offline": "ออฟไลน์",
"online": "ออนไลน์", "online": "ออนไลน์",

View File

@ -512,6 +512,7 @@
"cpuUsage": "CPU Kullanımı", "cpuUsage": "CPU Kullanımı",
"description": "Açıklama", "description": "Açıklama",
"errorCalculatingUptime": "Çalışma Süresi Hesaplanırken Hata", "errorCalculatingUptime": "Çalışma Süresi Hesaplanırken Hata",
"loadingMotd": "MOTD yükleniyor",
"memUsage": "Bellek Kullanımı", "memUsage": "Bellek Kullanımı",
"offline": "Çevrimdışı", "offline": "Çevrimdışı",
"online": "Çevrimiçi", "online": "Çevrimiçi",

View File

@ -512,6 +512,7 @@
"cpuUsage": "Використання Процесора", "cpuUsage": "Використання Процесора",
"description": "Опис", "description": "Опис",
"errorCalculatingUptime": "Підрахунок помилок аптайму", "errorCalculatingUptime": "Підрахунок помилок аптайму",
"loadingMotd": "Завантаження MOTD",
"memUsage": "Використання ОПЗ", "memUsage": "Використання ОПЗ",
"offline": "Оффлайн", "offline": "Оффлайн",
"online": "Онлайн", "online": "Онлайн",

View File

@ -95,7 +95,7 @@
"lastBackup": "上次:", "lastBackup": "上次:",
"max": "最大", "max": "最大",
"memUsage": "内存使用率", "memUsage": "内存使用率",
"motd": "今日消息MOTD", "motd": "服务器描述MOTD",
"newServer": "创建新服务器", "newServer": "创建新服务器",
"nextBackup": "下次:", "nextBackup": "下次:",
"no-servers": "当前没有服务器。要开始,请点击", "no-servers": "当前没有服务器。要开始,请点击",
@ -512,6 +512,7 @@
"cpuUsage": "CPU 使用率", "cpuUsage": "CPU 使用率",
"description": "简介", "description": "简介",
"errorCalculatingUptime": "计算正常运行时间时发生错误", "errorCalculatingUptime": "计算正常运行时间时发生错误",
"loadingMotd": "正在加载服务器描述MOTD",
"memUsage": "内存使用率", "memUsage": "内存使用率",
"offline": "已停止", "offline": "已停止",
"online": "运行中", "online": "运行中",

View File

@ -3,7 +3,7 @@ sonar.organization=crafty-controller
# This is the name and version displayed in the SonarCloud UI. # This is the name and version displayed in the SonarCloud UI.
sonar.projectName=Crafty 4 sonar.projectName=Crafty 4
sonar.projectVersion=4.2.3 sonar.projectVersion=4.2.4
sonar.python.version=3.9, 3.10, 3.11 sonar.python.version=3.9, 3.10, 3.11
sonar.exclusions=app/migrations/**, app/frontend/static/assets/vendors/** sonar.exclusions=app/migrations/**, app/frontend/static/assets/vendors/**