update friends IP from own net info sent by discovery

This commit is contained in:
csoler 2021-02-06 21:42:07 +01:00
parent 1f1a226f87
commit abe3527635
4 changed files with 39 additions and 15 deletions

View File

@ -379,6 +379,22 @@ void p3discovery2::recvOwnContactInfo(const RsPeerId &fromId, const RsDiscContac
mPeerMgr->setLocation(fromId, item->location); mPeerMgr->setLocation(fromId, item->location);
mPeerMgr->setVisState(fromId, item->vs_disc, item->vs_dht); mPeerMgr->setVisState(fromId, item->vs_disc, item->vs_dht);
if(!det.localAddr.empty())
{
if(sockaddr_storage_isValidNet(item->localAddrV4.addr))
mPeerMgr->setLocalAddress(fromId,item->localAddrV4.addr);
else if(sockaddr_storage_isValidNet(item->localAddrV6.addr))
mPeerMgr->setLocalAddress(fromId,item->localAddrV6.addr);
}
if(!det.extAddr.empty())
{
if(sockaddr_storage_isValidNet(item->extAddrV4.addr))
mPeerMgr->setExtAddress(fromId,item->extAddrV4.addr);
else if(sockaddr_storage_isValidNet(item->extAddrV6.addr))
mPeerMgr->setExtAddress(fromId,item->extAddrV6.addr);
}
setPeerVersion(fromId, item->version); setPeerVersion(fromId, item->version);
// Hidden nodes do not need IP information. So that information is dropped. // Hidden nodes do not need IP information. So that information is dropped.

View File

@ -472,6 +472,17 @@ void p3LinkMgrIMPL::tickMonitors()
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
// if(peer.actions & RS_PEER_CONNECTED)
// {
// pqiIpAddress ip;
// ip.mAddr = it->second.currentConnAddrAttempt.addr;
// ip.mSeenTime = time(NULL);
// ip.mSrc = time(NULL);
//
// mPeerMgr->updateCurrentAddress(it->second.id,)
// std::cerr << "Peer " << it->second.id << " connected with IP " << sockaddr_storage_tostring(it->second.currentConnAddrAttempt.addr) << std::endl;
// }
/* notify GUI */ /* notify GUI */
if (rsEvents && (peer.actions & RS_PEER_CONNECTED)) if (rsEvents && (peer.actions & RS_PEER_CONNECTED))
{ {
@ -788,6 +799,8 @@ bool p3LinkMgrIMPL::connectResult(const RsPeerId &id, bool success, bool isIncom
bool updatePeerAddr = false; bool updatePeerAddr = false;
bool updateLastContact = false; bool updateLastContact = false;
std::cerr << "Connection result with peer " << id << ": " << success << ". Is incoming: " << isIncomingConnection << ", remote addr: " << sockaddr_storage_tostring(remote_peer_address) << std::endl;
{ {
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/

View File

@ -1066,8 +1066,7 @@ bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg
} }
bool p3PeerMgrIMPL::addSslOnlyFriend( bool p3PeerMgrIMPL::addSslOnlyFriend( const RsPeerId& sslId, const RsPgpId& pgp_id, const RsPeerDetails& dt )
const RsPeerId& sslId, const RsPgpId& pgp_id, const RsPeerDetails& dt )
{ {
constexpr auto fname = __PRETTY_FUNCTION__; constexpr auto fname = __PRETTY_FUNCTION__;
const auto failure = [&](const std::string& err) const auto failure = [&](const std::string& err)
@ -1598,9 +1597,7 @@ bool p3PeerMgrIMPL::setLocalAddress( const RsPeerId &id,
std::map<RsPeerId, peerState>::iterator it; std::map<RsPeerId, peerState>::iterator it;
if (mFriendList.end() == (it = mFriendList.find(id))) if (mFriendList.end() == (it = mFriendList.find(id)))
{ {
#ifdef PEER_DEBUG std::cerr << "(EE) p3PeerMgrIMPL::setLocalAddress() cannot add addres " << "info : peer id not found in friend list id: " << id << std::endl;
std::cerr << "p3PeerMgrIMPL::setLocalAddress() cannot add addres " << "info : peer id not found in friend list id: " << id << std::endl;
#endif
return false; return false;
} }
@ -1659,9 +1656,7 @@ bool p3PeerMgrIMPL::setExtAddress( const RsPeerId &id,
std::map<RsPeerId, peerState>::iterator it; std::map<RsPeerId, peerState>::iterator it;
if (mFriendList.end() == (it = mFriendList.find(id))) if (mFriendList.end() == (it = mFriendList.find(id)))
{ {
#ifdef PEER_DEBUG std::cerr << "(EE) p3PeerMgrIMPL::setExtAddress() cannot add addres " << "info : peer id not found in friend list id: " << id << std::endl;
std::cerr << "p3PeerMgrIMPL::setExtAddress() cannot add addres " << "info : peer id not found in friend list id: " << id << std::endl;
#endif
return false; return false;
} }

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>658</width> <width>658</width>
<height>400</height> <height>419</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -441,17 +441,17 @@
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget>
<class>RSTextBrowser</class>
<extends>QTextBrowser</extends>
<header>gui/common/RSTextBrowser.h</header>
</customwidget>
<customwidget> <customwidget>
<class>HeaderFrame</class> <class>HeaderFrame</class>
<extends>QFrame</extends> <extends>QFrame</extends>
<header>gui/common/HeaderFrame.h</header> <header>gui/common/HeaderFrame.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>RSTextBrowser</class>
<extends>QTextBrowser</extends>
<header>gui/common/RSTextBrowser.h</header>
</customwidget>
<customwidget> <customwidget>
<class>AvatarWidget</class> <class>AvatarWidget</class>
<extends>QLabel</extends> <extends>QLabel</extends>