added early check of ExtAddrFinder and notify about its results

This commit is contained in:
csoler 2021-02-03 22:36:24 +01:00
parent d4141c493d
commit 67cf8baf77

View File

@ -466,6 +466,30 @@ void p3NetMgrIMPL::netStatusTick()
} }
if(netStatus <= RS_NET_UPNP_SETUP && mUseExtAddrFinder)
{
sockaddr_storage tmpip;
if(mExtAddrFinder->hasValidIP(tmpip) && sockaddr_storage_ipv6_to_ipv4(tmpip))
{
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext supplied by ExtAddrFinder" << std::endl;
#endif
sockaddr_storage_setport(tmpip, guessNewExtPort());
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
std::cerr << "p3NetMgrIMPL::netExtCheck() ";
std::cerr << "ExtAddr: " << sockaddr_storage_tostring(tmpip);
std::cerr << std::endl;
#endif
/* XXX HACK TO FIX drbob: ALLOWING
* ExtAddrFinder -> ExtAddrStableOk = true
* (which it is not normally) */
setExtAddress(tmpip);
}
}
switch(netStatus) switch(netStatus)
{ {
case RS_NET_NEEDS_RESET: case RS_NET_NEEDS_RESET:
@ -518,6 +542,10 @@ void p3NetMgrIMPL::netStatusTick()
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET) #if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
std::cerr << "p3NetMgrIMPL::netTick() STATUS: EXT_SETUP" << std::endl; std::cerr << "p3NetMgrIMPL::netTick() STATUS: EXT_SETUP" << std::endl;
#endif #endif
// This could take a lot of time on some systems to get there:
// (e.g. 10 mins to get passed upnp on windows), so it would be better to call it right away, so other external address finding
// systems still have a chance to run early.
netExtCheck(); netExtCheck();
break; break;