From 3cb3b41ceff88ad31e39a9734b227f3ff9cf7fad Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Tue, 20 Nov 2012 13:13:52 -0800 Subject: [PATCH 1/6] Rename unl_default to validators_file. --- rippled-example.cfg | 146 ++++++++++++++++++++++++++++++ src/cpp/ripple/Config.cpp | 6 +- src/cpp/ripple/Config.h | 2 +- src/cpp/ripple/RPCHandler.cpp | 2 +- src/cpp/ripple/UniqueNodeList.cpp | 6 +- 5 files changed, 154 insertions(+), 8 deletions(-) create mode 100644 rippled-example.cfg diff --git a/rippled-example.cfg b/rippled-example.cfg new file mode 100644 index 000000000..a57fa3a8c --- /dev/null +++ b/rippled-example.cfg @@ -0,0 +1,146 @@ +# +# Sample rippled.cfg +# +# This file contains configuration information for rippled. +# +# This file should be named rippled.cfg. This file is UTF-8 with Dos, UNIX, +# or Mac style end of lines. Blank lines and lines beginning with '#' are +# ignored. Undefined sections are reserved. No escapes are currently defined. +# +# When you launch rippled, it will attempt to find this file. For details, +# refer to the manual page for --conf command line option. +# +# [debug_logfile] +# Specifies were a debug logfile is kept. By default, no debug log is kept +# +# Example: debug.log +# +# [validators_site]: +# Specifies where to find validators.txt for UNL boostrapping and RPC command unl_network. +# During alpha testing, this defaults to: redstem.com +# +# Example: ripple.com +# +# [validators_file]: +# Specifies how to bootstrap the UNL list. The UNL list is based on a +# validators.txt file and is maintained in the databases. When rippled +# starts up, if the databases are missing or are obsolete due to an upgrade +# of rippled, rippled will reconstruct the UNL list as specified here. +# +# If this entry is not present or empty, rippled will look for a validators.txt in the +# config directory. If not found there, it will attempt to retrieve the file +# from the Ripple foundation's web site. +# +# This entry is also used by the RPC command unl_load. +# +# Specify the file by specifying its full path. +# +# Examples: +# C:/home/johndoe/ripple/validators.txt +# /home/johndoe/ripple/validators.txt +# +# [validators]: +# Only valid in "rippled.cfg", "ripple.txt", and the referered [validators_url]. +# List of nodes to accept as validators speficied by public key or domain. +# +# For domains, rippled will probe for https web servers at the specied +# domain in the following order: ripple.DOMAIN, www.DOMAIN, DOMAIN +# +# Examples: +# redstem.com +# n9KorY8QtTdRx7TVDpwnG9NvyxsDwHUKUEeDLY3AkiGncVaSXZi5 +# n9MqiExBcoG19UXwoLjBJnhsxEhAZMuWwJDRdkyDz1EkEkwzQTNt John Doe +# +# [ips]: +# Only valid in "rippled.cfg", "ripple.txt", and the referered [ips_url]. +# List of ips where the Newcoin protocol is avialable. +# One ipv4 or ipv6 address per line. +# A port may optionally be specified after adding a space to the address. +# By convention, if known, IPs are listed in from most to least trusted. +# +# Examples: +# 192.168.0.1 +# 192.168.0.1 3939 +# 2001:0db8:0100:f101:0210:a4ff:fee3:9566 +# +# [sntp_servers] +# IP address or domain of servers to use for time synchronization. +# The default time servers are suitable for servers located in the United States +# +# [peer_ip]: +# IP address or domain to bind to allow external connections from peers. +# Defaults to not allow external connections from peers. +# +# Examples: 0.0.0.0 - Bind on all interfaces. +# +# [peer_port]: +# Port to bind to allow external connections from peers. +# +# [rpc_ip]: +# IP address or domain to bind to allow insecure RPC connections. +# Defaults to not allow RPC connections. +# +# [rpc_port]: +# Port to bind to if allowing insecure RPC connections. +# +# [rpc_allow_remote]: +# 0 or 1. 0 only allows RPC connections from 127.0.0.1. [default 0] +# +# [websocket_ip]: +# IP address or domain to bind to allow client connections. +# +# Examples: 0.0.0.0 - Bind on all interfaces. +# 127.0.0.1 - Bind on localhost interface. Only local programs may connect. +# +# [websocket_port]: +# Port to bind to allow client connections. +# +# [validation_seed]: +# To perform validation, this section should contain either a validation seed or key. +# The validation seed is used to generate the validation public/private key pair. +# To obtain a validation seed, use the validation_create command. +# +# Examples: RASH BUSH MILK LOOK BAD BRIM AVID GAFF BAIT ROT POD LOVE +# shfArahZT9Q9ckTf3s1psJ7C7qzVN +# + +[peer_ip] +0.0.0.0 + +[peer_port] +51235 + +[rpc_ip] +127.0.0.1 + +[rpc_port] +5005 + +[rpc_allow_remote] +1 + +[websocket_ip] +0.0.0.0 + +[websocket_port] +5006 + +[debug_logfile] +log/debug.log + +[sntp_servers] +time.windows.com +time.apple.com +time.nist.gov +pool.ntp.org + +[validation_seed] +shh1D4oj5czH3PUEjYES8c7Bay3tE + +[unl_default] +validators.txt + +[ips] +23.21.167.100 51235 +23.23.201.55 51235 +107.21.116.214 51235 diff --git a/src/cpp/ripple/Config.cpp b/src/cpp/ripple/Config.cpp index 8a665ff13..68f2e3192 100644 --- a/src/cpp/ripple/Config.cpp +++ b/src/cpp/ripple/Config.cpp @@ -27,7 +27,7 @@ #define SECTION_RPC_IP "rpc_ip" #define SECTION_RPC_PORT "rpc_port" #define SECTION_SNTP "sntp_servers" -#define SECTION_UNL_DEFAULT "unl_default" +#define SECTION_VALIDATORS_FILE "validators_file" #define SECTION_VALIDATION_QUORUM "validation_quorum" #define SECTION_VALIDATION_SEED "validation_seed" #define SECTION_WEBSOCKET_PUBLIC_IP "websocket_public_ip" @@ -292,8 +292,8 @@ void Config::load() if (sectionSingleB(secConfig, SECTION_ACCOUNT_PROBE_MAX, strTemp)) ACCOUNT_PROBE_MAX = boost::lexical_cast(strTemp); - if (sectionSingleB(secConfig, SECTION_UNL_DEFAULT, strTemp)) - UNL_DEFAULT = strTemp; + if (sectionSingleB(secConfig, SECTION_VALIDATORS_FILE, strTemp)) + VALIDATORS_FILE = strTemp; if (sectionSingleB(secConfig, SECTION_DEBUG_LOGFILE, strTemp)) DEBUG_LOGFILE = strTemp; diff --git a/src/cpp/ripple/Config.h b/src/cpp/ripple/Config.h index 3807b51df..199b4292e 100644 --- a/src/cpp/ripple/Config.h +++ b/src/cpp/ripple/Config.h @@ -50,7 +50,7 @@ public: boost::filesystem::path CONFIG_DIR; boost::filesystem::path DATA_DIR; boost::filesystem::path DEBUG_LOGFILE; - boost::filesystem::path UNL_DEFAULT; + boost::filesystem::path VALIDATORS_FILE; std::string VALIDATORS_SITE; // Where to find validators.txt on the Internet. std::vector VALIDATORS; // Validators from rippled.cfg. diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index ba9f6f78b..6d6a4595e 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -1638,7 +1638,7 @@ Json::Value RPCHandler::doUnlList(const Json::Value& params) // Populate the UNL from a local validators.txt file. Json::Value RPCHandler::doUnlLoad(const Json::Value& params) { - if (theConfig.UNL_DEFAULT.empty() || !theApp->getUNL().nodeLoad(theConfig.UNL_DEFAULT)) + if (theConfig.VALIDATORS_FILE.empty() || !theApp->getUNL().nodeLoad(theConfig.VALIDATORS_FILE)) { return rpcError(rpcLOAD_FAILED); } diff --git a/src/cpp/ripple/UniqueNodeList.cpp b/src/cpp/ripple/UniqueNodeList.cpp index f372fcba7..9b9c55a5d 100644 --- a/src/cpp/ripple/UniqueNodeList.cpp +++ b/src/cpp/ripple/UniqueNodeList.cpp @@ -1576,15 +1576,15 @@ void UniqueNodeList::nodeBootstrap() bool bLoaded = iDomains || iNodes; // Always merge in the file specified in the config. - if (!theConfig.UNL_DEFAULT.empty()) + if (!theConfig.VALIDATORS_FILE.empty()) { cLog(lsINFO) << "Bootstrapping UNL: loading from unl_default."; - bLoaded = nodeLoad(theConfig.UNL_DEFAULT); + bLoaded = nodeLoad(theConfig.VALIDATORS_FILE); } // If never loaded anything try the current directory. - if (!bLoaded && theConfig.UNL_DEFAULT.empty()) + if (!bLoaded && theConfig.VALIDATORS_FILE.empty()) { cLog(lsINFO) << "Bootstrapping UNL: loading from '" VALIDATORS_FILE_NAME "'."; From 97c577e5b222c8018cb53a8063d9c993ef0c46de Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Tue, 20 Nov 2012 13:14:45 -0800 Subject: [PATCH 2/6] Fix compiler warning. --- src/cpp/ripple/Transactor.cpp | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/cpp/ripple/Transactor.cpp b/src/cpp/ripple/Transactor.cpp index 1157bf8c2..01861525f 100644 --- a/src/cpp/ripple/Transactor.cpp +++ b/src/cpp/ripple/Transactor.cpp @@ -15,11 +15,11 @@ Transactor::pointer Transactor::makeTransactor(const SerializedTransaction& txn, { switch(txn.getTxnType()) { - case ttPAYMENT: + case ttPAYMENT: return( Transactor::pointer(new PaymentTransactor(txn,params,engine)) ); - case ttACCOUNT_SET: + case ttACCOUNT_SET: return( Transactor::pointer(new AccountSetTransactor(txn,params,engine)) ); - case ttREGULAR_KEY_SET: + case ttREGULAR_KEY_SET: return( Transactor::pointer(new RegularKeySetTransactor(txn,params,engine)) ); case ttTRUST_SET: return( Transactor::pointer(new TrustSetTransactor(txn,params,engine)) ); @@ -35,14 +35,11 @@ Transactor::pointer Transactor::makeTransactor(const SerializedTransaction& txn, } -Transactor::Transactor(const SerializedTransaction& txn,TransactionEngineParams params, TransactionEngine* engine) : mTxn(txn), mParams(params), mEngine(engine) +Transactor::Transactor(const SerializedTransaction& txn,TransactionEngineParams params, TransactionEngine* engine) : mTxn(txn), mEngine(engine), mParams(params) { mHasAuthKey=false; } - - - void Transactor::calculateFee() { mFeeDue = theConfig.FEE_DEFAULT; @@ -61,7 +58,7 @@ TER Transactor::payFee() } if( !saPaid ) return tesSUCCESS; - + // Deduct the fee, so it's not available during the transaction. // Will only write the account back, if the transaction succeeds. if (mSourceBalance < saPaid) @@ -73,12 +70,11 @@ TER Transactor::payFee() return terINSUF_FEE_B; } - + mSourceBalance -= saPaid; mTxnAccount->setFieldAmount(sfBalance, mSourceBalance); - - return tesSUCCESS; + return tesSUCCESS; } @@ -108,7 +104,7 @@ TER Transactor::checkSig() return temBAD_AUTH_MASTER; } - + return tesSUCCESS; } @@ -133,11 +129,10 @@ TER Transactor::checkSeq() if (mEngine->getLedger()->hasTransaction(txID)) return tefALREADY; } - + cLog(lsWARNING) << "applyTransaction: past sequence number"; return tefPAST_SEQ; - }else { mTxnAccount->setFieldU32(sfSequence, t_seq + 1); @@ -209,12 +204,13 @@ TER Transactor::apply() terResult=checkSig(); if(terResult != tesSUCCESS) return(terResult); - + terResult=checkSeq(); if(terResult != tesSUCCESS) return(terResult); mEngine->entryModify(mTxnAccount); return doApply(); - -} \ No newline at end of file +} + +// vim:ts=4 From 17a6b79ed98a32533ad62430d63b15858392d511 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Tue, 20 Nov 2012 13:15:14 -0800 Subject: [PATCH 3/6] Rename example files. --- ripple.txt => ripple-example.txt | 0 rippled.cfg | 145 ----------------------- validators.txt => validators-example.txt | 0 3 files changed, 145 deletions(-) rename ripple.txt => ripple-example.txt (100%) delete mode 100644 rippled.cfg rename validators.txt => validators-example.txt (100%) diff --git a/ripple.txt b/ripple-example.txt similarity index 100% rename from ripple.txt rename to ripple-example.txt diff --git a/rippled.cfg b/rippled.cfg deleted file mode 100644 index c86e2324b..000000000 --- a/rippled.cfg +++ /dev/null @@ -1,145 +0,0 @@ -# -# Sample rippled.cfg -# -# This file should be named rippled.cfg. This file is UTF-8 with Dos, UNIX, -# or Mac style end of lines. Blank lines and lines beginning with '#' are -# ignored. Undefined sections are reserved. No escapes are currently defined. -# -# When you launch rippled, it will attempt to find this file. For details, -# refer to the manual page for --conf command line option. -# -# [debug_logfile] -# Specifies were a debug logfile is kept. By default, no debug log is kept -# -# Example: debug.log -# -# [validators_site]: -# Specifies where to find validators.txt for UNL boostrapping and RPC command unl_network. -# During alpha testing, this defaults to: redstem.com -# -# Example: ripple.com -# -# [unl_default]: -# XXX This should be called: [validators_file] -# Specifies how to bootstrap the UNL list. The UNL list is based on a -# validators.txt file and is maintained in the databases. When rippled -# starts up, if the databases are missing or are obsolete due to an upgrade -# of rippled, rippled will reconstruct the UNL list as specified here. -# -# If this entry is not present or empty, rippled will look for a validators.txt in the -# config directory. If not found there, it will attempt to retrieve the file -# from the Ripple foundation's web site. -# -# This entry is also used by the RPC command unl_load. -# -# Specify the file by specifying its full path. -# -# Examples: -# C:/home/johndoe/ripple/validators.txt -# /home/johndoe/ripple/validators.txt -# -# [validators]: -# Only valid in "rippled.cfg", "ripple.txt", and the referered [validators_url]. -# List of nodes to accept as validators speficied by public key or domain. -# -# For domains, rippled will probe for https web servers at the specied -# domain in the following order: ripple.DOMAIN, www.DOMAIN, DOMAIN -# -# Examples: -# redstem.com -# n9KorY8QtTdRx7TVDpwnG9NvyxsDwHUKUEeDLY3AkiGncVaSXZi5 -# n9MqiExBcoG19UXwoLjBJnhsxEhAZMuWwJDRdkyDz1EkEkwzQTNt John Doe -# -# [ips]: -# Only valid in "rippled.cfg", "ripple.txt", and the referered [ips_url]. -# List of ips where the Newcoin protocol is avialable. -# One ipv4 or ipv6 address per line. -# A port may optionally be specified after adding a space to the address. -# By convention, if known, IPs are listed in from most to least trusted. -# -# Examples: -# 192.168.0.1 -# 192.168.0.1 3939 -# 2001:0db8:0100:f101:0210:a4ff:fee3:9566 -# -# [sntp_servers] -# IP address or domain of servers to use for time synchronization. -# The default time servers are suitable for servers located in the United States -# -# [peer_ip]: -# IP address or domain to bind to allow external connections from peers. -# Defaults to not allow external connections from peers. -# -# Examples: 0.0.0.0 - Bind on all interfaces. -# -# [peer_port]: -# Port to bind to allow external connections from peers. -# -# [rpc_ip]: -# IP address or domain to bind to allow insecure RPC connections. -# Defaults to not allow RPC connections. -# -# [rpc_port]: -# Port to bind to if allowing insecure RPC connections. -# -# [rpc_allow_remote]: -# 0 or 1. 0 only allows RPC connections from 127.0.0.1. [default 0] -# -# [websocket_ip]: -# IP address or domain to bind to allow client connections. -# -# Examples: 0.0.0.0 - Bind on all interfaces. -# 127.0.0.1 - Bind on localhost interface. Only local programs may connect. -# -# [websocket_port]: -# Port to bind to allow client connections. -# -# [validation_seed]: -# To perform validation, this section should contain either a validation seed or key. -# The validation seed is used to generate the validation public/private key pair. -# To obtain a validation seed, use the validation_create command. -# -# Examples: RASH BUSH MILK LOOK BAD BRIM AVID GAFF BAIT ROT POD LOVE -# shfArahZT9Q9ckTf3s1psJ7C7qzVN -# - -[peer_ip] -0.0.0.0 - -[peer_port] -51235 - -[rpc_ip] -127.0.0.1 - -[rpc_port] -5005 - -[rpc_allow_remote] -1 - -[websocket_ip] -0.0.0.0 - -[websocket_port] -5006 - -[debug_logfile] -log/debug.log - -[sntp_servers] -time.windows.com -time.apple.com -time.nist.gov -pool.ntp.org - -[validation_seed] -shh1D4oj5czH3PUEjYES8c7Bay3tE - -[unl_default] -validators.txt - -[ips] -23.21.167.100 51235 -23.23.201.55 51235 -107.21.116.214 51235 diff --git a/validators.txt b/validators-example.txt similarity index 100% rename from validators.txt rename to validators-example.txt From a014bc5843c87ae5cfce38ae605adffa01ea4de5 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Tue, 20 Nov 2012 14:03:48 -0800 Subject: [PATCH 4/6] Build tags in base directory for editors. --- .gitignore | 1 + SConstruct | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5053c37ba..85a6c74ba 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ # Ignore object files. *.o build +tags # Ignore locally installed node_modules node_modules diff --git a/SConstruct b/SConstruct index 63c2f5ac8..458f48c94 100644 --- a/SConstruct +++ b/SConstruct @@ -132,7 +132,7 @@ for file in RIPPLE_SRCS: rippled = env.Program('build/rippled', RIPPLE_OBJS) -tags = env.CTags('build/obj/tags', RIPPLE_SRCS) +tags = env.CTags('tags', RIPPLE_SRCS) Default(rippled, tags) From ea00a2d0d06d1afbeec650f416b6fc8df78f4510 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Tue, 20 Nov 2012 14:47:55 -0800 Subject: [PATCH 5/6] Add configuration support for peer_private. --- rippled-example.cfg | 8 +++++++- src/cpp/ripple/Config.cpp | 6 ++++++ src/cpp/ripple/Config.h | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/rippled-example.cfg b/rippled-example.cfg index a57fa3a8c..0bbd0f5dd 100644 --- a/rippled-example.cfg +++ b/rippled-example.cfg @@ -76,6 +76,11 @@ # [peer_port]: # Port to bind to allow external connections from peers. # +# [peer_private]: +# 0 or 1. +# 0: allow peers to broadcast your address. [default] +# 1: request peers not broadcast your address. +# # [rpc_ip]: # IP address or domain to bind to allow insecure RPC connections. # Defaults to not allow RPC connections. @@ -84,7 +89,8 @@ # Port to bind to if allowing insecure RPC connections. # # [rpc_allow_remote]: -# 0 or 1. 0 only allows RPC connections from 127.0.0.1. [default 0] +# 0 or 1. +# 0: only allows RPC connections from 127.0.0.1. [default] # # [websocket_ip]: # IP address or domain to bind to allow client connections. diff --git a/src/cpp/ripple/Config.cpp b/src/cpp/ripple/Config.cpp index 68f2e3192..18c60c235 100644 --- a/src/cpp/ripple/Config.cpp +++ b/src/cpp/ripple/Config.cpp @@ -20,6 +20,7 @@ #define SECTION_PEER_CONNECT_LOW_WATER "peer_connect_low_water" #define SECTION_PEER_IP "peer_ip" #define SECTION_PEER_PORT "peer_port" +#define SECTION_PEER_PRIVATE "peer_private" #define SECTION_PEER_SCAN_INTERVAL_MIN "peer_scan_interval_min" #define SECTION_PEER_SSL_CIPHER_LIST "peer_ssl_cipher_list" #define SECTION_PEER_START_MAX "peer_start_max" @@ -143,6 +144,8 @@ void Config::setup(const std::string& strConf) PEER_START_MAX = DEFAULT_PEER_START_MAX; PEER_CONNECT_LOW_WATER = DEFAULT_PEER_CONNECT_LOW_WATER; + PEER_PRIVATE = false; + TRANSACTION_FEE_BASE = 1000; NETWORK_QUORUM = 0; // Don't need to see other nodes @@ -222,6 +225,9 @@ void Config::load() if (sectionSingleB(secConfig, SECTION_PEER_PORT, strTemp)) PEER_PORT = boost::lexical_cast(strTemp); + if (sectionSingleB(secConfig, SECTION_PEER_PRIVATE, strTemp)) + PEER_PRIVATE = boost::lexical_cast(strTemp); + (void) sectionSingleB(secConfig, SECTION_RPC_IP, RPC_IP); if (sectionSingleB(secConfig, SECTION_RPC_PORT, strTemp)) diff --git a/src/cpp/ripple/Config.h b/src/cpp/ripple/Config.h index 199b4292e..2caf47abf 100644 --- a/src/cpp/ripple/Config.h +++ b/src/cpp/ripple/Config.h @@ -66,7 +66,7 @@ public: int LEDGER_SECONDS; int LEDGER_PROPOSAL_DELAY_SECONDS; int LEDGER_AVALANCHE_SECONDS; - bool LEDGER_CREATOR; // should be false unless we are starting a new ledger + bool LEDGER_CREATOR; // Should be false unless we are starting a new ledger. bool RUN_STANDALONE; // Note: The following parameters do not relate to the UNL or trust at all @@ -81,6 +81,7 @@ public: int PEER_SCAN_INTERVAL_MIN; int PEER_START_MAX; unsigned int PEER_CONNECT_LOW_WATER; + bool PEER_PRIVATE; // True to ask peers not to relay current IP. // Websocket networking parameters std::string WEBSOCKET_PUBLIC_IP; // XXX Going away. Merge with the inbound peer connction. From ad4725ae744a833a8f4de53aacca0ef592d2faeb Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Tue, 20 Nov 2012 14:48:53 -0800 Subject: [PATCH 6/6] Add private peers. --- src/cpp/ripple/ConnectionPool.cpp | 1 + src/cpp/ripple/Peer.cpp | 22 +++++++++++++++++++--- src/cpp/ripple/Peer.h | 1 + src/cpp/ripple/ripple.proto | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/cpp/ripple/ConnectionPool.cpp b/src/cpp/ripple/ConnectionPool.cpp index 121eea8e6..85bc05ea5 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 76e396b3e..c42108e2e 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 3865e8aa3..f3c29c0f2 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 6d2292436..5ffbb657d 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. }