From 74335368ff3da5a1bdfd0be51e0b8399e92548eb Mon Sep 17 00:00:00 2001 From: subtly Date: Mon, 23 Mar 2015 14:15:04 +0100 Subject: [PATCH] add version to packet payload --- libp2p/Host.cpp | 2 +- libp2p/NodeTable.h | 4 ++-- libp2p/RLPxHandshake.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libp2p/Host.cpp b/libp2p/Host.cpp index 13ea87ba6..b946d9b3e 100644 --- a/libp2p/Host.cpp +++ b/libp2p/Host.cpp @@ -560,7 +560,7 @@ void Host::run(boost::system::error_code const&) { RecursiveGuard l(x_sessions); for (auto p: m_peers) - if (p.second->shouldReconnect()) + if (p.second->shouldReconnect() && !havePeerSession(p.second->id)) toConnect.push_back(p.second); } diff --git a/libp2p/NodeTable.h b/libp2p/NodeTable.h index 58fa722c1..562942f2f 100644 --- a/libp2p/NodeTable.h +++ b/libp2p/NodeTable.h @@ -321,8 +321,8 @@ struct PingNode: RLPXDatagram unsigned port; unsigned expiration; - void streamRLP(RLPStream& _s) const { _s.appendList(3); _s << ipAddress << port << expiration; } - void interpretRLP(bytesConstRef _bytes) { RLP r(_bytes); ipAddress = r[0].toString(); port = r[1].toInt(); expiration = r[2].toInt(); } + void streamRLP(RLPStream& _s) const { _s.appendList(4); _s << dev::p2p::c_protocolVersion << ipAddress << port << expiration; } + void interpretRLP(bytesConstRef _bytes) { RLP r(_bytes); version = r[0].toInt(); ipAddress = r[1].toString(); port = r[2].toInt(); expiration = r[3].toInt(); } }; /** diff --git a/libp2p/RLPxHandshake.cpp b/libp2p/RLPxHandshake.cpp index 1e42995ee..16bfe0fb1 100644 --- a/libp2p/RLPxHandshake.cpp +++ b/libp2p/RLPxHandshake.cpp @@ -252,7 +252,7 @@ void RLPXHandshake::transition(boost::system::error_code _ech) } clog(NetNote) << (m_originated ? "p2p.connect.egress" : "p2p.connect.ingress") << "hello frame: success. starting session."; - RLP rlp(frame.cropped(1)); + RLP rlp(frame.cropped(1), RLP::ThrowOnFail | RLP::FailIfTooSmall); m_host->startPeerSession(m_remote, rlp, m_io, m_socket->remoteEndpoint()); } });