mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Improve transport security:
* Add fields for local and remote IP addresses in hello. * Add configuration for known local public IP address * Set fields appropriately * Check the fields * Disallow self connection by key
This commit is contained in:
@@ -596,7 +596,7 @@ void PeerImp::doAccept()
|
||||
|
||||
auto resp = makeResponse(
|
||||
! overlay_.peerFinder().config().peerPrivate,
|
||||
http_message_, sharedValue);
|
||||
http_message_, remote_address_, sharedValue);
|
||||
beast::http::write (write_buffer_, resp);
|
||||
|
||||
auto const protocol = BuildInfo::make_protocol(hello_.protoversion());
|
||||
@@ -636,7 +636,9 @@ void PeerImp::doAccept()
|
||||
|
||||
beast::http::message
|
||||
PeerImp::makeResponse (bool crawl,
|
||||
beast::http::message const& req, uint256 const& sharedValue)
|
||||
beast::http::message const& req,
|
||||
beast::IP::Endpoint remote,
|
||||
uint256 const& sharedValue)
|
||||
{
|
||||
beast::http::message resp;
|
||||
resp.request(false);
|
||||
@@ -648,7 +650,8 @@ PeerImp::makeResponse (bool crawl,
|
||||
resp.headers.append("Connect-AS", "Peer");
|
||||
resp.headers.append("Server", BuildInfo::getFullVersionString());
|
||||
resp.headers.append ("Crawl", crawl ? "public" : "private");
|
||||
protocol::TMHello hello = buildHello(sharedValue, app_);
|
||||
protocol::TMHello hello = buildHello(sharedValue,
|
||||
overlay_.setup().public_ip, remote, app_);
|
||||
appendHello(resp, hello);
|
||||
return resp;
|
||||
}
|
||||
@@ -1647,22 +1650,6 @@ PeerImp::sendGetPeers ()
|
||||
send (packet);
|
||||
}
|
||||
|
||||
bool
|
||||
PeerImp::sendHello()
|
||||
{
|
||||
bool success;
|
||||
std::tie(sharedValue_, success) = makeSharedValue(
|
||||
stream_.native_handle(), journal_);
|
||||
if (! success)
|
||||
return false;
|
||||
|
||||
auto const hello = buildHello (sharedValue_, app_);
|
||||
auto const m = std::make_shared<Message> (
|
||||
std::move(hello), protocol::mtHELLO);
|
||||
send (m);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
PeerImp::addLedger (uint256 const& hash)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user