Setup inbound or outbound connection for communication over RLPXFrameCoder. RLPx Spec: https://github.com/ethereum/devp2p/blob/master/rlpx.md#encrypted-handshake.
More...
#include <RLPxHandshake.h>
|
static constexpr std::chrono::milliseconds | c_timeout {1800} |
|
Setup inbound or outbound connection for communication over RLPXFrameCoder. RLPx Spec: https://github.com/ethereum/devp2p/blob/master/rlpx.md#encrypted-handshake.
- Todo:
- Implement StartSession transition via lambda which is passed to constructor.
Thread Safety Distinct Objects: Safe. Shared objects: Unsafe.
◆ dev::p2p::RLPXHandshake::HostContext
struct dev::p2p::RLPXHandshake::HostContext |
◆ State
Sequential states of handshake.
Enumerator |
---|
Error | |
New | |
AckAuth | |
AckAuthEIP8 | |
WriteHello | |
ReadHello | |
StartSession | |
◆ RLPXHandshake() [1/2]
RLPXHandshake::RLPXHandshake |
( |
std::shared_ptr< HostContext const > |
ctx, |
|
|
std::shared_ptr< RLPXSocket > const & |
_socket |
|
) |
| |
Setup incoming connection.
◆ RLPXHandshake() [2/2]
RLPXHandshake::RLPXHandshake |
( |
std::shared_ptr< HostContext const > |
ctx, |
|
|
std::shared_ptr< RLPXSocket > const & |
_socket, |
|
|
NodeID |
_remote |
|
) |
| |
Setup outbound connection.
◆ cancel()
void RLPXHandshake::cancel |
( |
| ) |
|
◆ connectionDirectionString()
char const* dev::p2p::RLPXHandshake::connectionDirectionString |
( |
| ) |
const |
|
inlineprivate |
Get a string indicating if the connection is incoming or outgoing.
◆ error()
void RLPXHandshake::error |
( |
boost::system::error_code |
_ech = {} | ) |
|
|
private |
Closes connection and ends transitions.
◆ readAck()
void RLPXHandshake::readAck |
( |
| ) |
|
|
private |
Reads Auth message from socket and transitions to WriteHello.
◆ readAckEIP8()
void RLPXHandshake::readAckEIP8 |
( |
| ) |
|
|
private |
Continues reading Ack message in EIP-8 format and transitions to WriteHello.
◆ readAuth()
void RLPXHandshake::readAuth |
( |
| ) |
|
|
private |
Reads Auth message from socket and transitions to AckAuth.
◆ readAuthEIP8()
void RLPXHandshake::readAuthEIP8 |
( |
| ) |
|
|
private |
Continues reading Auth message in EIP-8 format and transitions to AckAuthEIP8.
◆ remote()
NodeID dev::p2p::RLPXHandshake::remote |
( |
| ) |
const |
|
inline |
◆ remoteSocketConnected()
bool RLPXHandshake::remoteSocketConnected |
( |
| ) |
const |
|
private |
Determine if the remote socket is still connected.
◆ setAuthValues()
void RLPXHandshake::setAuthValues |
( |
Signature const & |
sig, |
|
|
Public const & |
remotePubk, |
|
|
h256 const & |
remoteNonce, |
|
|
uint64_t |
remoteVersion |
|
) |
| |
|
private |
Derives ephemeral secret from signature and sets members after Auth has been decrypted.
◆ start()
void dev::p2p::RLPXHandshake::start |
( |
| ) |
|
|
inline |
◆ transition()
void RLPXHandshake::transition |
( |
boost::system::error_code |
_ech = {} | ) |
|
|
private |
Performs transition for m_nextState.
This pointer will be freed if there is an error otherwise it will be passed to Host which will take ownership.
authenticate and decrypt header
check frame size
rlp of header has protocol-type, sequence-id[, total-packet-size]
read padded frame and mac
◆ writeAck()
void RLPXHandshake::writeAck |
( |
| ) |
|
|
private |
Write Ack message to socket and transitions to WriteHello.
◆ writeAckEIP8()
void RLPXHandshake::writeAckEIP8 |
( |
| ) |
|
|
private |
Write Ack message in EIP-8 format to socket and transitions to WriteHello.
◆ writeAuth()
void RLPXHandshake::writeAuth |
( |
| ) |
|
|
private |
Write Auth message to socket and transitions to AckAuth.
◆ RLPXFrameCoder
◆ c_timeout
constexpr std::chrono::milliseconds RLPXHandshake::c_timeout {1800} |
|
staticconstexprprivate |
Timeout for a stage in the handshake to complete (the remote to respond to transition events). Enforced by m_idleTimer and refreshed by transition().
◆ host_ctx_
std::shared_ptr<HostContext const> dev::p2p::RLPXHandshake::host_ctx_ |
|
private |
◆ m_ack
bytes dev::p2p::RLPXHandshake::m_ack |
|
private |
Plaintext of egress or ingress Ack message.
◆ m_ackCipher
bytes dev::p2p::RLPXHandshake::m_ackCipher |
|
private |
Ciphertext of egress or ingress Ack message.
◆ m_auth
bytes dev::p2p::RLPXHandshake::m_auth |
|
private |
Buffers for encoded and decoded handshake phases.
Plaintext of egress or ingress Auth message.
◆ m_authCipher
bytes dev::p2p::RLPXHandshake::m_authCipher |
|
private |
Ciphertext of egress or ingress Auth message.
◆ m_cancel
bool dev::p2p::RLPXHandshake::m_cancel = false |
|
private |
Will be set to true if connection was canceled.
◆ m_ecdheLocal
Ephemeral ECDH secret and agreement.
◆ m_ecdheRemote
Public dev::p2p::RLPXHandshake::m_ecdheRemote |
|
private |
Remote ephemeral public key.
◆ m_errorLogger
◆ m_failureReason
◆ m_handshakeInBuffer
bytes dev::p2p::RLPXHandshake::m_handshakeInBuffer |
|
private |
Frame buffer for ingress Hello packet.
◆ m_handshakeOutBuffer
bytes dev::p2p::RLPXHandshake::m_handshakeOutBuffer |
|
private |
Frame buffer for egress Hello packet.
◆ m_idleTimer
ba::steady_timer dev::p2p::RLPXHandshake::m_idleTimer |
|
private |
Timer which enforces c_timeout. Reset for each stage of the handshake.
◆ m_io
Used to read and write RLPx encrypted frames for last step of handshake authentication. Passed onto Host which will take ownership.
◆ m_logger
◆ m_nextState
State dev::p2p::RLPXHandshake::m_nextState = New |
|
private |
Current or expected state of transition.
◆ m_nonce
h256 dev::p2p::RLPXHandshake::m_nonce |
|
private |
Nonce generated by this host for handshake.
◆ m_originated
bool dev::p2p::RLPXHandshake::m_originated = false |
|
private |
True if connection is outbound.
◆ m_remote
NodeID dev::p2p::RLPXHandshake::m_remote |
|
private |
Node id of remote host for socket.
Public address of remote host.
◆ m_remoteNonce
h256 dev::p2p::RLPXHandshake::m_remoteNonce |
|
private |
Nonce generated by remote host for handshake.
◆ m_remoteVersion
uint64_t dev::p2p::RLPXHandshake::m_remoteVersion |
|
private |
◆ m_socket
std::shared_ptr<RLPXSocket> dev::p2p::RLPXHandshake::m_socket |
|
private |
The documentation for this struct was generated from the following files: