mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'dew-features' into 'dev'
Works around bug for port/ip reporting See merge request crafty-controller/crafty-commander!69
This commit is contained in:
commit
21b7519861
@ -175,8 +175,8 @@ class Stats:
|
||||
|
||||
|
||||
# TODO: search server properties file for possible override of 127.0.0.1
|
||||
internal_ip = server_data.get('server_ip', "127.0.0.1")
|
||||
server_port = server_settings.get('server-port', "25565")
|
||||
internal_ip = server['server_ip']
|
||||
server_port = server['server_port']
|
||||
|
||||
logger.debug("Pinging {} on port {}".format(internal_ip, server_port))
|
||||
int_mc_ping = ping(internal_ip, int(server_port))
|
||||
@ -201,6 +201,8 @@ class Stats:
|
||||
for s in servers:
|
||||
|
||||
server_id = s.get('server_id', None)
|
||||
server = db_helper.get_server_data_by_id(server_id)
|
||||
|
||||
|
||||
logger.debug('Getting stats for server: {}'.format(server_id))
|
||||
|
||||
@ -208,7 +210,7 @@ class Stats:
|
||||
server_obj = s.get('server_obj', None)
|
||||
server_obj.reload_server_settings()
|
||||
server_settings = s.get('server_settings', {})
|
||||
server_data = s.get('server_data_obj', {})
|
||||
server_data = self.controller.get_server_data(server_id)
|
||||
|
||||
# world data
|
||||
world_name = server_settings.get('level-name', 'Unknown')
|
||||
@ -218,8 +220,8 @@ class Stats:
|
||||
p_stats = self._get_process_stats(server_obj.PID)
|
||||
|
||||
# TODO: search server properties file for possible override of 127.0.0.1
|
||||
internal_ip = server_data.get('server_ip', "127.0.0.1")
|
||||
server_port = server_settings.get('server-port', "25565")
|
||||
internal_ip = server['server_ip']
|
||||
server_port = server['server_port']
|
||||
|
||||
logger.debug("Pinging server '{}' on {}:{}".format(s.get('server_name', "ID#{}".format(server_id)), internal_ip, server_port))
|
||||
int_mc_ping = ping(internal_ip, int(server_port))
|
||||
@ -276,8 +278,8 @@ class Stats:
|
||||
p_stats = self._get_process_stats(server_obj.PID)
|
||||
|
||||
# TODO: search server properties file for possible override of 127.0.0.1
|
||||
internal_ip = server_data.get('server_ip', "127.0.0.1")
|
||||
server_port = server_settings.get('server-port', "25565")
|
||||
internal_ip = server['server_ip']
|
||||
server_port = server['server_port']
|
||||
|
||||
logger.debug("Pinging server '{}' on {}:{}".format(server.name, internal_ip, server_port))
|
||||
int_mc_ping = ping(internal_ip, int(server_port))
|
||||
|
@ -20,6 +20,7 @@ from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.shared.models import db_helper, Servers
|
||||
from app.classes.web.websocket_helper import websocket_helper
|
||||
from app.classes.shared.translation import translation
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -188,7 +189,7 @@ class Server:
|
||||
msg = "Server {} failed to start with error code: {}".format(self.name, ex)
|
||||
logger.error(msg)
|
||||
websocket_helper.broadcast('send_start_error', {
|
||||
'error': msg
|
||||
'error': translation.translate('error', 'start-error').format(self.name, ex)
|
||||
})
|
||||
return False
|
||||
if helper.check_internet():
|
||||
@ -198,11 +199,11 @@ class Server:
|
||||
})
|
||||
else:
|
||||
websocket_helper.broadcast('send_start_error', {
|
||||
'error': "We have detected port {} may not be open on the host network or a firewall is blocking it. Remote client connections to the server may be limited.".format(loc_server_port)
|
||||
'error': translation.translate('error', 'closedPort').format(loc_server_port)
|
||||
})
|
||||
else:
|
||||
websocket_helper.broadcast('send_start_error', {
|
||||
'error': "We have detected the machine running Crafty has no connection to the internet. Client connections to the server may be limited."
|
||||
'error': translation.translate('error', 'internet')
|
||||
})
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ from tornado import iostream
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.shared.models import Users, installer
|
||||
from app.classes.web.base_handler import BaseHandler
|
||||
from app.classes.shared.models import db_helper, server_permissions, Servers, Enum_Permissions_Server, crafty_permissions, Enum_Permissions_Crafty
|
||||
from app.classes.shared.models import db_helper, server_permissions, Servers, Enum_Permissions_Server, crafty_permissions, Enum_Permissions_Crafty, Server_Stats
|
||||
from app.classes.shared.helpers import helper
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -122,6 +122,10 @@ class PanelHandler(BaseHandler):
|
||||
elif page == 'dashboard':
|
||||
if exec_user['superuser'] == 1:
|
||||
page_data['servers'] = db_helper.get_all_servers_stats()
|
||||
total_players = 0
|
||||
for server in db_helper.get_all_defined_servers():
|
||||
total_players += len(self.controller.stats.get_server_players(server['server_id']))
|
||||
page_data['num_players'] = total_players
|
||||
else:
|
||||
user_auth = db_helper.get_authorized_servers_stats(exec_user_id)
|
||||
logger.debug("ASFR: {}".format(user_auth))
|
||||
|
@ -60,7 +60,7 @@
|
||||
<div class="d-flex">
|
||||
<div class="wrapper">
|
||||
<h5 class="mb-1 font-weight-medium text-primary">{{ translate('dashboard', 'players') }}</h5>
|
||||
<h3 class="mb-0 font-weight-semibold">18</h3>
|
||||
<h3 class="mb-0 font-weight-semibold">{{ data['num_players'] }}</h3>
|
||||
|
||||
</div>
|
||||
<div class="wrapper my-auto ml-auto ml-lg-4">
|
||||
@ -130,7 +130,7 @@
|
||||
<a class="restart_button" data-id="{{server['server_data']['server_id']}}" data-toggle="tooltip" title={{ translate('dashboard', 'restart') }}> <i class="fas fa-sync"></i></a>
|
||||
<a class="kill_button" data-id="{{server['server_data']['server_id']}}" class="kill_button" data-toggle="tooltip" title={{ translate('dashboard', 'kill') }}> <i class="fas fa-skull"></i></a>
|
||||
{% elif server['stats']['updating']%}
|
||||
<a data-id="{{server['server_data']['server_id']}}" class=""> UPDATING...</i></a>
|
||||
<a data-id="{{server['server_data']['server_id']}}" class="">{{ translate('serverTerm', 'updating') }}</i></a>
|
||||
{% else %}
|
||||
<a data-id="{{server['server_data']['server_id']}}" class="play_button"><i class="fas fa-play" data-toggle="tooltip" title={{ translate('dashboard', 'start') }}></i></a>
|
||||
<a data-id="{{server['server_data']['server_id']}}" class="clone_button"> <i class="fas fa-clone" data-toggle="tooltip" title={{ translate('dashboard', 'clone') }}></i></a>
|
||||
|
@ -10,7 +10,10 @@
|
||||
"contact": "Contact Crafty Control Support via Discord",
|
||||
"terribleFailure": "What a Terrible Failure!",
|
||||
"embarassing": "Oh my, well, this is embarrassing.",
|
||||
"error": "Error!"
|
||||
"error": "Error!",
|
||||
"start-error": "Server {} failed to start with error code: {}",
|
||||
"closedPort": "We have detected port {} may not be open on the host network or a firewall is blocking it. Remote client connections to the server may be limited.",
|
||||
"internet": "We have detected the machine running Crafty has no connection to the internet. Client connections to the server may be limited."
|
||||
},
|
||||
"404": {
|
||||
"contact": "Contact Crafty Control Support via Discord",
|
||||
|
@ -10,7 +10,10 @@
|
||||
"contact": "Ota yhteyttä Crafty Control -tukeen Discordin kautta",
|
||||
"terribleFailure": "Mikä kauhea epäonnistuminen!",
|
||||
"embarassing": "No, tämähän on noloa.",
|
||||
"error": "Virhe!"
|
||||
"error": "Virhe!",
|
||||
"start-error": "Palvelin {} ei käynnistynyt virhekoodilla: {}",
|
||||
"closedPort": "Olemme havainneet, että portti {} ei ehkä ole auki isäntäverkossa tai palomuuri estää sen. Etäasiakkaan yhteydet palvelimeen voivat olla rajallisia.",
|
||||
"internet": "Olemme havainneet, että Crafty -koneella ei ole Internet -yhteyttä. Asiakasyhteydet palvelimelle voivat olla rajalliset."
|
||||
},
|
||||
"404": {
|
||||
"contact": "Ota yhteyttä Crafty Control -tukeen Discordin kautta",
|
||||
@ -90,12 +93,12 @@
|
||||
"cpuCurFreq": "Nykyinen kellotaajuus",
|
||||
"cpuMaxFreq": "Maksimi kellotaajuus",
|
||||
"cpuCores": "Suorittimen ytimet",
|
||||
"start": "Start",
|
||||
"stop": "Stop",
|
||||
"clone": "Clone",
|
||||
"kill": "Kill Process",
|
||||
"restart": "Restart",
|
||||
"killing": "Killing process..."
|
||||
"start": "Alkaa",
|
||||
"stop": "Lopettaa",
|
||||
"clone": "Klooni",
|
||||
"kill": "Tapa prosessi",
|
||||
"restart": "Uudelleenkäynnistää",
|
||||
"killing": "Tappamisprosessi ..."
|
||||
},
|
||||
"accessDenied": {
|
||||
"accessDenied": "Käyttö estetty",
|
||||
|
@ -10,7 +10,10 @@
|
||||
"contact": "Contacter le Support de Crafty Control via Discord",
|
||||
"terribleFailure": "C'est une Terrible Erreur !",
|
||||
"embarassing": "Oulà, c'est embarrassant.",
|
||||
"error": "Erreur !"
|
||||
"error": "Erreur !",
|
||||
"start-error": "Le serveur {} n'a pas pu démarrer avec le code d'erreur : {}",
|
||||
"closedPort": "Nous avons détecté que le port {} n'est peut-être pas ouvert sur le réseau hôte ou qu'un pare-feu le bloque. Les connexions des clients distants au serveur peuvent être limitées.",
|
||||
"internet": "Nous avons détecté que la machine exécutant Crafty n'a pas de connexion à Internet. Les connexions client au serveur peuvent être limitées."
|
||||
},
|
||||
"404": {
|
||||
"contact": "Contacter le Support de Crafty Control via Discord",
|
||||
@ -90,12 +93,12 @@
|
||||
"cpuCurFreq": "Fréquence CPU actuelle",
|
||||
"cpuMaxFreq": "Fréquence CPU Maximum",
|
||||
"cpuCores": "Coeurs CPU",
|
||||
"start": "Start",
|
||||
"stop": "Stop",
|
||||
"clone": "Clone",
|
||||
"kill": "Kill Process",
|
||||
"restart": "Restart",
|
||||
"killing": "Killing process..."
|
||||
"start": "Début",
|
||||
"stop": "Arrêter",
|
||||
"clone": "Cloner",
|
||||
"kill": "Tuer le processus",
|
||||
"restart": "Redémarrage",
|
||||
"killing": "Processus de mise à mort..."
|
||||
},
|
||||
"accessDenied": {
|
||||
"accessDenied": "Accès Interdit",
|
||||
|
3
main.py
3
main.py
@ -131,6 +131,9 @@ if __name__ == '__main__':
|
||||
# this should always be last
|
||||
tasks_manager.start_main_kill_switch_watcher()
|
||||
|
||||
logger.info("Checking Internet/Port Service. This may take a minute.")
|
||||
console.info("Checking Internet/Port Service. This may take a minute.")
|
||||
|
||||
if not helper.check_internet():
|
||||
console.error("We have detected the machine running Crafty has no connection to the internet. Client connections to the server may be limited.")
|
||||
elif not helper.check_port(helper.get_setting('https_port')):
|
||||
|
Loading…
Reference in New Issue
Block a user