Merge pull request #18 from abitmore/bts2-bts-fix-dns-exception-rework

Catch DNS exceptions when adding seed nodes
This commit is contained in:
abitmore 2016-09-15 16:38:13 +02:00 committed by GitHub
commit 252e34a3e1

View file

@ -125,6 +125,7 @@ namespace detail {
auto seeds = _options->at("seed-node").as<vector<string>>(); auto seeds = _options->at("seed-node").as<vector<string>>();
for( const string& endpoint_string : seeds ) for( const string& endpoint_string : seeds )
{ {
try {
std::vector<fc::ip::endpoint> endpoints = resolve_string_to_ip_endpoints(endpoint_string); std::vector<fc::ip::endpoint> endpoints = resolve_string_to_ip_endpoints(endpoint_string);
for (const fc::ip::endpoint& endpoint : endpoints) for (const fc::ip::endpoint& endpoint : endpoints)
{ {
@ -132,6 +133,10 @@ namespace detail {
_p2p_network->add_node(endpoint); _p2p_network->add_node(endpoint);
_p2p_network->connect_to_endpoint(endpoint); _p2p_network->connect_to_endpoint(endpoint);
} }
} catch( const fc::exception& e ) {
wlog( "caught exception ${e} while adding seed node ${endpoint}",
("e", e.to_detail_string())("endpoint", endpoint_string) );
}
} }
} }
@ -141,12 +146,17 @@ namespace detail {
auto seeds = fc::json::from_string(seeds_str).as<vector<string>>(); auto seeds = fc::json::from_string(seeds_str).as<vector<string>>();
for( const string& endpoint_string : seeds ) for( const string& endpoint_string : seeds )
{ {
try {
std::vector<fc::ip::endpoint> endpoints = resolve_string_to_ip_endpoints(endpoint_string); std::vector<fc::ip::endpoint> endpoints = resolve_string_to_ip_endpoints(endpoint_string);
for (const fc::ip::endpoint& endpoint : endpoints) for (const fc::ip::endpoint& endpoint : endpoints)
{ {
ilog("Adding seed node ${endpoint}", ("endpoint", endpoint)); ilog("Adding seed node ${endpoint}", ("endpoint", endpoint));
_p2p_network->add_node(endpoint); _p2p_network->add_node(endpoint);
} }
} catch( const fc::exception& e ) {
wlog( "caught exception ${e} while adding seed node ${endpoint}",
("e", e.to_detail_string())("endpoint", endpoint_string) );
}
} }
} }
else else
@ -172,12 +182,17 @@ namespace detail {
}; };
for( const string& endpoint_string : seeds ) for( const string& endpoint_string : seeds )
{ {
try {
std::vector<fc::ip::endpoint> endpoints = resolve_string_to_ip_endpoints(endpoint_string); std::vector<fc::ip::endpoint> endpoints = resolve_string_to_ip_endpoints(endpoint_string);
for (const fc::ip::endpoint& endpoint : endpoints) for (const fc::ip::endpoint& endpoint : endpoints)
{ {
ilog("Adding seed node ${endpoint}", ("endpoint", endpoint)); ilog("Adding seed node ${endpoint}", ("endpoint", endpoint));
_p2p_network->add_node(endpoint); _p2p_network->add_node(endpoint);
} }
} catch( const fc::exception& e ) {
wlog( "caught exception ${e} while adding seed node ${endpoint}",
("e", e.to_detail_string())("endpoint", endpoint_string) );
}
} }
} }