File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ static std::unordered_set<std::string> const TESTING_ONLY_OPTIONS = {
7777
7878// Options that should only be used for testing
7979static std::unordered_set<std::string> const TESTING_SUGGESTED_OPTIONS = {
80- " ALLOW_LOCALHOST_FOR_TESTING" };
80+ " ALLOW_LOCALHOST_FOR_TESTING" , " ALLOW_PRIVATE_ADDRESSES_FOR_TESTING " };
8181
8282namespace
8383{
@@ -155,6 +155,7 @@ Config::Config() : NODE_SEED(SecretKey::random())
155155 IGNORE_MESSAGE_LIMITS_FOR_TESTING = false ;
156156 TESTING_IGNORE_LEDGER_TIME_UPGRADE_BOUNDS = false ;
157157 TESTING_NOMINATE_RANDOM_VALUES = false ;
158+ ALLOW_PRIVATE_ADDRESSES_FOR_TESTING = false ;
158159#endif
159160
160161 FORCE_SCP = false ;
@@ -1278,6 +1279,10 @@ Config::processConfig(std::shared_ptr<cpptoml::table> t)
12781279 }},
12791280 {" IGNORE_MESSAGE_LIMITS_FOR_TESTING" ,
12801281 [&]() { IGNORE_MESSAGE_LIMITS_FOR_TESTING = readBool (item); }},
1282+ {" ALLOW_PRIVATE_ADDRESSES_FOR_TESTING" ,
1283+ [&]() {
1284+ ALLOW_PRIVATE_ADDRESSES_FOR_TESTING = readBool (item);
1285+ }},
12811286#endif // BUILD_TESTS
12821287 {" ARTIFICIALLY_GENERATE_LOAD_FOR_TESTING" ,
12831288 [&]() {
Original file line number Diff line number Diff line change @@ -922,6 +922,13 @@ class Config : public std::enable_shared_from_this<Config>
922922 // When set to true, ignores all message and tx set size limits for testing
923923 bool IGNORE_MESSAGE_LIMITS_FOR_TESTING ;
924924
925+ // A config to allow gossiping (advertising and accepting in PEERS
926+ // messages) and connecting to RFC1918 private addresses (10/8, 172.16/12,
927+ // 192.168/16). Private addresses are normally filtered out of peer
928+ // exchange, which disables gossip-based peer discovery in environments
929+ // where every node has a private address (e.g. a Kubernetes pod network).
930+ bool ALLOW_PRIVATE_ADDRESSES_FOR_TESTING ;
931+
925932 // When set, disables validation of the ledger target close time
926933 // bounds on config upgrades (for testing only).
927934 bool TESTING_IGNORE_LEDGER_TIME_UPGRADE_BOUNDS ;
Original file line number Diff line number Diff line change @@ -2018,7 +2018,12 @@ Peer::recvPeers(StellarMessage const& msg)
20182018 releaseAssert (peer.ip .type () == IPv4);
20192019 auto address = PeerBareAddress{peer};
20202020
2021- if (address.isPrivate ())
2021+ bool allowPrivateAddresses = false ;
2022+ #ifdef BUILD_TESTS
2023+ allowPrivateAddresses =
2024+ mAppConnector .getConfig ().ALLOW_PRIVATE_ADDRESSES_FOR_TESTING ;
2025+ #endif
2026+ if (address.isPrivate () && !allowPrivateAddresses)
20222027 {
20232028 CLOG_DEBUG (Overlay, " ignoring received private address {}" ,
20242029 address.toString ());
Original file line number Diff line number Diff line change @@ -211,8 +211,12 @@ std::vector<PeerBareAddress>
211211PeerManager::getPeersToSend (size_t size, PeerBareAddress const & address)
212212{
213213 ZoneScoped;
214+ bool allowPrivate = false ;
215+ #ifdef BUILD_TESTS
216+ allowPrivate = mApp .getConfig ().ALLOW_PRIVATE_ADDRESSES_FOR_TESTING ;
217+ #endif
214218 auto keep = [&](PeerBareAddress const & pba) {
215- return !pba.isPrivate () && pba != address;
219+ return (allowPrivate || !pba.isPrivate () ) && pba != address;
216220 };
217221
218222 auto peers = mOutboundPeersToSend ->getRandomPeers (size, keep);
You can’t perform that action at this time.
0 commit comments