File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -1005,8 +1005,6 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
10051005 socklen_t len = sizeof (sockaddr);
10061006 SOCKET hSocket = accept (hListenSocket.socket , (struct sockaddr *)&sockaddr, &len);
10071007 CAddress addr;
1008- int nInbound = 0 ;
1009- int nMaxInbound = nMaxConnections - m_max_outbound;
10101008
10111009 if (hSocket == INVALID_SOCKET) {
10121010 const int nErr = WSAGetLastError ();
@@ -1024,6 +1022,18 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
10241022
10251023 NetPermissionFlags permissionFlags = NetPermissionFlags::PF_NONE;
10261024 hListenSocket.AddSocketPermissionFlags (permissionFlags);
1025+
1026+ CreateNodeFromAcceptedSocket (hSocket, permissionFlags, addr_bind, addr);
1027+ }
1028+
1029+ void CConnman::CreateNodeFromAcceptedSocket (SOCKET hSocket,
1030+ NetPermissionFlags permissionFlags,
1031+ const CAddress& addr_bind,
1032+ const CAddress& addr)
1033+ {
1034+ int nInbound = 0 ;
1035+ int nMaxInbound = nMaxConnections - m_max_outbound;
1036+
10271037 AddWhitelistPermissionFlags (permissionFlags, addr);
10281038 if (NetPermissions::HasFlag (permissionFlags, NetPermissionFlags::PF_ISIMPLICIT)) {
10291039 NetPermissions::ClearFlag (permissionFlags, PF_ISIMPLICIT);
Original file line number Diff line number Diff line change @@ -1049,6 +1049,20 @@ class CConnman
10491049 void ThreadOpenConnections (std::vector<std::string> connect);
10501050 void ThreadMessageHandler ();
10511051 void AcceptConnection (const ListenSocket& hListenSocket);
1052+
1053+ /* *
1054+ * Create a `CNode` object from a socket that has just been accepted and add the node to
1055+ * the `vNodes` member.
1056+ * @param[in] hSocket Connected socket to communicate with the peer.
1057+ * @param[in] permissionFlags The peer's permissions.
1058+ * @param[in] addr_bind The address and port at our side of the connection.
1059+ * @param[in] addr The address and port at the peer's side of the connection.
1060+ */
1061+ void CreateNodeFromAcceptedSocket (SOCKET hSocket,
1062+ NetPermissionFlags permissionFlags,
1063+ const CAddress& addr_bind,
1064+ const CAddress& addr);
1065+
10521066 void DisconnectNodes ();
10531067 void NotifyNumConnectionsChanged ();
10541068 /* * Return true if the peer is inactive and should be disconnected. */
You can’t perform that action at this time.
0 commit comments