Merge branch 'dev' into dev-Silversthorn-MVC

This commit is contained in:
Silversthorn 2021-09-25 22:58:01 +02:00
commit e381ebe239
12 changed files with 162 additions and 67 deletions

View File

@ -1 +1,9 @@
docker/
.git/
.gitignore
crafty_commander.exe
DBCHANGES.md
docker-compose.yml.example
README.md

View File

@ -1,51 +1,38 @@
stages:
- buildx
- build-dev
- build-prod
buildx:
image: docker:git
services:
- docker:dind
stage: buildx
rules:
- if: $CI_COMMIT_BRANCH == 'dev'
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables:
GIT_STRATEGY: none
tags:
- docker
artifacts:
paths:
- buildx
expire_in: 1 hour
script:
- export DOCKER_BUILDKIT=1
- git clone git://github.com/docker/buildx ./docker-buildx
- docker build --platform=local -o . ./docker-buildx
- win-dev
- win-prod
- docker-dev
- docker-prod
docker-build-dev:
image: docker:latest
services:
- name: docker:dind
command: ["--experimental"]
stage: build-dev
stage: docker-dev
tags:
- docker
- docker
rules:
- if: $CI_COMMIT_BRANCH == 'dev'
environment:
name: development
before_script:
- mkdir -p ~/.docker/cli-plugins
- mv buildx ~/.docker/cli-plugins/docker-buildx
- |
apk --no-cache add curl
latest_tag=$(curl -s https://api.github.com/repos/docker/buildx/releases/latest | sed -Ene '/^ *"tag_name": *"(v.+)",$/s//\1/p')
echo "Using buildx version $latest_tag"
curl -sSLo docker-buildx "https://github.com/docker/buildx/releases/download/$latest_tag/buildx-$latest_tag.linux-amd64"
chmod a+x docker-buildx
mkdir -p ~/.docker/cli-plugins
mv docker-buildx ~/.docker/cli-plugins/docker-buildx
docker version
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- echo $CI_BUILD_TOKEN | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
script:
- |
tag=":$CI_COMMIT_REF_SLUG"
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
- docker buildx create --use
- docker buildx create --use --name zedBuilder
- docker buildx build
--cache-from type=registry,ref="$CI_REGISTRY_IMAGE${tag}"
--build-arg BUILDKIT_INLINE_CACHE=1
@ -53,30 +40,40 @@ docker-build-dev:
--platform linux/arm64/v8,linux/amd64
--push .
after_script:
- docker buildx imagetools inspect "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
- |
docker buildx rm zedBuilder && echo "Successfully Stopped builder instance" || echo "Failed to stop builder instance."
echo "Please review multi-arch manifests are present:"
docker buildx imagetools inspect "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
docker-build-prod:
image: docker:latest
services:
- name: docker:dind
command: ["--experimental"]
stage: build-prod
stage: docker-prod
tags:
- docker
- docker
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
environment:
name: production
before_script:
- mkdir -p ~/.docker/cli-plugins
- mv buildx ~/.docker/cli-plugins/docker-buildx
- |
apk --no-cache add curl
latest_tag=$(curl -s https://api.github.com/repos/docker/buildx/releases/latest | sed -Ene '/^ *"tag_name": *"(v.+)",$/s//\1/p')
echo "Using buildx version $latest_tag"
curl -sSLo docker-buildx "https://github.com/docker/buildx/releases/download/$latest_tag/buildx-$latest_tag.linux-amd64"
chmod a+x docker-buildx
mkdir -p ~/.docker/cli-plugins
mv docker-buildx ~/.docker/cli-plugins/docker-buildx
docker version
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- echo $CI_BUILD_TOKEN | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
script:
- |
tag=""
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
- docker buildx create --use
- docker buildx create --use --name zedBuilder
- docker buildx build
--cache-from type=registry,ref="$CI_REGISTRY_IMAGE${tag}"
--build-arg BUILDKIT_INLINE_CACHE=1
@ -84,4 +81,75 @@ docker-build-prod:
--platform linux/arm64/v8,linux/amd64
--push .
after_script:
- docker buildx imagetools inspect "$CI_REGISTRY_IMAGE${tag}"
- |
docker buildx rm zedBuilder && echo "Successfully Stopped builder instance" || echo "Failed to stop builder instance."
echo "Please review multi-arch manifests are present:"
docker buildx imagetools inspect "$CI_REGISTRY_IMAGE${tag}"
win-dev-build:
stage: win-dev
tags:
- win64
cache:
paths:
- .venv/
rules:
- if: "$CI_COMMIT_BRANCH == 'dev'"
environment:
name: development
script:
- |
$ErrorActionPreference = "Stop"
py -m venv .venv
.venv\Scripts\activate.ps1
pip install pyinstaller
pip install -r requirements.txt
- pyinstaller -F main.py
--distpath .
--icon app\frontend\static\assets\images\Crafty_4-0_Logo_square.ico
--name "crafty_commander"
--paths .venv\Lib\site-packages
--hidden-import cryptography
--hidden-import cffi
artifacts:
paths:
- app\
- .\crafty_commander.exe
exclude:
- app\classes\**\*
# Download latest:
# | https://gitlab.com/crafty-controller/crafty-commander/-/jobs/artifacts/dev/download?job=win-dev-build
win-prod-build:
stage: win-prod
tags:
- win64
cache:
paths:
- .venv/
rules:
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
environment:
name: production
script:
- |
$ErrorActionPreference = "Stop"
py -m venv .venv
.venv\Scripts\activate.ps1
pip install pyinstaller
pip install -r requirements.txt
- pyinstaller -F main.py
--distpath .
--icon app\frontend\static\assets\images\Crafty_4-0_Logo_square.ico
--name "crafty_commander"
--paths .venv\Lib\site-packages
--hidden-import cryptography
--hidden-import cffi
artifacts:
paths:
- app\
- .\crafty_commander.exe
exclude:
- app\classes\**\*
# Download latest:
# | https://gitlab.com/crafty-controller/crafty-commander/-/jobs/artifacts/master/download?job=win-prod-build

View File

@ -1,6 +1,7 @@
import os
import time
import logging
import json
import sys
import yaml
import asyncio

View File

@ -81,18 +81,22 @@ class Helpers:
try:
requests.get('https://google.com', timeout=1)
return True
except Exception as err:
except Exception as err:
return False
@staticmethod
def check_port(server_port):
host_public = get('https://api.ipify.org').text
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex((host_public ,server_port))
sock.close()
if result == 0:
return True
else:
try:
host_public = get('https://api.ipify.org').text
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(10.0)
result = sock.connect_ex((host_public ,server_port))
sock.close()
if result == 0:
return True
else:
return False
except Exception as err:
return False
def get_setting(self, key, default_return=False):
@ -430,7 +434,7 @@ class Helpers:
sizes = []
for p in paths:
sizes.append({
"path": p,
"path": p,
"size": self.human_readable_file_size(os.stat(p).st_size)
})
return sizes
@ -589,7 +593,7 @@ class Helpers:
@staticmethod
def in_path_old(x, y):
return os.path.abspath(y).__contains__(os.path.abspath(x))
@staticmethod
def copy_files(source, dest):
if os.path.isfile(source):

View File

@ -103,9 +103,6 @@ class Controller:
if s['auto_start']:
db_helper.set_waiting_start(s['server_id'], True)
db_helper.get_waiting_start(s['server_id'])
server_stats = db_helper.get_all_servers_stats()
self.refresh_server_settings(s['server_id'])
console.info("Loaded Server: ID {} | Name: {} | Autostart: {} | Delay: {} ".format(

View File

@ -76,16 +76,6 @@ class PanelHandler(BaseHandler):
}
page_data['super_user'] = exec_user['superuser']
# if no servers defined, let's go to the build server area
if page_data['server_stats']['total'] == 0 and page != "error" and page != "credits" and page != "contribute":
if Enum_Permissions_Crafty.Server_Creation not in exec_user_crafty_permissions and len(defined_servers) == 0:
logger.warning("User '" + exec_user['username'] + "#" + str(exec_user_id) + "' has access to 0 servers and is not a server creator")
else:
self.set_status(301)
self.redirect("/server/step1")
return
if page == 'unauthorized':
template = "panel/denied.html"
@ -129,14 +119,22 @@ class PanelHandler(BaseHandler):
if exec_user['superuser'] == 1:
page_data['servers'] = self.controller.servers.get_all_servers_stats()
for data in page_data['servers']:
data['stats']['waiting_start'] = db_helper.get_waiting_start(int(data['stats']['server_id']['server_id']))
try:
data['stats']['waiting_start'] = self.controller.servers.get_waiting_start(int(data['stats']['server_id']['server_id']))
except:
data['stats']['waiting_start'] = False
else:
user_auth = self.controller.servers.get_authorized_servers_stats(exec_user_id)
logger.debug("ASFR: {}".format(user_auth))
page_data['servers'] = user_auth
for data in page_data['servers']:
try:
data['stats']['waiting_start'] = self.controller.servers.get_waiting_start(int(data['stats']['server_id']['server_id']))
except:
data['stats']['waiting_start'] = False
total_players = 0
for server in db_helper.get_all_defined_servers():
for server in self.controller.servers.get_all_defined_servers():
total_players += len(self.controller.stats.get_server_players(server['server_id']))
page_data['num_players'] = total_players
@ -179,7 +177,10 @@ class PanelHandler(BaseHandler):
# server_data isn't needed since the server_stats also pulls server data
page_data['server_data'] = self.controller.servers.get_server_data_by_id(server_id)
page_data['server_stats'] = self.controller.servers.get_server_stats_by_id(server_id)
page_data['waiting_start'] = self.controller.servers.get_waiting_start(server_id)
try:
page_data['waiting_start'] = self.controller.servers.get_waiting_start(server_id)
except:
page_data['waiting_start'] = False
page_data['get_players'] = lambda: self.controller.stats.get_server_players(server_id)
page_data['active_link'] = subpage
page_data['permissions'] = {

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

View File

@ -101,6 +101,15 @@
<div class="card-body">
<div class="table-responsive">
{% if len(data['servers']) == 0%}
<div style="text-align: center; color: grey;">
<h1>{{ translate('dashboard', 'welcome') }}</h1>
<br>
<h7>{{ translate('dashboard', 'no-servers') }} {{ translate('dashboard', 'newServer') }}.</h7>
</div>
{% end %}
{% if len(data['servers']) > 0 %}
<table class="table table-hover">
<thead>
<tr class="rounded">
@ -205,6 +214,7 @@
</tbody>
</table>
{% end %}
</div>
</div>
</div>
@ -212,7 +222,6 @@
</div>
</div>
<!-- content-wrapper ends -->

View File

@ -157,6 +157,7 @@
</div>
</div>
</div>
{% end %}
<div class="form-check-flat">
<label for="enabled" class="form-check-label ml-4 mb-4">
@ -184,7 +185,7 @@
</label>
</div>
{% end %}
<button type="submit" class="btn btn-success mr-2"><i class="fas fa-save"></i> {{ translate('panelConfig', 'save') }}</button>
<button type="reset" onclick="location.href='/panel/panel_config'" class="btn btn-light"><i class="fas fa-undo-alt"></i> {{ translate('panelConfig', 'cancel') }}</button>
</form>

View File

@ -100,7 +100,9 @@
"restart": "Restart",
"killing": "Killing process...",
"starting": "Delayed-Start",
"delay-explained": "The service/agent has recently started and is delaying the start of the minecraft server instance"
"delay-explained": "The service/agent has recently started and is delaying the start of the minecraft server instance",
"no-servers": "There are currently no servers. To get started, click",
"welcome": "Welcome to Crafty Controller"
},
"accessDenied": {
"accessDenied": "Access Denied",

View File

@ -100,7 +100,9 @@
"restart": "Uudelleenkäynnistää",
"killing": "Tappamisprosessi ...",
"starting": "Myöhästynyt lähtö",
"delay-explained": "Palvelu/agentti on äskettäin aloittanut ja viivästyttää minecraft -palvelimen ilmentymän alkua"
"delay-explained": "Palvelu/agentti on äskettäin aloittanut ja viivästyttää minecraft -palvelimen ilmentymän alkua",
"no-servers": "Palvelimia ei tällä hetkellä ole. Aloita napsauttamalla",
"welcome": "Tervetuloa Crafty Controller"
},
"accessDenied": {
"accessDenied": "Käyttö estetty",

View File

@ -100,7 +100,9 @@
"restart": "Redémarrage",
"killing": "Processus de mise à mort...",
"starting": "Démarrage retardé",
"delay-explained": "Le service/agent a récemment démarré et retarde le démarrage de l'instance du serveur minecraft"
"delay-explained": "Le service/agent a récemment démarré et retarde le démarrage de l'instance du serveur minecraft",
"no-servers": "Il n'y a actuellement aucun serveur. Pour commencer, cliquez sur",
"welcome": "Bienvenue à Crafty Controller"
},
"accessDenied": {
"accessDenied": "Accès Interdit",