mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-15 17:37:12 -05:00
More ipv6 to ipv4 conversion around
More safe sockaddr_storage copy
This commit is contained in:
parent
7d765ec04e
commit
dedfcb2b60
@ -1226,9 +1226,17 @@ void p3PeerMgrIMPL::printPeerLists(std::ostream &out)
|
|||||||
* as it doesn't call back to there.
|
* as it doesn't call back to there.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool p3PeerMgrIMPL::UpdateOwnAddress( const sockaddr_storage& localAddr,
|
bool p3PeerMgrIMPL::UpdateOwnAddress( const sockaddr_storage& pLocalAddr,
|
||||||
const sockaddr_storage& extAddr )
|
const sockaddr_storage& pExtAddr )
|
||||||
{
|
{
|
||||||
|
sockaddr_storage localAddr;
|
||||||
|
sockaddr_storage_copy(pLocalAddr, localAddr);
|
||||||
|
sockaddr_storage_ipv6_to_ipv4(localAddr);
|
||||||
|
|
||||||
|
sockaddr_storage extAddr;
|
||||||
|
sockaddr_storage_copy(pExtAddr, extAddr);
|
||||||
|
sockaddr_storage_ipv6_to_ipv4(extAddr);
|
||||||
|
|
||||||
#ifdef PEER_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgrIMPL::UpdateOwnAddress("
|
std::cerr << "p3PeerMgrIMPL::UpdateOwnAddress("
|
||||||
<< sockaddr_storage_tostring(localAddr) << ", "
|
<< sockaddr_storage_tostring(localAddr) << ", "
|
||||||
@ -1251,7 +1259,7 @@ bool p3PeerMgrIMPL::UpdateOwnAddress( const sockaddr_storage& localAddr,
|
|||||||
|
|
||||||
//update ip address list
|
//update ip address list
|
||||||
pqiIpAddress ipAddressTimed;
|
pqiIpAddress ipAddressTimed;
|
||||||
ipAddressTimed.mAddr = localAddr;
|
sockaddr_storage_copy(localAddr, ipAddressTimed.mAddr);
|
||||||
ipAddressTimed.mSeenTime = time(NULL);
|
ipAddressTimed.mSeenTime = time(NULL);
|
||||||
ipAddressTimed.mSrc = 0;
|
ipAddressTimed.mSrc = 0;
|
||||||
mOwnState.ipAddrs.updateLocalAddrs(ipAddressTimed);
|
mOwnState.ipAddrs.updateLocalAddrs(ipAddressTimed);
|
||||||
@ -1284,6 +1292,7 @@ bool p3PeerMgrIMPL::UpdateOwnAddress( const sockaddr_storage& localAddr,
|
|||||||
* networking stack */
|
* networking stack */
|
||||||
!sockaddr_storage_ipv6_isLinkLocalNet(addr) )
|
!sockaddr_storage_ipv6_isLinkLocalNet(addr) )
|
||||||
{
|
{
|
||||||
|
sockaddr_storage_ipv6_to_ipv4(addr);
|
||||||
pqiIpAddress pqiIp;
|
pqiIpAddress pqiIp;
|
||||||
sockaddr_storage_clear(pqiIp.mAddr);
|
sockaddr_storage_clear(pqiIp.mAddr);
|
||||||
pqiIp.mAddr.ss_family = addr.ss_family;
|
pqiIp.mAddr.ss_family = addr.ss_family;
|
||||||
@ -1299,7 +1308,7 @@ bool p3PeerMgrIMPL::UpdateOwnAddress( const sockaddr_storage& localAddr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mOwnState.localaddr = localAddr;
|
sockaddr_storage_copy(mOwnState.localaddr, localAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1308,7 +1317,7 @@ bool p3PeerMgrIMPL::UpdateOwnAddress( const sockaddr_storage& localAddr,
|
|||||||
|
|
||||||
//update ip address list
|
//update ip address list
|
||||||
pqiIpAddress ipAddressTimed;
|
pqiIpAddress ipAddressTimed;
|
||||||
ipAddressTimed.mAddr = extAddr;
|
sockaddr_storage_copy(extAddr, ipAddressTimed.mAddr);
|
||||||
ipAddressTimed.mSeenTime = time(NULL);
|
ipAddressTimed.mSeenTime = time(NULL);
|
||||||
ipAddressTimed.mSrc = 0;
|
ipAddressTimed.mSrc = 0;
|
||||||
mOwnState.ipAddrs.updateExtAddrs(ipAddressTimed);
|
mOwnState.ipAddrs.updateExtAddrs(ipAddressTimed);
|
||||||
@ -1343,7 +1352,7 @@ bool p3PeerMgrIMPL::UpdateOwnAddress( const sockaddr_storage& localAddr,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mOwnState.serveraddr = extAddr;
|
sockaddr_storage_copy(extAddr, mOwnState.serveraddr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,16 +363,16 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
|||||||
for(it = ps.ipAddrs.mLocal.mAddrs.begin();
|
for(it = ps.ipAddrs.mLocal.mAddrs.begin();
|
||||||
it != ps.ipAddrs.mLocal.mAddrs.end(); ++it)
|
it != ps.ipAddrs.mLocal.mAddrs.end(); ++it)
|
||||||
{
|
{
|
||||||
|
sockaddr_storage_ipv6_to_ipv4(it->mAddr);
|
||||||
std::string toto;
|
std::string toto;
|
||||||
toto += "L:";
|
|
||||||
toto += sockaddr_storage_tostring(it->mAddr);
|
toto += sockaddr_storage_tostring(it->mAddr);
|
||||||
rs_sprintf_append(toto, " %ld sec", time(NULL) - it->mSeenTime);
|
rs_sprintf_append(toto, " %ld sec", time(NULL) - it->mSeenTime);
|
||||||
d.ipAddressList.push_back(toto);
|
d.ipAddressList.push_back(toto);
|
||||||
}
|
}
|
||||||
for(it = ps.ipAddrs.mExt.mAddrs.begin(); it != ps.ipAddrs.mExt.mAddrs.end(); ++it)
|
for(it = ps.ipAddrs.mExt.mAddrs.begin(); it != ps.ipAddrs.mExt.mAddrs.end(); ++it)
|
||||||
{
|
{
|
||||||
|
sockaddr_storage_ipv6_to_ipv4(it->mAddr);
|
||||||
std::string toto;
|
std::string toto;
|
||||||
toto += "E:";
|
|
||||||
toto += sockaddr_storage_tostring(it->mAddr);
|
toto += sockaddr_storage_tostring(it->mAddr);
|
||||||
rs_sprintf_append(toto, " %ld sec", time(NULL) - it->mSeenTime);
|
rs_sprintf_append(toto, " %ld sec", time(NULL) - it->mSeenTime);
|
||||||
d.ipAddressList.push_back(toto);
|
d.ipAddressList.push_back(toto);
|
||||||
|
Loading…
Reference in New Issue
Block a user