barrel_p2p_dist_protocol (barrel_p2p v0.1.0)
View SourceSummary
Functions
Decode an authentication message The HELLO node name is returned as a *validated binary*, not an atom. Atomising peer-controlled bytes here would let an unauthenticated peer flood the (never-GC'd) atom table; the caller mints the atom only after the Ed25519 signature is verified. See barrel_p2p_dist_auth_stream.
Encode AUTH_CHALLENGE message Format: <<Type:8, Nonce:32/binary, Timestamp:64/big>>
Encode AUTH_FAIL message Format: <<Type:8, ReasonLen:16/big, Reason/binary>>
Encode AUTH_HELLO message Format: <<Type:8, Version:8, NodeNameLen:16/big, NodeName/binary, PubKey:32/binary>>
Encode AUTH_OK message Format: <<Type:8>>
Encode AUTH_RESPONSE message Format: <<Type:8, Signature:64/binary>>
Validate a node name binary. Returns ok if the bytes form a well-shaped name@host atom by Erlang dist conventions.
Functions
-spec decode(binary()) -> {hello, binary(), binary()} | {challenge, binary(), integer()} | {response, binary()} | ok | {fail, binary()} | {error, term()}.
Decode an authentication message The HELLO node name is returned as a *validated binary*, not an atom. Atomising peer-controlled bytes here would let an unauthenticated peer flood the (never-GC'd) atom table; the caller mints the atom only after the Ed25519 signature is verified. See barrel_p2p_dist_auth_stream.
Encode AUTH_CHALLENGE message Format: <<Type:8, Nonce:32/binary, Timestamp:64/big>>
Encode AUTH_FAIL message Format: <<Type:8, ReasonLen:16/big, Reason/binary>>
Encode AUTH_HELLO message Format: <<Type:8, Version:8, NodeNameLen:16/big, NodeName/binary, PubKey:32/binary>>
-spec encode_ok() -> binary().
Encode AUTH_OK message Format: <<Type:8>>
Encode AUTH_RESPONSE message Format: <<Type:8, Signature:64/binary>>
-spec validate_node_name(binary()) -> ok | {error, invalid_node_name}.
Validate a node name binary. Returns ok if the bytes form a well-shaped name@host atom by Erlang dist conventions.