From fd2cfd37812184f9dcf3ab2beba2ba1a2b7bf361 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 9 Mar 2024 21:38:32 +0100 Subject: [PATCH] Fix issue in SSH protocol preventing connection. Resolve #3411 --- CHANGELOG.md | 2 ++ evennia/server/portal/ssh.py | 15 +++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fb9459899..8499f1849e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,11 +26,13 @@ Evennia core's version (michaelfaith84, Griatch) - [Fix][issue3438]: Limiting search by tag didn't take search-string into account (Griatch) +- [Fix][issue4311]: SSH connection caused a traceback in protocol (Griatch) - Fix: Resolve a bug when loading on-demand-handler data from database (Griatch) - Doc fixes (iLPdev, Griatch, CloudKeeper) [pull3420]: https://github.com/evennia/evennia/pull/3420 [issue3438]: https://github.com/evennia/evennia/issues/3438 +[issue3411]: https://github.com/evennia/evennia/issues/3411 ## Evennia 3.2.0 diff --git a/evennia/server/portal/ssh.py b/evennia/server/portal/ssh.py index 046d5b0761..0a8e9637e8 100644 --- a/evennia/server/portal/ssh.py +++ b/evennia/server/portal/ssh.py @@ -34,6 +34,9 @@ except ImportError: raise ImportError(_SSH_IMPORT_ERROR) from django.conf import settings +from evennia.accounts.models import AccountDB +from evennia.utils import ansi +from evennia.utils.utils import class_from_module, to_str from twisted.conch import interfaces as iconch from twisted.conch.insults import insults from twisted.conch.manhole import Manhole, recvline @@ -43,10 +46,6 @@ from twisted.conch.ssh.userauth import SSHUserAuthServer from twisted.internet import defer, protocol from twisted.python import components -from evennia.accounts.models import AccountDB -from evennia.utils import ansi -from evennia.utils.utils import class_from_module, to_str - _RE_N = re.compile(r"\|n$") _RE_SCREENREADER_REGEX = re.compile( r"%s" % settings.SCREENREADER_REGEX_STRIP, re.DOTALL + re.MULTILINE @@ -127,15 +126,15 @@ class SshProtocol(Manhole, _BASE_SESSION_CLASS): self.width = width self.height = height - # Set color defaults - for color in ("ANSI", "XTERM256", "TRUECOLOR"): - self.protocol_flags[color] = True - # initialize the session client_address = self.getClientAddress() client_address = client_address.host if client_address else None self.init_session("ssh", client_address, self.cfactory.sessionhandler) + # Set color defaults + for color in ("ANSI", "XTERM256", "TRUECOLOR"): + self.protocol_flags[color] = True + # since we might have authenticated already, we might set this here. if self.authenticated_account: self.logged_in = True