mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
net: isolate the protocol-agnostic part of CConnman::AcceptConnection()
Isolate the second half of `CConnman::AcceptConnection()` into a new separate method, which could be reused if we accept incoming connections by other means than `accept()` (first half of `CConnman::AcceptConnection()`).
This commit is contained in:
14
src/net.cpp
14
src/net.cpp
@@ -1005,8 +1005,6 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
|
||||
socklen_t len = sizeof(sockaddr);
|
||||
SOCKET hSocket = accept(hListenSocket.socket, (struct sockaddr*)&sockaddr, &len);
|
||||
CAddress addr;
|
||||
int nInbound = 0;
|
||||
int nMaxInbound = nMaxConnections - m_max_outbound;
|
||||
|
||||
if (hSocket == INVALID_SOCKET) {
|
||||
const int nErr = WSAGetLastError();
|
||||
@@ -1024,6 +1022,18 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
|
||||
|
||||
NetPermissionFlags permissionFlags = NetPermissionFlags::PF_NONE;
|
||||
hListenSocket.AddSocketPermissionFlags(permissionFlags);
|
||||
|
||||
CreateNodeFromAcceptedSocket(hSocket, permissionFlags, addr_bind, addr);
|
||||
}
|
||||
|
||||
void CConnman::CreateNodeFromAcceptedSocket(SOCKET hSocket,
|
||||
NetPermissionFlags permissionFlags,
|
||||
const CAddress& addr_bind,
|
||||
const CAddress& addr)
|
||||
{
|
||||
int nInbound = 0;
|
||||
int nMaxInbound = nMaxConnections - m_max_outbound;
|
||||
|
||||
AddWhitelistPermissionFlags(permissionFlags, addr);
|
||||
if (NetPermissions::HasFlag(permissionFlags, NetPermissionFlags::PF_ISIMPLICIT)) {
|
||||
NetPermissions::ClearFlag(permissionFlags, PF_ISIMPLICIT);
|
||||
|
||||
Reference in New Issue
Block a user