Skip to content

Commit

Permalink
Merge pull request #636 from steemit/634-local-hostname-endpoints
Browse files Browse the repository at this point in the history
Can't use /etc/hosts hostnames for endpoints #634
  • Loading branch information
Michael Vandeberg authored Nov 29, 2016
2 parents 7e63a33 + 52fc68d commit f2d02ee
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions libraries/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ namespace detail {
}

if( _options->count("p2p-endpoint") )
_p2p_network->listen_on_endpoint(fc::ip::endpoint::from_string(_options->at("p2p-endpoint").as<string>()), true);
{
auto p2p_endpoint = _options->at("p2p-endpoint").as<string>();
auto endpoints = resolve_string_to_ip_endpoints( p2p_endpoint );
FC_ASSERT( endpoints.size(), "p2p-endpoint ${hostname} did not resolve", ("hostname", p2p_endpoint) );
_p2p_network->listen_on_endpoint( endpoints[0], true);
}
else
_p2p_network->listen_on_port(0, false);

Expand Down Expand Up @@ -172,8 +177,11 @@ namespace detail {
_websocket_server = std::make_shared<fc::http::websocket_server>();

_websocket_server->on_connection([&]( const fc::http::websocket_connection_ptr& c ){ on_connection(c); } );
ilog("Configured websocket rpc to listen on ${ip}", ("ip",_options->at("rpc-endpoint").as<string>()));
_websocket_server->listen( fc::ip::endpoint::from_string(_options->at("rpc-endpoint").as<string>()) );
auto rpc_endpoint = _options->at("rpc-endpoint").as<string>();
ilog("Configured websocket rpc to listen on ${ip}", ("ip", rpc_endpoint));
auto endpoints = resolve_string_to_ip_endpoints( rpc_endpoint );
FC_ASSERT( endpoints.size(), "rpc-endpoint ${hostname} did not resolve", ("hostname", rpc_endpoint) );
_websocket_server->listen( endpoints[0] );
_websocket_server->start_accept();
} FC_CAPTURE_AND_RETHROW() }

Expand All @@ -192,8 +200,11 @@ namespace detail {
_websocket_tls_server = std::make_shared<fc::http::websocket_tls_server>( _options->at("server-pem").as<string>(), password );

_websocket_tls_server->on_connection([this]( const fc::http::websocket_connection_ptr& c ){ on_connection(c); } );
ilog("Configured websocket TLS rpc to listen on ${ip}", ("ip",_options->at("rpc-tls-endpoint").as<string>()));
_websocket_tls_server->listen( fc::ip::endpoint::from_string(_options->at("rpc-tls-endpoint").as<string>()) );
auto rpc_tls_endpoint = _options->at("rpc-tls-endpoint").as<string>();
ilog("Configured websocket TLS rpc to listen on ${ip}", ("ip", rpc_tls_endpoint));
auto endpoints = resolve_string_to_ip_endpoints( rpc_tls_endpoint );
FC_ASSERT( endpoints.size(), "rpc-tls-endpoint ${hostname} did not resolve", ("hostname", rpc_tls_endpoint) );
_websocket_tls_server->listen( endpoints[0] );
_websocket_tls_server->start_accept();
} FC_CAPTURE_AND_RETHROW() }

Expand Down

0 comments on commit f2d02ee

Please sign in to comment.