Implement IPv6 listening

With this commit IPv6-v3 surpass v0.6-IPv6-2 in term of features
  obsoleting it.
p3BitDht handle gracefully unwanted non IPv4 addresses
rsUdpStack handle gracefully unwanted non IPv4 addresses
pqissludp handle gracefully unwanted non IPv4 addresses
Move single address limitation workaround from
  p3discovery2::sendOwnContactInfo to better
  place p3PeerMgrIMPL::UpdateOwnAddress this way local address list is
  queried less often and only id there is some suggestion that it may
  have changed (probably ir will not be called all the times there is a
  changes in local network interfaces but is good enough)
Implement crossplatform rs_setsockopt to avoid too much ifdef around
Implement sockaddr_storage_copy to safely copy sockaddr_storage objects
This commit is contained in:
Gioacchino Mazzurco 2018-02-24 14:07:25 +01:00
parent b3c7d195c8
commit 4a138e07b9
No known key found for this signature in database
GPG key ID: A1FBCA3872E87051
14 changed files with 618 additions and 378 deletions

View file

@ -39,7 +39,9 @@ RsDisc *rsDisc = NULL;
* #define P3DISC_DEBUG 1
****/
static bool populateContactInfo(const peerState &detail, RsDiscContactItem *pkt,bool include_ip_information)
static bool populateContactInfo( const peerState &detail,
RsDiscContactItem *pkt,
bool include_ip_information )
{
pkt->clear();
@ -342,7 +344,7 @@ void p3discovery2::sendOwnContactInfo(const SSLID &sslid)
std::cerr << std::endl;
#endif
peerState detail;
if (mPeerMgr->getOwnNetStatus(detail))
if (mPeerMgr->getOwnNetStatus(detail))
{
RsDiscContactItem *pkt = new RsDiscContactItem();
/* Cyril: we dont send our own IP to an hidden node. It will not use it
@ -461,6 +463,7 @@ void p3discovery2::updatePeerAddressList(const RsDiscContactItem *item)
{
}
else if(!mPeerMgr->isHiddenNode(rsPeers->getOwnId()))
{
/* Cyril: we don't store IP addresses if we're a hidden node.
* Normally they should not be sent to us, except for old peers. */
/* G10h4ck: sending IP information also to hidden nodes has proven very
@ -471,13 +474,13 @@ void p3discovery2::updatePeerAddressList(const RsDiscContactItem *item)
* permission matrix. Disabling this instead will make life more
* difficult for average user, that moreover whould have no way to
* revert an hardcoded policy. */
{
pqiIpAddrSet addrsFromPeer;
pqiIpAddrSet addrsFromPeer;
addrsFromPeer.mLocal.extractFromTlv(item->localAddrList);
addrsFromPeer.mExt.extractFromTlv(item->extAddrList);
#ifdef P3DISC_DEBUG
std::cerr << "Setting address list to peer " << item->sslId << ", to be:" << std::endl ;
std::cerr << "Setting address list to peer " << item->sslId
<< ", to be:" << std::endl ;
std::string addrstr;
addrsFromPeer.printAddrs(addrstr);