@ -30,7 +30,7 @@ using namespace CryptoPP;
void RLPXHandshake : : writeAuth ( )
void RLPXHandshake : : writeAuth ( )
{
{
clog ( NetConnect ) < < " p2p.connect.egress sending auth to " < < m_socket - > remoteEndpoint ( ) ;
clog ( NetP2P Connect ) < < " p2p.connect.egress sending auth to " < < m_socket - > remoteEndpoint ( ) ;
m_auth . resize ( Signature : : size + h256 : : size + Public : : size + h256 : : size + 1 ) ;
m_auth . resize ( Signature : : size + h256 : : size + Public : : size + h256 : : size + 1 ) ;
bytesRef sig ( & m_auth [ 0 ] , Signature : : size ) ;
bytesRef sig ( & m_auth [ 0 ] , Signature : : size ) ;
bytesRef hepubk ( & m_auth [ Signature : : size ] , h256 : : size ) ;
bytesRef hepubk ( & m_auth [ Signature : : size ] , h256 : : size ) ;
@ -56,7 +56,7 @@ void RLPXHandshake::writeAuth()
void RLPXHandshake : : writeAck ( )
void RLPXHandshake : : writeAck ( )
{
{
clog ( NetConnect ) < < " p2p.connect.ingress sending ack to " < < m_socket - > remoteEndpoint ( ) ;
clog ( NetP2P Connect ) < < " p2p.connect.ingress sending ack to " < < m_socket - > remoteEndpoint ( ) ;
m_ack . resize ( Public : : size + h256 : : size + 1 ) ;
m_ack . resize ( Public : : size + h256 : : size + 1 ) ;
bytesRef epubk ( & m_ack [ 0 ] , Public : : size ) ;
bytesRef epubk ( & m_ack [ 0 ] , Public : : size ) ;
bytesRef nonce ( & m_ack [ Public : : size ] , h256 : : size ) ;
bytesRef nonce ( & m_ack [ Public : : size ] , h256 : : size ) ;
@ -74,7 +74,7 @@ void RLPXHandshake::writeAck()
void RLPXHandshake : : readAuth ( )
void RLPXHandshake : : readAuth ( )
{
{
clog ( NetConnect ) < < " p2p.connect.ingress recving auth from " < < m_socket - > remoteEndpoint ( ) ;
clog ( NetP2P Connect ) < < " p2p.connect.ingress recving auth from " < < m_socket - > remoteEndpoint ( ) ;
m_authCipher . resize ( 307 ) ;
m_authCipher . resize ( 307 ) ;
auto self ( shared_from_this ( ) ) ;
auto self ( shared_from_this ( ) ) ;
ba : : async_read ( m_socket - > ref ( ) , ba : : buffer ( m_authCipher , 307 ) , [ this , self ] ( boost : : system : : error_code ec , std : : size_t )
ba : : async_read ( m_socket - > ref ( ) , ba : : buffer ( m_authCipher , 307 ) , [ this , self ] ( boost : : system : : error_code ec , std : : size_t )
@ -95,13 +95,13 @@ void RLPXHandshake::readAuth()
m_remoteEphemeral = recover ( * ( Signature * ) sig . data ( ) , sharedSecret ^ m_remoteNonce ) ;
m_remoteEphemeral = recover ( * ( Signature * ) sig . data ( ) , sharedSecret ^ m_remoteNonce ) ;
if ( sha3 ( m_remoteEphemeral ) ! = * ( h256 * ) hepubk . data ( ) )
if ( sha3 ( m_remoteEphemeral ) ! = * ( h256 * ) hepubk . data ( ) )
clog ( NetConnect ) < < " p2p.connect.ingress auth failed (invalid: hash mismatch) for " < < m_socket - > remoteEndpoint ( ) ;
clog ( NetP2P Connect ) < < " p2p.connect.ingress auth failed (invalid: hash mismatch) for " < < m_socket - > remoteEndpoint ( ) ;
transition ( ) ;
transition ( ) ;
}
}
else
else
{
{
clog ( NetConnect ) < < " p2p.connect.ingress recving auth decrypt failed for " < < m_socket - > remoteEndpoint ( ) ;
clog ( NetP2P Connect ) < < " p2p.connect.ingress recving auth decrypt failed for " < < m_socket - > remoteEndpoint ( ) ;
m_nextState = Error ;
m_nextState = Error ;
transition ( ) ;
transition ( ) ;
}
}
@ -110,7 +110,7 @@ void RLPXHandshake::readAuth()
void RLPXHandshake : : readAck ( )
void RLPXHandshake : : readAck ( )
{
{
clog ( NetConnect ) < < " p2p.connect.egress recving ack from " < < m_socket - > remoteEndpoint ( ) ;
clog ( NetP2P Connect ) < < " p2p.connect.egress recving ack from " < < m_socket - > remoteEndpoint ( ) ;
m_ackCipher . resize ( 210 ) ;
m_ackCipher . resize ( 210 ) ;
auto self ( shared_from_this ( ) ) ;
auto self ( shared_from_this ( ) ) ;
ba : : async_read ( m_socket - > ref ( ) , ba : : buffer ( m_ackCipher , 210 ) , [ this , self ] ( boost : : system : : error_code ec , std : : size_t )
ba : : async_read ( m_socket - > ref ( ) , ba : : buffer ( m_ackCipher , 210 ) , [ this , self ] ( boost : : system : : error_code ec , std : : size_t )
@ -125,7 +125,7 @@ void RLPXHandshake::readAck()
}
}
else
else
{
{
clog ( NetConnect ) < < " p2p.connect.egress recving ack decrypt failed for " < < m_socket - > remoteEndpoint ( ) ;
clog ( NetP2P Connect ) < < " p2p.connect.egress recving ack decrypt failed for " < < m_socket - > remoteEndpoint ( ) ;
m_nextState = Error ;
m_nextState = Error ;
transition ( ) ;
transition ( ) ;
}
}
@ -138,9 +138,9 @@ void RLPXHandshake::error()
auto connected = m_socket - > isConnected ( ) ;
auto connected = m_socket - > isConnected ( ) ;
if ( connected & & ! m_socket - > remoteEndpoint ( ) . address ( ) . is_unspecified ( ) )
if ( connected & & ! m_socket - > remoteEndpoint ( ) . address ( ) . is_unspecified ( ) )
clog ( NetConnect ) < < " Disconnecting " < < m_socket - > remoteEndpoint ( ) < < " (Handshake Failed) " ;
clog ( NetP2P Connect ) < < " Disconnecting " < < m_socket - > remoteEndpoint ( ) < < " (Handshake Failed) " ;
else
else
clog ( NetConnect ) < < " Handshake Failed (Connection reset by peer) " ;
clog ( NetP2P Connect ) < < " Handshake Failed (Connection reset by peer) " ;
m_socket - > close ( ) ;
m_socket - > close ( ) ;
if ( m_io ! = nullptr )
if ( m_io ! = nullptr )
@ -151,7 +151,7 @@ void RLPXHandshake::transition(boost::system::error_code _ech)
{
{
if ( _ech | | m_nextState = = Error | | m_cancel )
if ( _ech | | m_nextState = = Error | | m_cancel )
{
{
clog ( NetConnect ) < < " Handshake Failed (I/O Error: " < < _ech . message ( ) < < " ) " ;
clog ( NetP2P Connect ) < < " Handshake Failed (I/O Error: " < < _ech . message ( ) < < " ) " ;
return error ( ) ;
return error ( ) ;
}
}
@ -175,7 +175,7 @@ void RLPXHandshake::transition(boost::system::error_code _ech)
else if ( m_nextState = = WriteHello )
else if ( m_nextState = = WriteHello )
{
{
m_nextState = ReadHello ;
m_nextState = ReadHello ;
clog ( NetConnect ) < < ( m_originated ? " p2p.connect.egress " : " p2p.connect.ingress " ) < < " sending capabilities handshake " ;
clog ( NetP2P Connect ) < < ( m_originated ? " p2p.connect.egress " : " p2p.connect.ingress " ) < < " sending capabilities handshake " ;
/// This pointer will be freed if there is an error otherwise
/// This pointer will be freed if there is an error otherwise
/// it will be passed to Host which will take ownership.
/// it will be passed to Host which will take ownership.
@ -220,7 +220,7 @@ void RLPXHandshake::transition(boost::system::error_code _ech)
return ;
return ;
}
}
clog ( NetNote ) < < ( m_originated ? " p2p.connect.egress " : " p2p.connect.ingress " ) < < " recvd hello header " ;
clog ( NetP2P Note ) < < ( m_originated ? " p2p.connect.egress " : " p2p.connect.ingress " ) < < " recvd hello header " ;
/// check frame size
/// check frame size
bytes & header = m_handshakeInBuffer ;
bytes & header = m_handshakeInBuffer ;
@ -228,7 +228,7 @@ void RLPXHandshake::transition(boost::system::error_code _ech)
if ( frameSize > 1024 )
if ( frameSize > 1024 )
{
{
// all future frames: 16777216
// all future frames: 16777216
clog ( NetWarn ) < < ( m_originated ? " p2p.connect.egress " : " p2p.connect.ingress " ) < < " hello frame is too large " < < frameSize ;
clog ( NetP2P Warn ) < < ( m_originated ? " p2p.connect.egress " : " p2p.connect.ingress " ) < < " hello frame is too large " < < frameSize ;
m_nextState = Error ;
m_nextState = Error ;
transition ( ) ;
transition ( ) ;
return ;
return ;
@ -279,7 +279,7 @@ void RLPXHandshake::transition(boost::system::error_code _ech)
if ( ! _ec )
if ( ! _ec )
{
{
if ( ! m_socket - > remoteEndpoint ( ) . address ( ) . is_unspecified ( ) )
if ( ! m_socket - > remoteEndpoint ( ) . address ( ) . is_unspecified ( ) )
clog ( NetConnect ) < < " Disconnecting " < < m_socket - > remoteEndpoint ( ) < < " (Handshake Timeout) " ;
clog ( NetP2P Connect ) < < " Disconnecting " < < m_socket - > remoteEndpoint ( ) < < " (Handshake Timeout) " ;
cancel ( ) ;
cancel ( ) ;
}
}
} ) ;
} ) ;