Changeset View
Changeset View
Standalone View
Standalone View
src/net.cpp
Show First 20 Lines • Show All 176 Lines • ▼ Show 20 Lines | return fDiscover && pnode->addr.IsRoutable() && addrLocal.IsRoutable() && | ||||
!IsLimited(addrLocal.GetNetwork()); | !IsLimited(addrLocal.GetNetwork()); | ||||
} | } | ||||
// Pushes our own address to a peer. | // Pushes our own address to a peer. | ||||
void AdvertiseLocal(CNode *pnode) { | void AdvertiseLocal(CNode *pnode) { | ||||
if (fListen && pnode->fSuccessfullyConnected) { | if (fListen && pnode->fSuccessfullyConnected) { | ||||
CAddress addrLocal = | CAddress addrLocal = | ||||
GetLocalAddress(&pnode->addr, pnode->GetLocalServices()); | GetLocalAddress(&pnode->addr, pnode->GetLocalServices()); | ||||
if (gArgs.GetBoolArg("-addrmantest", false)) { | |||||
// use IPv4 loopback during addrmantest | |||||
addrLocal = | |||||
CAddress(CService(LookupNumeric("127.0.0.1", GetListenPort())), | |||||
pnode->GetLocalServices()); | |||||
} | |||||
// If discovery is enabled, sometimes give our peer the address it tells | // If discovery is enabled, sometimes give our peer the address it tells | ||||
// us that it sees us as in case it has a better idea of our address | // us that it sees us as in case it has a better idea of our address | ||||
// than we do. | // than we do. | ||||
if (IsPeerAddrLocalGood(pnode) && | if (IsPeerAddrLocalGood(pnode) && | ||||
(!addrLocal.IsRoutable() || | (!addrLocal.IsRoutable() || | ||||
GetRand((GetnScore(addrLocal) > LOCAL_MANUAL) ? 8 : 2) == 0)) { | GetRand((GetnScore(addrLocal) > LOCAL_MANUAL) ? 8 : 2) == 0)) { | ||||
addrLocal.SetIP(pnode->GetAddrLocal()); | addrLocal.SetIP(pnode->GetAddrLocal()); | ||||
} | } | ||||
if (addrLocal.IsRoutable()) { | if (addrLocal.IsRoutable() || gArgs.GetBoolArg("-addrmantest", false)) { | ||||
LogPrint(BCLog::NET, "AdvertiseLocal: advertising address %s\n", | LogPrint(BCLog::NET, "AdvertiseLocal: advertising address %s\n", | ||||
addrLocal.ToString()); | addrLocal.ToString()); | ||||
FastRandomContext insecure_rand; | FastRandomContext insecure_rand; | ||||
pnode->PushAddress(addrLocal, insecure_rand); | pnode->PushAddress(addrLocal, insecure_rand); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,887 Lines • Show Last 20 Lines |