@@ -402,7 +402,8 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
402
402
pszDest ? 0.0 : (double )(GetAdjustedTime () - addrConnect.nTime )/3600.0 );
403
403
404
404
// Resolve
405
- const uint16_t default_port{Params ().GetDefaultPort ()};
405
+ const uint16_t default_port{pszDest != nullptr ? Params ().GetDefaultPort (pszDest) :
406
+ Params ().GetDefaultPort ()};
406
407
if (pszDest) {
407
408
std::vector<CService> resolved;
408
409
if (Lookup (pszDest, resolved, default_port, fNameLookup && !HaveNameProxy (), 256 ) && !resolved.empty ()) {
@@ -2059,8 +2060,9 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
2059
2060
// from advertising themselves as a service on another host and
2060
2061
// port, causing a DoS attack as nodes around the network attempt
2061
2062
// to connect to it fruitlessly.
2062
- if (addr.GetPort () != Params ().GetDefaultPort () && nTries < 50 )
2063
+ if (addr.GetPort () != Params ().GetDefaultPort (addr. GetNetwork ()) && nTries < 50 ) {
2063
2064
continue ;
2065
+ }
2064
2066
2065
2067
addrConnect = addr;
2066
2068
break ;
@@ -2123,7 +2125,7 @@ std::vector<AddedNodeInfo> CConnman::GetAddedNodeInfo() const
2123
2125
}
2124
2126
2125
2127
for (const std::string& strAddNode : lAddresses) {
2126
- CService service (LookupNumeric (strAddNode, Params ().GetDefaultPort ()));
2128
+ CService service (LookupNumeric (strAddNode, Params ().GetDefaultPort (strAddNode )));
2127
2129
AddedNodeInfo addedNode{strAddNode, CService (), false , false };
2128
2130
if (service.IsValid ()) {
2129
2131
// strAddNode is an IP:port
0 commit comments