@ -43,7 +43,7 @@ Host::Host(std::string const& _clientVersion, NetworkPreferences const& _n, bool
m_netPrefs ( _n ) ,
m_ifAddresses ( Network : : getInterfaceAddresses ( ) ) ,
m_ioService ( 2 ) ,
m_acceptorV4 ( m_ioService ) ,
m_tcp4Acceptor ( m_ioService ) ,
m_key ( KeyPair : : create ( ) )
{
for ( auto address : m_ifAddresses )
@ -95,9 +95,9 @@ void Host::doneWorking()
m_ioService . reset ( ) ;
// shutdown acceptor
m_acceptorV4 . cancel ( ) ;
if ( m_acceptorV4 . is_open ( ) )
m_acceptorV4 . close ( ) ;
m_tcp4Acceptor . cancel ( ) ;
if ( m_tcp4Acceptor . is_open ( ) )
m_tcp4Acceptor . close ( ) ;
// There maybe an incoming connection which started but hasn't finished.
// Wait for acceptor to end itself instead of assuming it's complete.
@ -280,7 +280,7 @@ void Host::determinePublic(string const& _publicAddress, bool _upnp)
{
if ( ! m_peerAddresses . count ( reqpublicaddr ) )
m_peerAddresses . insert ( reqpublicaddr ) ;
m_public = reqpublic ;
m_tc pP ublic = reqpublic ;
return ;
}
@ -288,7 +288,7 @@ void Host::determinePublic(string const& _publicAddress, bool _upnp)
for ( auto addr : m_peerAddresses )
if ( addr . is_v4 ( ) & & ! isPrivateAddress ( addr ) )
{
m_public = bi : : tcp : : endpoint ( * m_peerAddresses . begin ( ) , m_listenPort ) ;
m_tc pP ublic = bi : : tcp : : endpoint ( * m_peerAddresses . begin ( ) , m_listenPort ) ;
return ;
}
@ -301,7 +301,7 @@ void Host::determinePublic(string const& _publicAddress, bool _upnp)
{
if ( ! m_peerAddresses . count ( upnpep . address ( ) ) )
m_peerAddresses . insert ( upnpep . address ( ) ) ;
m_public = upnpep ;
m_tc pP ublic = upnpep ;
return ;
}
}
@ -312,12 +312,12 @@ void Host::determinePublic(string const& _publicAddress, bool _upnp)
for ( auto addr : m_peerAddresses )
if ( addr . is_v4 ( ) & & isPrivateAddress ( addr ) )
{
m_public = bi : : tcp : : endpoint ( addr , m_listenPort ) ;
m_tc pP ublic = bi : : tcp : : endpoint ( addr , m_listenPort ) ;
return ;
}
// otherwise address is unspecified
m_public = bi : : tcp : : endpoint ( bi : : address ( ) , m_listenPort ) ;
m_tc pP ublic = bi : : tcp : : endpoint ( bi : : address ( ) , m_listenPort ) ;
}
void Host : : runAcceptor ( )
@ -326,10 +326,10 @@ void Host::runAcceptor()
if ( m_run & & ! m_accepting )
{
clog ( NetConnect ) < < " Listening on local port " < < m_listenPort < < " (public: " < < m_public < < " ) " ;
clog ( NetConnect ) < < " Listening on local port " < < m_listenPort < < " (public: " < < m_tc pP ublic < < " ) " ;
m_accepting = true ;
m_socket . reset ( new bi : : tcp : : socket ( m_ioService ) ) ;
m_acceptorV4 . async_accept ( * m_socket , [ = ] ( boost : : system : : error_code ec )
m_tcp4Acceptor . async_accept ( * m_socket , [ = ] ( boost : : system : : error_code ec )
{
bool success = false ;
if ( ! ec )
@ -656,7 +656,7 @@ void Host::startedWorking()
}
// try to open acceptor (todo: ipv6)
m_listenPort = Network : : listen4 ( m_acceptorV4 , m_netPrefs . listenPort ) ;
m_listenPort = Network : : tcp4Listen ( m_tcp4Acceptor , m_netPrefs . listenPort ) ;
// start capability threads
for ( auto const & h : m_capabilities )
@ -674,8 +674,8 @@ void Host::startedWorking()
// if m_public address is valid then add us to node list
// todo: abstract empty() and emplace logic
if ( ! m_public . address ( ) . is_unspecified ( ) & & ( m_nodes . empty ( ) | | m_nodes [ m_nodesList [ 0 ] ] - > id ! = id ( ) ) )
noteNode ( id ( ) , m_public , Origin : : Perfect , false ) ;
if ( ! m_tc pP ublic . address ( ) . is_unspecified ( ) & & ( m_nodes . empty ( ) | | m_nodes [ m_nodesList [ 0 ] ] - > id ! = id ( ) ) )
noteNode ( id ( ) , m_tc pP ublic , Origin : : Perfect , false ) ;
clog ( NetNote ) < < " Id: " < < id ( ) . abridged ( ) ;
@ -739,7 +739,7 @@ void Host::restoreNodes(bytesConstRef _b)
{
auto oldId = id ( ) ;
m_key = KeyPair ( r [ 1 ] . toHash < Secret > ( ) ) ;
noteNode ( id ( ) , m_public , Origin : : Perfect , false , oldId ) ;
noteNode ( id ( ) , m_tc pP ublic , Origin : : Perfect , false , oldId ) ;
for ( auto i : r [ 2 ] )
{