src/net.cpp
void AdvertiseLocal(CNode *pnode)
{
    if (fListen && pnode->fSuccessfullyConnected)
    {
        CAddress addrLocal = 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 us that it sees us as in case it has a better idea of our
        // address than we do.
        FastRandomContext rng;
        if (IsPeerAddrLocalGood(pnode) && (!addrLocal.IsRoutable() ||
             rng.randbits((GetnScore(addrLocal) > LOCAL_MANUAL) ? 3 : 1) == 0))
        {
            addrLocal.SetIP(pnode->GetAddrLocal());
        }
        if (addrLocal.IsRoutable() || gArgs.GetBoolArg("-addrmantest", false))
        {
            LogPrint(BCLog::NET, "AdvertiseLocal: advertising address %s\n", addrLocal.ToString());
            pnode->PushAddress(addrLocal, rng);
        }
    }
}
// pushes our own address to a peer
pushes our own address to a peer
pushes our own address to a peer
void AdvertiseLocal(CNode *pnode)
{
    if (fListen && pnode->fSuccessfullyConnected)
    {
        CAddress addrLocal = GetLocalAddress(&pnode->addr, pnode->GetLocalServices());
        if (gArgs.GetBoolArg("-addrmantest", false)) {
            addrLocal = CAddress(CService(LookupNumeric("127.0.0.1", GetListenPort())), pnode->GetLocalServices());
        }
        FastRandomContext rng;
        if (IsPeerAddrLocalGood(pnode) && (!addrLocal.IsRoutable() ||
             rng.randbits((GetnScore(addrLocal) > LOCAL_MANUAL) ? 3 : 1) == 0))
        {
            addrLocal.SetIP(pnode->GetAddrLocal());
        }
        if (addrLocal.IsRoutable() || gArgs.GetBoolArg("-addrmantest", false))
        {
            LogPrint(BCLog::NET, "AdvertiseLocal: advertising address %s\n", addrLocal.ToString());
            pnode->PushAddress(addrLocal, rng);
        }
    }
}
void AdvertiseLocal ( CNode * pnode ) { if ( fListen && pnode -> fSuccessfullyConnected ) { CAddress addrLocal = GetLocalAddress ( & pnode -> addr , pnode -> GetLocalServices ( ) ) ; if ( gArgs . GetBoolArg ( " " , false ) ) { addrLocal = CAddress ( CService ( LookupNumeric ( " " , GetListenPort ( ) ) ) , pnode -> GetLocalServices ( ) ) ; } FastRandomContext rng ; if ( IsPeerAddrLocalGood ( pnode ) && ( ! addrLocal . IsRoutable ( ) || rng . randbits ( ( GetnScore ( addrLocal ) > LOCAL_MANUAL ) ? 3 : 1 ) == 0 ) ) { addrLocal . SetIP ( pnode -> GetAddrLocal ( ) ) ; } if ( addrLocal . IsRoutable ( ) || gArgs . GetBoolArg ( " " , false ) ) { LogPrint ( BCLog :: NET , " \n " , addrLocal . ToString ( ) ) ; pnode -> PushAddress ( addrLocal , rng ) ; } } }
pushes our own address to a peer
pushes our own address to a peer
// use IPv4 loopback during addrmantest // 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 than we do.