diff --git a/src/cpp/ripple/ConnectionPool.cpp b/src/cpp/ripple/ConnectionPool.cpp index 121eea8e63..85bc05ea5d 100644 --- a/src/cpp/ripple/ConnectionPool.cpp +++ b/src/cpp/ripple/ConnectionPool.cpp @@ -300,6 +300,7 @@ void ConnectionPool::connectTo(const std::string& strIp, int iPort) { if (theConfig.RUN_STANDALONE) return; + { Database* db = theApp->getWalletDB()->getDB(); ScopedLock sl(theApp->getWalletDB()->getDBLock()); diff --git a/src/cpp/ripple/Peer.cpp b/src/cpp/ripple/Peer.cpp index 76e396b3e3..c42108e2e3 100644 --- a/src/cpp/ripple/Peer.cpp +++ b/src/cpp/ripple/Peer.cpp @@ -430,24 +430,29 @@ void Peer::processReadBuffer() case ripple::mtCONTACT: { ripple::TMContact msg; + if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE)) recvContact(msg); else cLog(lsWARNING) << "parse error: " << type; } break; + case ripple::mtGET_PEERS: { ripple::TMGetPeers msg; + if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE)) recvGetPeers(msg); else cLog(lsWARNING) << "parse error: " << type; } break; + case ripple::mtPEERS: { ripple::TMPeers msg; + if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE)) recvPeers(msg); else @@ -666,7 +671,17 @@ void Peer::recvHello(ripple::TMHello& packet) std::string strIP = getSocket().remote_endpoint().address().to_string(); int iPort = packet.ipv4port(); - theApp->getConnectionPool().savePeer(strIP, iPort, UniqueNodeList::vsInbound); + if (mHello.nodeprivate()) + { + cLog(lsINFO) << boost::str(boost::format("Recv(Hello): Private connection: %s %s") % strIP % iPort); + } + else + { + // Don't save IP address if the node wants privacy. + // Note: We don't go so far as to delete it. If a node which has previously announced itself now wants + // privacy, it should at least change its port. + theApp->getConnectionPool().savePeer(strIP, iPort, UniqueNodeList::vsInbound); + } } // Consider us connected. No longer accepting mtHELLO. @@ -994,7 +1009,7 @@ void Peer::recvGetContacts(ripple::TMGetContacts& packet) { } -// return a list of your favorite people +// Return a list of your favorite people // TODO: filter out all the LAN peers // TODO: filter out the peer you are talking to void Peer::recvGetPeers(ripple::TMGetPeers& packet) @@ -1510,6 +1525,7 @@ void Peer::sendHello() h.set_nodepublic(theApp->getWallet().getNodePublic().humanNodePublic()); h.set_nodeproof(&vchSig[0], vchSig.size()); h.set_ipv4port(theConfig.PEER_PORT); + h.set_nodeprivate(theConfig.PEER_PRIVATE); Ledger::pointer closedLedger = theApp->getMasterLedger().getClosedLedger(); if (closedLedger && closedLedger->isClosed()) @@ -1526,7 +1542,7 @@ void Peer::sendHello() void Peer::sendGetPeers() { - // get other peers this guy knows about + // Ask peer for known other peers. ripple::TMGetPeers getPeers; getPeers.set_doweneedthis(1); diff --git a/src/cpp/ripple/Peer.h b/src/cpp/ripple/Peer.h index 3865e8aa3c..f3c29c0f24 100644 --- a/src/cpp/ripple/Peer.h +++ b/src/cpp/ripple/Peer.h @@ -49,6 +49,7 @@ private: ipPort mIpPortConnect; uint256 mCookieHash; uint64 mPeerId; + bool mPrivate; // Keep peer IP private. uint256 mClosedLedgerHash, mPreviousLedgerHash; std::list mRecentLedgers; diff --git a/src/cpp/ripple/ripple.proto b/src/cpp/ripple/ripple.proto index 6d2292436c..5ffbb657df 100644 --- a/src/cpp/ripple/ripple.proto +++ b/src/cpp/ripple/ripple.proto @@ -34,7 +34,6 @@ enum MessageType { // Sent on connect - message TMHello { required uint32 protoVersion = 1; required uint32 protoVersionMin = 2; @@ -46,6 +45,7 @@ message TMHello { optional uint32 ledgerIndex = 8; optional bytes ledgerClosed = 9; // our last closed ledger optional bytes ledgerPrevious = 10; // the ledger before the last closed ledger + optional bool nodePrivate = 11; // Request to not forward IP. }