mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
net: Minor accumulated cleanups
This commit is contained in:
27
src/net.cpp
27
src/net.cpp
@@ -1923,23 +1923,25 @@ std::vector<AddedNodeInfo> CConnman::GetAddedNodeInfo()
|
||||
|
||||
for (const std::string& strAddNode : lAddresses) {
|
||||
CService service(LookupNumeric(strAddNode.c_str(), Params().GetDefaultPort()));
|
||||
AddedNodeInfo addedNode{strAddNode, CService(), false, false};
|
||||
if (service.IsValid()) {
|
||||
// strAddNode is an IP:port
|
||||
auto it = mapConnected.find(service);
|
||||
if (it != mapConnected.end()) {
|
||||
ret.push_back(AddedNodeInfo{strAddNode, service, true, it->second});
|
||||
} else {
|
||||
ret.push_back(AddedNodeInfo{strAddNode, CService(), false, false});
|
||||
addedNode.resolvedAddress = service;
|
||||
addedNode.fConnected = true;
|
||||
addedNode.fInbound = it->second;
|
||||
}
|
||||
} else {
|
||||
// strAddNode is a name
|
||||
auto it = mapConnectedByName.find(strAddNode);
|
||||
if (it != mapConnectedByName.end()) {
|
||||
ret.push_back(AddedNodeInfo{strAddNode, it->second.second, true, it->second.first});
|
||||
} else {
|
||||
ret.push_back(AddedNodeInfo{strAddNode, CService(), false, false});
|
||||
addedNode.resolvedAddress = it->second.second;
|
||||
addedNode.fConnected = true;
|
||||
addedNode.fInbound = it->second.first;
|
||||
}
|
||||
}
|
||||
ret.emplace_back(std::move(addedNode));
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -2088,23 +2090,16 @@ bool CConnman::BindListenPort(const CService &addrBind, std::string& strError, b
|
||||
LogPrintf("%s\n", strError);
|
||||
return false;
|
||||
}
|
||||
#ifndef WIN32
|
||||
|
||||
// Allow binding if the port is still in TIME_WAIT state after
|
||||
// the program was closed and restarted.
|
||||
setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (void*)&nOne, sizeof(int));
|
||||
#else
|
||||
setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (const char*)&nOne, sizeof(int));
|
||||
#endif
|
||||
setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (sockopt_arg_type)&nOne, sizeof(int));
|
||||
|
||||
// some systems don't have IPV6_V6ONLY but are always v6only; others do have the option
|
||||
// and enable it by default or not. Try to enable it, if possible.
|
||||
if (addrBind.IsIPv6()) {
|
||||
#ifdef IPV6_V6ONLY
|
||||
#ifdef WIN32
|
||||
setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&nOne, sizeof(int));
|
||||
#else
|
||||
setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&nOne, sizeof(int));
|
||||
#endif
|
||||
setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (sockopt_arg_type)&nOne, sizeof(int));
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
int nProtLevel = PROTECTION_LEVEL_UNRESTRICTED;
|
||||
|
||||
Reference in New Issue
Block a user