Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Allow disablement of net_plugin's listen socket #6459

Merged
merged 1 commit into from
Dec 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2935,7 +2935,7 @@ namespace eosio {
my->use_socket_read_watermark = options.at( "use-socket-read-watermark" ).as<bool>();

my->resolver = std::make_shared<tcp::resolver>( std::ref( app().get_io_service()));
if( options.count( "p2p-listen-endpoint" )) {
if( options.count( "p2p-listen-endpoint" ) && options.at("p2p-listen-endpoint").as<string>().length()) {
my->p2p_address = options.at( "p2p-listen-endpoint" ).as<string>();
auto host = my->p2p_address.substr( 0, my->p2p_address.find( ':' ));
auto port = my->p2p_address.substr( host.size() + 1, my->p2p_address.size());
Expand All @@ -2946,21 +2946,22 @@ namespace eosio {
my->listen_endpoint = *my->resolver->resolve( query );

my->acceptor.reset( new tcp::acceptor( app().get_io_service()));
}
if( options.count( "p2p-server-address" )) {
my->p2p_address = options.at( "p2p-server-address" ).as<string>();
} else {
if( my->listen_endpoint.address().to_v4() == address_v4::any()) {
boost::system::error_code ec;
auto host = host_name( ec );
if( ec.value() != boost::system::errc::success ) {

FC_THROW_EXCEPTION( fc::invalid_arg_exception,
"Unable to retrieve host_name. ${msg}", ("msg", ec.message()));
if( options.count( "p2p-server-address" )) {
my->p2p_address = options.at( "p2p-server-address" ).as<string>();
} else {
if( my->listen_endpoint.address().to_v4() == address_v4::any()) {
boost::system::error_code ec;
auto host = host_name( ec );
if( ec.value() != boost::system::errc::success ) {

FC_THROW_EXCEPTION( fc::invalid_arg_exception,
"Unable to retrieve host_name. ${msg}", ("msg", ec.message()));

}
auto port = my->p2p_address.substr( my->p2p_address.find( ':' ), my->p2p_address.size());
my->p2p_address = host + port;
}
auto port = my->p2p_address.substr( my->p2p_address.find( ':' ), my->p2p_address.size());
my->p2p_address = host + port;
}
}

Expand Down