@ -990,6 +990,12 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
return ;
return ;
}
}
if ( ! fNetworkActive ) {
LogPrintf ( " connection from %s dropped: not accepting new connections \n " , addr . ToString ( ) ) ;
CloseSocket ( hSocket ) ;
return ;
}
if ( ! IsSelectableSocket ( hSocket ) )
if ( ! IsSelectableSocket ( hSocket ) )
{
{
LogPrintf ( " connection from %s dropped: non-selectable socket \n " , addr . ToString ( ) ) ;
LogPrintf ( " connection from %s dropped: non-selectable socket \n " , addr . ToString ( ) ) ;
@ -1783,6 +1789,9 @@ bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
// Initiate outbound network connection
// Initiate outbound network connection
//
//
boost : : this_thread : : interruption_point ( ) ;
boost : : this_thread : : interruption_point ( ) ;
if ( ! fNetworkActive ) {
return false ;
}
if ( ! pszDest ) {
if ( ! pszDest ) {
if ( IsLocal ( addrConnect ) | |
if ( IsLocal ( addrConnect ) | |
FindNode ( ( CNetAddr ) addrConnect ) | | IsBanned ( addrConnect ) | |
FindNode ( ( CNetAddr ) addrConnect ) | | IsBanned ( addrConnect ) | |
@ -2024,8 +2033,28 @@ void Discover(boost::thread_group& threadGroup)
# endif
# endif
}
}
void CConnman : : SetNetworkActive ( bool active )
{
if ( fDebug ) {
LogPrint ( " net " , " SetNetworkActive: %s \n " , active ) ;
}
if ( ! active ) {
fNetworkActive = false ;
LOCK ( cs_vNodes ) ;
// Close sockets to all nodes
BOOST_FOREACH ( CNode * pnode , vNodes ) {
pnode - > CloseSocketDisconnect ( ) ;
}
} else {
fNetworkActive = true ;
}
}
CConnman : : CConnman ( uint64_t nSeed0In , uint64_t nSeed1In ) : nSeed0 ( nSeed0In ) , nSeed1 ( nSeed1In )
CConnman : : CConnman ( uint64_t nSeed0In , uint64_t nSeed1In ) : nSeed0 ( nSeed0In ) , nSeed1 ( nSeed1In )
{
{
fNetworkActive = true ;
setBannedIsDirty = false ;
setBannedIsDirty = false ;
fAddressesInitialized = false ;
fAddressesInitialized = false ;
nLastNodeId = 0 ;
nLastNodeId = 0 ;