mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-23 14:39:34 -05:00
The external ip address is now set when a peer is connected if there is no upnp or extadrfinder
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1918 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c90714c5bd
commit
d485c71126
@ -2545,8 +2545,9 @@ bool p3ConnectMgr::setAddressList(std::string id, std::list<IpAddressTimed> I
|
|||||||
/* check if it is our own ip */
|
/* check if it is our own ip */
|
||||||
if (id == getOwnId()) {
|
if (id == getOwnId()) {
|
||||||
ownState.updateIpAddressList(IpAddressTimedList);
|
ownState.updateIpAddressList(IpAddressTimedList);
|
||||||
//if we are using firewalled or manually set port mode, and we are not using extAddrFinder, we will use this list for ip ext ip detection
|
//if we have no ext address from upnp or extAdrFinder, we will use this list for ext ip detection
|
||||||
if ((!ownState.netMode & RS_NET_MODE_UPNP) && !use_extr_addr_finder) {
|
sockaddr_in extAddr;
|
||||||
|
if (!getExtFinderExtAddress(extAddr) && !getUpnpExtAddress(extAddr)) { //TODO fix it
|
||||||
IpAddressTimed extractedAddress;
|
IpAddressTimed extractedAddress;
|
||||||
if (peerConnectState::extractExtAddress(IpAddressTimedList, extractedAddress)) {
|
if (peerConnectState::extractExtAddress(IpAddressTimedList, extractedAddress)) {
|
||||||
#ifdef CONN_DEBUG
|
#ifdef CONN_DEBUG
|
||||||
@ -2554,6 +2555,10 @@ bool p3ConnectMgr::setAddressList(std::string id, std::list<IpAddressTimed> I
|
|||||||
#endif
|
#endif
|
||||||
ownState.currentserveraddr.sin_addr = extractedAddress.ipAddr.sin_addr;
|
ownState.currentserveraddr.sin_addr = extractedAddress.ipAddr.sin_addr;
|
||||||
IndicateConfigChanged();
|
IndicateConfigChanged();
|
||||||
|
} else {
|
||||||
|
#ifdef CONN_DEBUG
|
||||||
|
std::cerr << "p3ConnectMgr::setAddressList() no valuable ext adress found." << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -3280,30 +3285,17 @@ void peerConnectState::sortIpAddressListBySeenTime() { //Sort the ip list orderi
|
|||||||
}
|
}
|
||||||
|
|
||||||
void peerConnectState::sortIpAddressListBySeenTime(std::list<IpAddressTimed> &ipTimedListInput) { //Sort the ip list ordering by seen time
|
void peerConnectState::sortIpAddressListBySeenTime(std::list<IpAddressTimed> &ipTimedListInput) { //Sort the ip list ordering by seen time
|
||||||
#ifdef CONN_DEBUG
|
|
||||||
std::cerr << "peerConnectState::sortIpAdressListBySeenTime() called" << std::endl;
|
|
||||||
#endif
|
|
||||||
ipTimedListInput.sort(peerConnectState::compare_seen_time);
|
ipTimedListInput.sort(peerConnectState::compare_seen_time);
|
||||||
ipTimedListInput.reverse();
|
ipTimedListInput.reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::list<IpAddressTimed> peerConnectState::getIpAddressList() {
|
std::list<IpAddressTimed> peerConnectState::getIpAddressList() {
|
||||||
#ifdef CONN_DEBUG
|
|
||||||
std::cerr << "peerConnectState::getIpAddressList() called" << std::endl;
|
|
||||||
#endif
|
|
||||||
purgeIpAddressList();
|
purgeIpAddressList();
|
||||||
#ifdef CONN_DEBUG
|
|
||||||
printIpAddressList();
|
|
||||||
#endif
|
|
||||||
return ipAddressList;
|
return ipAddressList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void peerConnectState::purgeIpAddressList() {//purge old and useless addresses to keep a small list
|
void peerConnectState::purgeIpAddressList() {//purge old and useless addresses to keep a small list
|
||||||
#ifdef CONN_DEBUG
|
|
||||||
std::cerr << "peerConnectState::purgeIpAdressList() called." << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::list<IpAddressTimed>::iterator ipListIt;
|
std::list<IpAddressTimed>::iterator ipListIt;
|
||||||
for (ipListIt = ipAddressList.begin(); ipListIt!=(ipAddressList.end());) {
|
for (ipListIt = ipAddressList.begin(); ipListIt!=(ipAddressList.end());) {
|
||||||
if (ipListIt->ipAddr.sin_addr.s_addr == 0 || ipListIt->ipAddr.sin_port == 0 ||
|
if (ipListIt->ipAddr.sin_addr.s_addr == 0 || ipListIt->ipAddr.sin_port == 0 ||
|
||||||
@ -3314,9 +3306,6 @@ void peerConnectState::purgeIpAddressList() {//purge old and useless addresses t
|
|||||||
++ipListIt;
|
++ipListIt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef CONN_DEBUG
|
|
||||||
printIpAddressList();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//purge duplicates
|
//purge duplicates
|
||||||
for (ipListIt = ipAddressList.begin(); ipListIt!=(ipAddressList.end()); ipListIt++) {
|
for (ipListIt = ipAddressList.begin(); ipListIt!=(ipAddressList.end()); ipListIt++) {
|
||||||
@ -3407,7 +3396,7 @@ bool peerConnectState::extractExtAddress(std::list<IpAddressTimed> IpAddressTime
|
|||||||
//if ((ipListIt->ipAddr.sin_addr.s_addr != 0)
|
//if ((ipListIt->ipAddr.sin_addr.s_addr != 0)
|
||||||
if (ipListIt->ipAddr.sin_addr.s_addr != 0 && ipListIt->ipAddr.sin_port != 0 &&
|
if (ipListIt->ipAddr.sin_addr.s_addr != 0 && ipListIt->ipAddr.sin_port != 0 &&
|
||||||
ipListIt->ipAddr.sin_addr.s_addr != 1 && ipListIt->ipAddr.sin_port != 1 &&
|
ipListIt->ipAddr.sin_addr.s_addr != 1 && ipListIt->ipAddr.sin_port != 1 &&
|
||||||
std::string(inet_ntoa(ipListIt->ipAddr.sin_addr)) == "1.1.1.1" &&
|
std::string(inet_ntoa(ipListIt->ipAddr.sin_addr)) != "1.1.1.1" &&
|
||||||
(!isLoopbackNet(&ipListIt->ipAddr.sin_addr)) &&
|
(!isLoopbackNet(&ipListIt->ipAddr.sin_addr)) &&
|
||||||
(!isPrivateNet(&ipListIt->ipAddr.sin_addr))
|
(!isPrivateNet(&ipListIt->ipAddr.sin_addr))
|
||||||
) {
|
) {
|
||||||
|
Loading…
Reference in New Issue
Block a user