change the address selection of udp connection

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1869 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2009-12-14 10:34:57 +00:00
parent f610e09f5c
commit 892598d6eb

View File

@ -2254,7 +2254,14 @@ bool p3ConnectMgr::retryConnectTCP(std::string id)
}
}
if (!found && !isSameSubnet(&ipListIt->ipAddr.sin_addr, &ownState.currentlocaladdr.sin_addr)) {//add only if in different subnet
/* Try not to add internal address like 192.168.x.x
* check that the (addr1 & 255.255.0.0) == (addr2 & 255.255.0.0)
*/
unsigned long a1 = ntohl(ipListIt->ipAddr.sin_addr.s_addr);
unsigned long a2 = ntohl(ownState.currentlocaladdr.sin_addr.s_addr);
bool isLocal = ((a1 & 0xffff0000) == (a2 & 0xffff0000));
if (!found && !isLocal && !isSameSubnet(&ipListIt->ipAddr.sin_addr, &ownState.currentlocaladdr.sin_addr)) {//add only if in different subnet
#ifdef CONN_DEBUG
std::cerr << "Adding udp connection attempt." << std::endl;
#endif