evennia.server.portal.ssh

This module implements the ssh (Secure SHell) protocol for encrypted connections.

This depends on a generic session module that implements the actual login procedure of the game, tracks sessions etc.

Using standard ssh client,

class evennia.server.portal.ssh.SSHServerFactory[source]

Bases: twisted.internet.protocol.ServerFactory

This is only to name this better in logs

noisy = False
logPrefix()[source]

Describe this factory for log messages.

class evennia.server.portal.ssh.SshProtocol(starttuple)[source]

Bases: twisted.conch.manhole.Manhole, evennia.server.session.Session

Each account connecting over ssh gets this protocol assigned to them. All communication between game and account goes through here.

noisy = False
__init__(starttuple)[source]

For setting up the account. If account is not None then we’ll login automatically.

Parameters

starttuple (tuple) – A (account, factory) tuple.

terminalSize(width, height)[source]

Initialize the terminal and connect to the new session.

Parameters
  • width (int) – Width of terminal.

  • height (int) – Height of terminal.

connectionMade()[source]

This is called when the connection is first established.

handle_INT()[source]

Handle ^C as an interrupt keystroke by resetting the current input variables to their initial state.

handle_EOF()[source]

Handles EOF generally used to exit.

handle_FF()[source]

Handle a ‘form feed’ byte - generally used to request a screen refresh/redraw.

handle_QUIT()[source]

Quit, end, and lose the connection.

connectionLost(reason=None)[source]

This is executed when the connection is lost for whatever reason. It can also be called directly, from the disconnect method.

Parameters

reason (str) – Motivation for loosing connection.

getClientAddress()[source]

Get client address.

Returns

address_and_port (tuple)

The client’s address and port in

a tuple. For example (‘127.0.0.1’, 41917).

lineReceived(string)[source]

Communication User -> Evennia. Any line return indicates a command for the purpose of the MUD. So we take the user input and pass it on to the game engine.

Parameters

string (str) – Input text.

sendLine(string)[source]

Communication Evennia -> User. Any string sent should already have been properly formatted and processed before reaching this point.

Parameters

string (str) – Output text.

at_login()[source]

Called when this session gets authenticated by the server.

disconnect(reason='Connection closed. Goodbye for now.')[source]

Disconnect from server.

Parameters

reason (str) – Motivation for disconnect.

data_out(**kwargs)[source]

Data Evennia -> User

Keyword Arguments

kwargs (any) – Options to the protocol.

send_text(*args, **kwargs)[source]

Send text data. This is an in-band telnet operation.

Parameters

text (str) – The first argument is always the text string to send. No other arguments are considered.

Keyword Arguments

options (dict) –

Send-option flags:

  • mxp: Enforce MXP link support.

  • ansi: Enforce no ANSI colors.

  • xterm256: Enforce xterm256 colors, regardless of TTYPE setting.

  • nocolor: Strip all colors.

  • raw: Pass string through without any ansi processing (i.e. include Evennia ansi markers but do not convert them into ansi tokens)

  • echo: Turn on/off line echo on the client. Turn off line echo for client, for example for password. Note that it must be actively turned back on again!

send_prompt(*args, **kwargs)[source]
send_default(*args, **kwargs)[source]
class evennia.server.portal.ssh.ExtraInfoAuthServer[source]

Bases: twisted.conch.ssh.userauth.SSHUserAuthServer

noisy = False
auth_password(packet)[source]

Password authentication.

Used mostly for setting up the transport so we can query username and password later.

Parameters

packet (Packet) – Auth packet.

class evennia.server.portal.ssh.AccountDBPasswordChecker(factory)[source]

Bases: object

Checks the django db for the correct credentials for username/password otherwise it returns the account or None which is useful for the Realm.

noisy = False
credentialInterfaces = (<InterfaceClass twisted.cred.credentials.IUsernamePassword>,)
__init__(factory)[source]

Initialize the factory.

Parameters

factory (SSHFactory) – Checker factory.

requestAvatarId(c)[source]

Generic credentials.

class evennia.server.portal.ssh.PassAvatarIdTerminalRealm(transportFactory=None)[source]

Bases: twisted.conch.manhole_ssh.TerminalRealm

Returns an avatar that passes the avatarId through to the protocol. This is probably not the best way to do it.

noisy = False
class evennia.server.portal.ssh.TerminalSessionTransport_getPeer(proto, chainedProtocol, avatar, width, height)[source]

Bases: object

Taken from twisted’s TerminalSessionTransport which doesn’t provide getPeer to the transport. This one does.

noisy = False
__init__(proto, chainedProtocol, avatar, width, height)[source]

Initialize self. See help(type(self)) for accurate signature.

evennia.server.portal.ssh.getKeyPair(pubkeyfile, privkeyfile)[source]

This function looks for RSA keypair files in the current directory. If they do not exist, the keypair is created.

evennia.server.portal.ssh.makeFactory(configdict)[source]

Creates the ssh server factory.