Gracefully not accept incoming connection (#1342)
This commit is contained in:
parent
80b71d9746
commit
e89b12d0c5
13
src/net.cpp
13
src/net.cpp
@ -963,12 +963,6 @@ static bool AttemptToEvictConnection(bool fPreferNewConnection) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void AcceptConnection(const ListenSocket& hListenSocket) {
|
static void AcceptConnection(const ListenSocket& hListenSocket) {
|
||||||
// don't accept incoming connections until fully synced
|
|
||||||
if(fMasterNode && !masternodeSync.IsSynced()) {
|
|
||||||
LogPrintf("AcceptConnection -- masternode is not synced yet, skipping inbound connection attempt\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct sockaddr_storage sockaddr;
|
struct sockaddr_storage sockaddr;
|
||||||
socklen_t len = sizeof(sockaddr);
|
socklen_t len = sizeof(sockaddr);
|
||||||
SOCKET hSocket = accept(hListenSocket.socket, (struct sockaddr*)&sockaddr, &len);
|
SOCKET hSocket = accept(hListenSocket.socket, (struct sockaddr*)&sockaddr, &len);
|
||||||
@ -1029,6 +1023,13 @@ static void AcceptConnection(const ListenSocket& hListenSocket) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// don't accept incoming connections until fully synced
|
||||||
|
if(fMasterNode && !masternodeSync.IsSynced()) {
|
||||||
|
LogPrintf("AcceptConnection -- masternode is not synced yet, skipping inbound connection attempt\n");
|
||||||
|
CloseSocket(hSocket);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CNode* pnode = new CNode(hSocket, addr, "", true);
|
CNode* pnode = new CNode(hSocket, addr, "", true);
|
||||||
pnode->fWhitelisted = whitelisted;
|
pnode->fWhitelisted = whitelisted;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user