dist_proto.base_dist_protocol module

Base abstract Distribution connection class

class pyrlang.dist_proto.base_dist_protocol.BaseDistProtocol(node_name: str)

Bases: asyncio.protocols.Protocol

Defines Erlang distribution protocol (shared parts). Concrete implementations for incoming (DistServerProtocol) and outgoing (DistClientProtocol) are located in the corresponding modules.

ALIVE = 'alive'
CONNECTED = 'conn'
DISCONNECTED = 'disconn'
RECV_CHALLENGE = 'recv_challenge'
RECV_CHALLENGE_ACK = 'recv_challenge_ack'
RECV_NAME = 'recvname'
RECV_STATUS = 'recv_status'
WAIT_CHALLENGE_REPLY = 'wait_ch_reply'
static check_digest(digest: bytes, challenge: int, cookie: str) → bool

Hash cookie + the challenge together producing a verification hash and return if they match against the offered 'digest'.


Handler is called when the client has disconnected

connection_made(transport: asyncio.transports.Transport)

Connection has been accepted and established (callback).

data_received(data: bytes) → None

Called when some data is received.

The argument is a bytes object.


Use this to get access to the Pyrlang node which owns this protocol. :rtype: pyrlang2.node.Node

inbox_ = None

Inbox is used to ask the connection to do something.

async listen_on_inbox()
static make_digest(challenge: int, cookie: str) → bytes
node_db = <pyrlang.node_db.NodeDB object>
node_name_ = None

Name of the running Erlang node.

on_packet(data: bytes) → bytes
on_packet_connected(data: bytes) → bytes

Handle incoming dist packets in the connected state.

async on_passthrough_message(control_term, msg_term)

On incoming 'p' message with control and data, handle it. :raises DistributionError: when 'p' message is not a tuple

packet_len_size_ = None

Packet size header is variable, 2 bytes before handshake is finished and 4 bytes afterwards.

peer_distr_version_ = None

Protocol version range supported by the remote peer. Erlang/OTP versions 19-20 supports protocol version 7, older Erlangs down to R6B support version 5.

state_ = None

FSM state for the protocol state-machine.