mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 01:16:20 -05:00
only use external up from DHT stunner as fallback when no other source provides a valid IP
This commit is contained in:
parent
f27022fe7b
commit
f019a71472
@ -711,49 +711,6 @@ void p3NetMgrIMPL::netExtCheck()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ALLOW_DHT_STUNNER
|
|
||||||
// (cyril) I disabled this because it's pretty dangerous. The DHT can report a wrong address quite easily
|
|
||||||
// if the other DHT peers are not collaborating.
|
|
||||||
// (sehraf) For the record: The udp stunner uses multiple (as for now: two) peers to ensure that the IP recieved is the correct one, see UdpStunner::locked_checkExternalAddress()
|
|
||||||
// Nevertheless this stays a more risky method to determine the external ip address.
|
|
||||||
|
|
||||||
/* Next ask the DhtStunner */
|
|
||||||
{
|
|
||||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
|
||||||
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext Not Ok, Checking DhtStunner" << std::endl;
|
|
||||||
#endif
|
|
||||||
uint8_t isstable = 0;
|
|
||||||
struct sockaddr_storage tmpaddr;
|
|
||||||
sockaddr_storage_clear(tmpaddr);
|
|
||||||
|
|
||||||
if (mDhtStunner)
|
|
||||||
{
|
|
||||||
/* input network bits */
|
|
||||||
if (mDhtStunner->getExternalAddr(tmpaddr, isstable))
|
|
||||||
{
|
|
||||||
if((rsBanList == NULL) || rsBanList->isAddressAccepted(tmpaddr,RSBANLIST_CHECKING_FLAGS_BLACKLIST))
|
|
||||||
{
|
|
||||||
// must be stable???
|
|
||||||
isStable = (isstable == 1);
|
|
||||||
//mNetFlags.mExtAddr = tmpaddr;
|
|
||||||
mNetFlags.mExtAddrOk = true;
|
|
||||||
mNetFlags.mExtAddrStableOk = isStable;
|
|
||||||
|
|
||||||
address_votes[tmpaddr].n++ ;
|
|
||||||
#ifdef NETMGR_DEBUG_STATEBOX
|
|
||||||
std::cerr << "p3NetMgrIMPL::netExtCheck() From DhtStunner: ";
|
|
||||||
std::cerr << sockaddr_storage_tostring(tmpaddr);
|
|
||||||
std::cerr << " Stable: " << (uint32_t) isstable;
|
|
||||||
std::cerr << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
std::cerr << "(SS) DHTStunner returned wrong own IP " << sockaddr_storage_iptostring(tmpaddr) << " (banned). Rejecting." << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* ask ExtAddrFinder */
|
/* ask ExtAddrFinder */
|
||||||
{
|
{
|
||||||
/* ExtAddrFinder */
|
/* ExtAddrFinder */
|
||||||
@ -831,6 +788,49 @@ void p3NetMgrIMPL::netExtCheck()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ALLOW_DHT_STUNNER
|
||||||
|
// (cyril) I disabled this because it's pretty dangerous. The DHT can report a wrong address quite easily
|
||||||
|
// if the other DHT peers are not collaborating.
|
||||||
|
// (sehraf) For the record: The udp stunner uses multiple (as for now: two) peers to ensure that the IP recieved is the correct one, see UdpStunner::locked_checkExternalAddress()
|
||||||
|
// Nevertheless this stays a more risky method to determine the external ip address.
|
||||||
|
|
||||||
|
/* lastly ask the DhtStunner as fallback */
|
||||||
|
if (address_votes.empty()) {
|
||||||
|
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||||
|
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext Not Ok, Checking DhtStunner" << std::endl;
|
||||||
|
#endif
|
||||||
|
uint8_t isstable = 0;
|
||||||
|
struct sockaddr_storage tmpaddr;
|
||||||
|
sockaddr_storage_clear(tmpaddr);
|
||||||
|
|
||||||
|
if (mDhtStunner)
|
||||||
|
{
|
||||||
|
/* input network bits */
|
||||||
|
if (mDhtStunner->getExternalAddr(tmpaddr, isstable))
|
||||||
|
{
|
||||||
|
if((rsBanList == NULL) || rsBanList->isAddressAccepted(tmpaddr,RSBANLIST_CHECKING_FLAGS_BLACKLIST))
|
||||||
|
{
|
||||||
|
// must be stable???
|
||||||
|
isStable = (isstable == 1);
|
||||||
|
//mNetFlags.mExtAddr = tmpaddr;
|
||||||
|
mNetFlags.mExtAddrOk = true;
|
||||||
|
mNetFlags.mExtAddrStableOk = isStable;
|
||||||
|
|
||||||
|
address_votes[tmpaddr].n++ ;
|
||||||
|
#ifdef NETMGR_DEBUG_STATEBOX
|
||||||
|
std::cerr << "p3NetMgrIMPL::netExtCheck() From DhtStunner: ";
|
||||||
|
std::cerr << sockaddr_storage_tostring(tmpaddr);
|
||||||
|
std::cerr << " Stable: " << (uint32_t) isstable;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
std::cerr << "(SS) DHTStunner returned wrong own IP " << sockaddr_storage_iptostring(tmpaddr) << " (banned). Rejecting." << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* any other sources ??? */
|
/* any other sources ??? */
|
||||||
|
|
||||||
/* finalise address */
|
/* finalise address */
|
||||||
|
Loading…
Reference in New Issue
Block a user