mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 19:15:54 +00:00
fix connect
This commit is contained in:
@@ -2413,8 +2413,16 @@ static RPCCallTestData const rpcCallTestArray[] = {
|
|||||||
"ThereIsNoCheckingOnTheIPFormat",
|
"ThereIsNoCheckingOnTheIPFormat",
|
||||||
"-1",
|
"-1",
|
||||||
},
|
},
|
||||||
RPCCallTestData::bad_cast,
|
RPCCallTestData::no_exception,
|
||||||
R"()"},
|
R"({
|
||||||
|
"method" : "connect",
|
||||||
|
"params" : [
|
||||||
|
{
|
||||||
|
"error" : "invalidParams",
|
||||||
|
"error_message" : "Invalid field 'port'."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})"},
|
||||||
{// Note: this should return an error but not throw.
|
{// Note: this should return an error but not throw.
|
||||||
"connect: port too large.",
|
"connect: port too large.",
|
||||||
__LINE__,
|
__LINE__,
|
||||||
@@ -2423,8 +2431,16 @@ static RPCCallTestData const rpcCallTestArray[] = {
|
|||||||
"ThereIsNoCheckingOnTheIPFormat",
|
"ThereIsNoCheckingOnTheIPFormat",
|
||||||
"4294967296",
|
"4294967296",
|
||||||
},
|
},
|
||||||
RPCCallTestData::bad_cast,
|
RPCCallTestData::no_exception,
|
||||||
R"()"},
|
R"({
|
||||||
|
"method" : "connect",
|
||||||
|
"params" : [
|
||||||
|
{
|
||||||
|
"error" : "invalidParams",
|
||||||
|
"error_message" : "Invalid field 'port'."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})"},
|
||||||
|
|
||||||
// consensus_info
|
// consensus_info
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
|
|||||||
@@ -455,7 +455,10 @@ private:
|
|||||||
if (jvParams.size() == 2)
|
if (jvParams.size() == 2)
|
||||||
{
|
{
|
||||||
jvRequest[jss::ip] = ip;
|
jvRequest[jss::ip] = ip;
|
||||||
jvRequest[jss::port] = jvParams[1u].asUInt();
|
if (auto port = jvParseUInt(jvParams[1u]))
|
||||||
|
jvRequest[jss::port] = *port;
|
||||||
|
else
|
||||||
|
return RPC::invalid_field_error(jss::port);
|
||||||
return jvRequest;
|
return jvRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,8 +467,13 @@ private:
|
|||||||
{
|
{
|
||||||
std::size_t colon = ip.find_last_of(":");
|
std::size_t colon = ip.find_last_of(":");
|
||||||
jvRequest[jss::ip] = std::string{ip, 0, colon};
|
jvRequest[jss::ip] = std::string{ip, 0, colon};
|
||||||
jvRequest[jss::port] =
|
|
||||||
Json::Value{std::string{ip, colon + 1}}.asUInt();
|
std::uint32_t port;
|
||||||
|
if (beast::lexicalCastChecked(port, std::string{ip, colon + 1}))
|
||||||
|
jvRequest[jss::port] = port;
|
||||||
|
else
|
||||||
|
return RPC::invalid_field_error(jss::port);
|
||||||
|
|
||||||
return jvRequest;
|
return jvRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user