mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 03:26:01 +00:00
Resolve hostnames found in the [ips] config section
This commit is contained in:
committed by
Vinnie Falco
parent
28c7827f14
commit
73485d5a23
@@ -60,39 +60,36 @@
|
||||
#
|
||||
# [ips]
|
||||
#
|
||||
# List of ips where the Ripple protocol is served. For a starter list,
|
||||
# you can copy entries from: https://ripple.com/ripple.txt
|
||||
# List of hostnames or ips where the Ripple protocol is served. For a starter
|
||||
# list, you can either copy entries from: https://ripple.com/ripple.txt or if
|
||||
# you prefer you can specify r.ripple.com 51235
|
||||
#
|
||||
# Domain names are not allowed. 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.
|
||||
# One IPv4 address or domain names per line is allowed. 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
|
||||
# r.ripple.com 51235
|
||||
#
|
||||
# Here's the recent set of good, well known addresses:
|
||||
# This will give you a good, up-to-date list of addresses:
|
||||
#
|
||||
# [ips]
|
||||
# 54.225.112.220 51235
|
||||
# 54.225.123.13 51235
|
||||
# 54.227.239.106 51235
|
||||
# 107.21.251.218 51235
|
||||
# 184.73.226.101 51235
|
||||
# 23.23.201.55 51235
|
||||
# r.ripple.com 51235
|
||||
#
|
||||
#
|
||||
#
|
||||
# [ips_fixed]
|
||||
#
|
||||
# List of IP addresses to which rippled should always maintain peer
|
||||
# connections with. This is useful for manually forming private networks,
|
||||
# for example to configure a validation server that connects to the
|
||||
# List of IP addresses or hostnames to which rippled should always attempt to
|
||||
# maintain peer connections with. This is useful for manually forming private
|
||||
# networks, for example to configure a validation server that connects to the
|
||||
# Ripple network through a public-facing server, or for building a set
|
||||
# of cluster peers.
|
||||
#
|
||||
#
|
||||
# One IPv4 address or domain names per line is allowed. A port may optionally
|
||||
# be specified after adding a space to the address.
|
||||
#
|
||||
# [peer_ip]
|
||||
#
|
||||
@@ -813,15 +810,9 @@ time.nist.gov
|
||||
pool.ntp.org
|
||||
|
||||
# Where to find some other servers speaking the Ripple protocol.
|
||||
# This set of addresses is recent as of September 5, 2013
|
||||
#
|
||||
[ips]
|
||||
54.225.112.220 51235
|
||||
54.225.123.13 51235
|
||||
54.227.239.106 51235
|
||||
107.21.251.218 51235
|
||||
184.73.226.101 51235
|
||||
23.23.201.55 51235
|
||||
r.ripple.com 51235
|
||||
|
||||
# These validators are taken from the v0.16 release notes on the wiki:
|
||||
# https://ripple.com/wiki/Latest_rippled_release_notes
|
||||
|
||||
@@ -193,47 +193,39 @@ public:
|
||||
|
||||
HostAndPort parseName(std::string const& str)
|
||||
{
|
||||
struct find_whitespace
|
||||
{
|
||||
bool operator() (const char c)
|
||||
{
|
||||
return std::isspace (c);
|
||||
}
|
||||
};
|
||||
// Attempt to find the first and last non-whitespace
|
||||
auto const find_whitespace = std::bind (
|
||||
std::isspace <std::string::value_type>,
|
||||
std::placeholders::_1,
|
||||
std::locale ());
|
||||
|
||||
struct find_port_separator
|
||||
{
|
||||
bool operator() (const char c)
|
||||
{
|
||||
if (std::isspace (c))
|
||||
return true;
|
||||
|
||||
if (c == ':')
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// Find the first non-whitespace
|
||||
auto host_first = std::find_if_not (
|
||||
str.begin (), str.end (), find_whitespace ());
|
||||
str.begin (), str.end (), find_whitespace);
|
||||
|
||||
// Find the last non-whitespace
|
||||
auto port_last = std::find_if_not (
|
||||
str.rbegin (), str.rend(), find_whitespace ()).base();
|
||||
str.rbegin (), str.rend(), find_whitespace).base();
|
||||
|
||||
// This should only happen for all-whitespace strings
|
||||
if (host_first >= port_last)
|
||||
return std::make_pair(std::string (), std::string ());
|
||||
|
||||
// Attempt to find the first valid port separator
|
||||
auto host_last = std::find_if (
|
||||
host_first, port_last, find_port_separator ());
|
||||
// Attempt to find the first and last valid port separators
|
||||
auto const find_port_separator = [](char const c) -> bool
|
||||
{
|
||||
if (std::isspace (c))
|
||||
return true;
|
||||
|
||||
if (c == ':')
|
||||
return true;
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
auto host_last = std::find_if (
|
||||
host_first, port_last, find_port_separator);
|
||||
|
||||
// Attempt to find the last valid port separator
|
||||
auto port_first = std::find_if_not (
|
||||
host_last, port_last, find_port_separator ());
|
||||
host_last, port_last, find_port_separator);
|
||||
|
||||
return make_pair (
|
||||
std::string (host_first, host_last),
|
||||
|
||||
@@ -947,10 +947,11 @@ public:
|
||||
{
|
||||
int count (0);
|
||||
SharedState::Access state (m_state);
|
||||
for (IPAddresses::const_iterator iter (
|
||||
list.begin()); iter != list.end(); ++iter)
|
||||
if (addBootcacheAddress (*iter, state))
|
||||
for (auto addr : list)
|
||||
{
|
||||
if (addBootcacheAddress (addr, state))
|
||||
++count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,9 +44,9 @@ public:
|
||||
results.addresses.reserve (m_strings.size());
|
||||
for (int i = 0; i < m_strings.size (); ++i)
|
||||
{
|
||||
IP::Endpoint ep (
|
||||
IP::Endpoint::from_string_altform (
|
||||
m_strings [i]));
|
||||
IP::Endpoint ep (IP::Endpoint::from_string (m_strings [i]));
|
||||
if (is_unspecified (ep))
|
||||
ep = IP::Endpoint::from_string_altform (m_strings [i]);
|
||||
if (! is_unspecified (ep))
|
||||
results.addresses.push_back (ep);
|
||||
}
|
||||
|
||||
@@ -411,30 +411,36 @@ public:
|
||||
|
||||
m_peerFinder->setConfig (config);
|
||||
|
||||
// Add the static IPs from the rippled.cfg file
|
||||
m_peerFinder->addFallbackStrings ("rippled.cfg", getConfig().IPS);
|
||||
if (!getConfig ().IPS.empty ())
|
||||
{
|
||||
m_resolver.resolve (getConfig ().IPS,
|
||||
[this](
|
||||
std::string const& name,
|
||||
std::vector <IP::Endpoint> const& addresses)
|
||||
{
|
||||
std::vector <std::string> ips;
|
||||
|
||||
for (auto const& addr : addresses)
|
||||
ips.push_back (to_string (addr));
|
||||
|
||||
std::string const base ("config: ");
|
||||
|
||||
if (!ips.empty ())
|
||||
m_peerFinder->addFallbackStrings (base + name, ips);
|
||||
});
|
||||
}
|
||||
|
||||
// Add the ips_fixed from the rippled.cfg file
|
||||
if (! getConfig ().RUN_STANDALONE && !getConfig ().IPS_FIXED.empty ())
|
||||
{
|
||||
struct resolve_fixed_peers
|
||||
{
|
||||
PeerFinder::Manager* m_peerFinder;
|
||||
|
||||
resolve_fixed_peers (PeerFinder::Manager* peerFinder)
|
||||
: m_peerFinder (peerFinder)
|
||||
{ }
|
||||
|
||||
void operator()(std::string const& name,
|
||||
std::vector <IP::Endpoint> const& address)
|
||||
{
|
||||
if (!address.empty())
|
||||
m_peerFinder->addFixedPeer (name, address);
|
||||
}
|
||||
};
|
||||
|
||||
m_resolver.resolve (getConfig ().IPS_FIXED,
|
||||
resolve_fixed_peers (m_peerFinder.get ()));
|
||||
[this](
|
||||
std::string const& name,
|
||||
std::vector <IP::Endpoint> const& addresses)
|
||||
{
|
||||
if (!addresses.empty ())
|
||||
m_peerFinder->addFixedPeer (name, addresses);
|
||||
});
|
||||
}
|
||||
|
||||
// Configure the peer doors, which allow the server to accept incoming
|
||||
|
||||
Reference in New Issue
Block a user