Add SERVER_HOSTNAME setting. Update website index to show telnet connect info

This commit is contained in:
Griatch 2021-10-31 10:38:38 +01:00
parent be3fea2af4
commit 063c44f38d
4 changed files with 97 additions and 31 deletions

View file

@ -99,7 +99,8 @@ Up requirements to Django 3.2+, Twisted 21+
because it's used for handlers, and e.g. self.locks=[] is a common beginner mistake.
- Add `$pron()` inlinefunc for pronoun parsing in actor-stance strings using
`msg_contents`.
- Update defauklt website to show Telnet/SSL/SSH connect info. Added new
`SERVER_HOSTNAME` setting for use in the server:port stanza.
### Evennia 0.9.5 (2019-2020)

View file

@ -27,6 +27,10 @@ SERVERNAME = "Evennia"
# Short one-sentence blurb describing your game. Shown under the title
# on the website and could be used in online listings of your game etc.
GAME_SLOGAN = "The Python MUD/MU* creation system"
# The url address to your server, like mymudgame.com. This should be the publicly
# visible location. This is used e.g. on the web site to show how you connect to the
# game over telnet. Default is localhost (only on your machine).
SERVER_HOSTNAME = "localhost"
# Lockdown mode will cut off the game from any external connections
# and only allow connections from localhost. Requires a cold reboot.
LOCKDOWN_MODE = False

View file

@ -24,21 +24,55 @@
into a full-fledged home for your game.
</p>
{% if webclient_enabled %}
<p>
<a href="{% url 'webclient:index' %}" class="playbutton">Play in the browser!</a>
</p>
<p>
<a href="{% url 'webclient:index' %}" class="playbutton">Play in the browser!</a>
</p>
{% endif %}
{% if telnet_enabled %}
<p>
Telnet: <strong>{{ server_hostname }}</strong>, port
{% for port in telnet_ports %}
{% if not forloop.first and forloop.last %} or
{% elif forloop.counter != 1 %},
{% endif %}
<strong>{{ port }}</strong>
{% endfor %}
</p>
{% endif %}
{% if telnet_ssl_enabled %}
<p>
Telnet (SSL): <strong>{{ server_hostname }}</strong>, port
{% for port in telnet_ssl_ports %}
{% if not forloop.first and forloop.last %} or
{% elif forloop.counter != 1 %},
{% endif %}
<strong>{{ port }}</strong>
{% endfor %}
</p>
{% endif %}
{% if ssh_enabled %}
<p>
SSH: <strong>{{ server_hostname }}</strong>, port
{% for port in ssh_ports %}
{% if not forloop.first and forloop.last %} or
{% elif forloop.counter != 1 %},
{% endif %}
<strong>{{ port }}</strong>
{% endfor %}
</p>
{% endif %}
<p>
For more info, take your time to
peruse Evennia's extensive online <a href="https://evennia.com/docs/latest">manual</a>.
For more info, see the <a href="https://www.evennia.com">Evennia homepage</a> or check
out our extensive <a href="https://evennia.com/docs/latest">online documentation</a>.
</p>
<p>
If you have any questions, don't hesitate to join the Evennia community! Drop a message in the <a href="https://github.com/evennia/evennia/discussions">Evennia forums</a>
or come say hi in the support/chat channels (<a href="http://webchat.freenode.net/?channels=evennia">IRC</a>
or <a href="https://discord.gg/NecFePw">Discord</a>).
Don't hesitate asking questions to the Evennia community!<br>Drop a message
in the <a href="https://github.com/evennia/evennia/discussions">Evennia forums</a>
or come say hi in the <a href="https://discord.gg/AJJpcRUhtF">Discord support channel</a>.
</p>
<p>
If you find bugs, please report them to our <a href="https://github.com/evennia/evennia/issues">Issue tracker</a> on GitHub.
Evennia is Open source and can be found on <a href="https://github.com/evennia/evennia">GitHub</a>.
If you find bugs, please report them to the <a href="https://github.com/evennia/evennia/issues">Issue tracker</a>.
</p>
</div>
</div>

View file

@ -15,24 +15,45 @@ from evennia.utils.utils import get_evennia_version
# Setup lists of the most relevant apps so
# the adminsite becomes more readable.
GAME_NAME = None
GAME_SLOGAN = None
SERVER_VERSION = None
SERVER_HOSTNAME = None
TELNET_ENABLED = None
TELNET_PORTS = None
TELNET_SSL_ENABLED = None
TELNET_SSL_PORTS = None
SSH_ENABLED = None
SSH_PORTS = None
WEBCLIENT_ENABLED = None
WEBSOCKET_CLIENT_ENABLED = None
WEBSOCKET_PORT = None
WEBSOCKET_URL = None
REST_API_ENABLED = False
ACCOUNT_RELATED = ["Accounts"]
GAME_ENTITIES = ["Objects", "Scripts", "Comms", "Help"]
GAME_SETUP = ["Permissions", "Config"]
CONNECTIONS = ["Irc"]
WEBSITE = ["Flatpages", "News", "Sites"]
REST_API_ENABLED = False
# Determine the site name and server version
def set_game_name_and_slogan():
def load_game_settings():
"""
Sets global variables GAME_NAME and GAME_SLOGAN which are used by
general_context.
Notes:
This function is used for unit testing the values of the globals.
Load and cache game settings.
"""
global GAME_NAME, GAME_SLOGAN, SERVER_VERSION, REST_API_ENABLED
global GAME_NAME, GAME_SLOGAN, SERVER_VERSION, SERVER_HOSTNAME
global TELNET_ENABLED, TELNET_PORTS
global TELNET_SSL_ENABLED, TELNET_SSL_PORTS
global SSH_ENABLED, SSH_PORTS
global WEBCLIENT_ENABLED, WEBSOCKET_CLIENT_ENABLED, WEBSOCKET_PORT, WEBSOCKET_URL
global REST_API_ENABLED
try:
GAME_NAME = settings.SERVERNAME.strip()
except AttributeError:
@ -42,19 +63,16 @@ def set_game_name_and_slogan():
GAME_SLOGAN = settings.GAME_SLOGAN.strip()
except AttributeError:
GAME_SLOGAN = SERVER_VERSION
SERVER_HOSTNAME = settings.SERVER_HOSTNAME
REST_API_ENABLED = settings.REST_API_ENABLED
TELNET_ENABLED = settings.TELNET_ENABLED
TELNET_PORTS = settings.TELNET_PORTS
TELNET_SSL_ENABLED = settings.SSL_ENABLED
TELNET_SSL_PORTS = settings.SSL_PORTS
def set_webclient_settings():
"""
As with set_game_name_and_slogan above, this sets global variables pertaining
to webclient settings.
SSH_ENABLED = settings.SSH_ENABLED
SSH_PORTS = settings.SSH_PORTS
Notes:
Used for unit testing.
"""
global WEBCLIENT_ENABLED, WEBSOCKET_CLIENT_ENABLED, WEBSOCKET_PORT, WEBSOCKET_URL
WEBCLIENT_ENABLED = settings.WEBCLIENT_ENABLED
WEBSOCKET_CLIENT_ENABLED = settings.WEBSOCKET_CLIENT_ENABLED
# if we are working through a proxy or uses docker port-remapping, the webclient port encoded
@ -66,9 +84,11 @@ def set_webclient_settings():
# this is determined dynamically by the client and is less of an issue
WEBSOCKET_URL = settings.WEBSOCKET_CLIENT_URL
REST_API_ENABLED = settings.REST_API_ENABLED
load_game_settings()
set_game_name_and_slogan()
set_webclient_settings()
# The main context processor function
def general_context(request):
@ -91,11 +111,18 @@ def general_context(request):
"puppet": puppet,
"game_name": GAME_NAME,
"game_slogan": GAME_SLOGAN,
"server_hostname": SERVER_HOSTNAME,
"evennia_userapps": ACCOUNT_RELATED,
"evennia_entityapps": GAME_ENTITIES,
"evennia_setupapps": GAME_SETUP,
"evennia_connectapps": CONNECTIONS,
"evennia_websiteapps": WEBSITE,
"telnet_enabled": TELNET_ENABLED,
"telnet_ports": TELNET_PORTS,
"telnet_ssl_enabled": TELNET_SSL_ENABLED,
"telnet_ssl_ports": TELNET_SSL_PORTS,
"ssh_enabled": SSH_ENABLED,
"ssh_ports": SSH_ENABLED,
"webclient_enabled": WEBCLIENT_ENABLED,
"websocket_enabled": WEBSOCKET_CLIENT_ENABLED,
"websocket_port": WEBSOCKET_PORT,