mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Trim space in Endpoint::from_string
Fixes: RIPD-1643
This commit is contained in:
committed by
Nik Bougalis
parent
68bebc472a
commit
8098cba4c2
@@ -21,6 +21,7 @@
|
||||
#endif
|
||||
|
||||
#include <ripple/beast/net/IPEndpoint.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
namespace beast {
|
||||
namespace IP {
|
||||
@@ -38,7 +39,7 @@ Endpoint::Endpoint (Address const& addr, Port port)
|
||||
|
||||
std::pair <Endpoint, bool> Endpoint::from_string_checked (std::string const& s)
|
||||
{
|
||||
std::stringstream is (s);
|
||||
std::stringstream is (boost::trim_copy(s));
|
||||
Endpoint endpoint;
|
||||
is >> endpoint;
|
||||
if (! is.fail() && is.rdbuf()->in_avail() == 0)
|
||||
|
||||
@@ -219,6 +219,11 @@ public:
|
||||
shouldParseEPV4("1.2.3.4", {{1,2,3,4}}, 0);
|
||||
shouldParseEPV4("1.2.3.4:5", {{1,2,3,4}}, 5);
|
||||
shouldParseEPV4("1.2.3.4 5", {{1,2,3,4}}, 5, "1.2.3.4:5");
|
||||
// leading, trailing space
|
||||
shouldParseEPV4(" 1.2.3.4:5", {{1,2,3,4}}, 5, "1.2.3.4:5");
|
||||
shouldParseEPV4("1.2.3.4:5 ", {{1,2,3,4}}, 5, "1.2.3.4:5");
|
||||
shouldParseEPV4("1.2.3.4 ", {{1,2,3,4}}, 0, "1.2.3.4");
|
||||
shouldParseEPV4(" 1.2.3.4", {{1,2,3,4}}, 0, "1.2.3.4");
|
||||
shouldParseEPV6(
|
||||
"2001:db8:a0b:12f0::1",
|
||||
{{32, 01, 13, 184, 10, 11, 18, 240, 0, 0, 0, 0, 0, 0, 0, 1}},
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <ripple/basics/contract.h>
|
||||
#include <ripple/core/Config.h>
|
||||
#include <ripple/core/ConfigSections.h>
|
||||
#include <ripple/server/Port.h>
|
||||
#include <test/jtx/TestSuite.h>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/format.hpp>
|
||||
@@ -40,7 +41,7 @@ port_wss_admin
|
||||
[port_rpc]
|
||||
port = 5005
|
||||
ip = 127.0.0.1
|
||||
admin = 127.0.0.1
|
||||
admin = 127.0.0.1, ::1
|
||||
protocol = https
|
||||
|
||||
[port_peer]
|
||||
@@ -852,6 +853,24 @@ trustthesevalidators.gov
|
||||
}
|
||||
}
|
||||
|
||||
void testPort ()
|
||||
{
|
||||
detail::RippledCfgGuard const cfg(*this, "testPort", "", "");
|
||||
auto const& conf = cfg.config();
|
||||
if (!BEAST_EXPECT(conf.exists("port_rpc")))
|
||||
return;
|
||||
if (!BEAST_EXPECT(conf.exists("port_wss_admin")))
|
||||
return;
|
||||
ParsedPort rpc;
|
||||
if (!unexcept([&]() { parse_Port (rpc, conf["port_rpc"], log); }))
|
||||
return;
|
||||
BEAST_EXPECT(rpc.admin_ip && (rpc.admin_ip .get().size() == 2));
|
||||
ParsedPort wss;
|
||||
if (!unexcept([&]() { parse_Port (wss, conf["port_wss_admin"], log); }))
|
||||
return;
|
||||
BEAST_EXPECT(wss.admin_ip && (wss.admin_ip .get().size() == 1));
|
||||
}
|
||||
|
||||
void run () override
|
||||
{
|
||||
testLegacy ();
|
||||
@@ -860,6 +879,7 @@ trustthesevalidators.gov
|
||||
testValidatorsFile ();
|
||||
testSetup (false);
|
||||
testSetup (true);
|
||||
testPort ();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user