mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-21 04:18:23 -04:00
display the best available ip for peers in the gui, instead of 0.0.0.0. This does only affect the gui, not the way ips are trusted and propagated (backport of commit 1799 from trunk)
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.4.x@1800 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
46f44a2a07
commit
f7d39e4a6b
1 changed files with 22 additions and 4 deletions
|
@ -248,6 +248,20 @@ bool p3Peers::isFriend(std::string id)
|
|||
return false;
|
||||
}
|
||||
|
||||
static struct sockaddr_in getPreferredAddress( const struct sockaddr_in& addr1,time_t ts1,
|
||||
const struct sockaddr_in& addr2,time_t ts2,
|
||||
const struct sockaddr_in& addr3,time_t ts3)
|
||||
{
|
||||
time_t ts = ts1 ;
|
||||
struct sockaddr_in addr = addr1 ;
|
||||
|
||||
if(ts2 > ts && strcmp(inet_ntoa(addr2.sin_addr),"0.0.0.0")) { ts = ts2 ; addr = addr2 ; }
|
||||
if(ts3 > ts && strcmp(inet_ntoa(addr3.sin_addr),"0.0.0.0")) { ts = ts3 ; addr = addr3 ; }
|
||||
|
||||
return addr ;
|
||||
}
|
||||
|
||||
|
||||
bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
|
@ -300,12 +314,16 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
|
|||
}
|
||||
}
|
||||
|
||||
// From all addresses, show the most recent one if no address is currently in use.
|
||||
struct sockaddr_in best_local_addr = (!strcmp(inet_ntoa(pcs.localaddr.sin_addr),"0.0.0.0"))?getPreferredAddress(pcs.dht.laddr,pcs.dht.ts,pcs.disc.laddr,pcs.disc.ts,pcs.peer.laddr,pcs.peer.ts):pcs.localaddr ;
|
||||
struct sockaddr_in best_servr_addr = (!strcmp(inet_ntoa(pcs.serveraddr.sin_addr),"0.0.0.0"))?getPreferredAddress(pcs.dht.raddr,pcs.dht.ts,pcs.disc.raddr,pcs.disc.ts,pcs.peer.raddr,pcs.peer.ts):pcs.serveraddr ;
|
||||
|
||||
/* fill from pcs */
|
||||
|
||||
d.localAddr = inet_ntoa(pcs.localaddr.sin_addr);
|
||||
d.localPort = ntohs(pcs.localaddr.sin_port);
|
||||
d.extAddr = inet_ntoa(pcs.serveraddr.sin_addr);
|
||||
d.extPort = ntohs(pcs.serveraddr.sin_port);
|
||||
d.localAddr = inet_ntoa(best_local_addr.sin_addr);
|
||||
d.localPort = ntohs(best_local_addr.sin_port);
|
||||
d.extAddr = inet_ntoa(best_servr_addr.sin_addr);
|
||||
d.extPort = ntohs(best_servr_addr.sin_port);
|
||||
d.lastConnect = pcs.lastcontact;
|
||||
d.connectPeriod = 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue