pyrlang.dist_proto.handshake¶
The messages of the distribution handshake, version 6 (OTP 23 and newer),
as pure functions over bytes: no sockets, no state.
Layouts are from erl_dist_protocol (“Distribution Handshake”) of OTP 29.
Each function takes or returns one packet without its 2-byte length prefix.
Node names are Latin-1 on the wire, as in dist_util (atom_to_binary(Node,
latin1) when sending, list_to_atom of the bytes when receiving): a name
with other characters cannot take part in a handshake with OTP.
Malformed input raises DistributionError.
- pyrlang.dist_proto.handshake.new_challenge()¶
A 32-bit challenge from the system’s secure random source.
- pyrlang.dist_proto.handshake.digest(challenge, cookie)¶
md5(Cookie ++ integer_to_list(Challenge))asdist_util:gen_digestcomputes it: the cookie’s characters are bytes, so it must be Latin-1 (OTP fails withbadargon any other cookie).
- pyrlang.dist_proto.handshake.digest_matches(received, challenge, cookie)¶
Whether
receivedis the digest ofchallenge; the comparison takes the same time wherever the first difference is.
- class pyrlang.dist_proto.handshake.Name(flags, creation, name)¶
Bases:
objectsend_name: the initiator introduces itself.
- class pyrlang.dist_proto.handshake.Status(status)¶
Bases:
objectrecv_status/send_status: the acceptor’s verdict, or the initiator’s true/false answer to “alive”.
- class pyrlang.dist_proto.handshake.Named(name, creation)¶
Bases:
objectStatus “named:”: the name and creation an acceptor gives to an initiator that asked for them with DFLAG_NAME_ME (dynamic node name, OTP 23).
- class pyrlang.dist_proto.handshake.Challenge(flags, challenge, creation, name)¶
Bases:
objectsend_challenge: the acceptor introduces itself and challenges the initiator.
- class pyrlang.dist_proto.handshake.ChallengeReply(challenge, digest)¶
Bases:
objectsend_challenge_reply: the initiator’s digest and its own challenge.
- class pyrlang.dist_proto.handshake.ChallengeAck(digest)¶
Bases:
objectsend_challenge_ack: the acceptor’s digest of the initiator’s challenge.
- pyrlang.dist_proto.handshake.encode_name(msg)¶
'N', Flags:64, Creation:32, Nlen:16, Name
- pyrlang.dist_proto.handshake.decode_name(data)¶
The initiator’s name message.
- Raises:
DistributionError – malformed
- pyrlang.dist_proto.handshake.encode_status(msg)¶
's', Status
- pyrlang.dist_proto.handshake.decode_status(data)¶
The status text. For
named:the fields after the colon are read withdecode_named().
- pyrlang.dist_proto.handshake.decode_named(data)¶
's', "named:", Nlen:16, Name, Creation:32: the acceptor’s answer to a name message withDFLAG_NAME_ME(the name is UTF-8, asdist_util:send_statuswrites it); bytes after it are ignored.
- pyrlang.dist_proto.handshake.encode_challenge(msg)¶
'N', Flags:64, Challenge:32, Creation:32, Nlen:16, Name
- pyrlang.dist_proto.handshake.decode_challenge(data)¶
The acceptor’s challenge message.
- Raises:
DistributionError – malformed
- pyrlang.dist_proto.handshake.encode_challenge_reply(msg)¶
'r', Challenge:32, Digest:16 bytes
- pyrlang.dist_proto.handshake.decode_challenge_reply(data)¶
The initiator’s challenge reply.
- Raises:
DistributionError – malformed
- pyrlang.dist_proto.handshake.encode_challenge_ack(msg)¶
'a', Digest:16 bytes
- pyrlang.dist_proto.handshake.decode_challenge_ack(data)¶
The acceptor’s challenge ack.
- Raises:
DistributionError – malformed