mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-21 05:39:11 -04:00
remove upnp mapping before adding new ones
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1821 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
8168be6828
commit
573e7b2474
3 changed files with 13 additions and 7 deletions
|
@ -544,7 +544,7 @@ void p3ConnectMgr::netTick()
|
||||||
#ifdef CONN_DEBUG
|
#ifdef CONN_DEBUG
|
||||||
std::cerr << "p3ConnectMgr::netTick() STATUS: UPNP_INIT" << std::endl;
|
std::cerr << "p3ConnectMgr::netTick() STATUS: UPNP_INIT" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
netExtraAddressCheck();
|
netExtFinderAddressCheck();
|
||||||
netUpnpInit();
|
netUpnpInit();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -561,7 +561,7 @@ void p3ConnectMgr::netTick()
|
||||||
#endif
|
#endif
|
||||||
stunCheck(); /* Keep on stunning */
|
stunCheck(); /* Keep on stunning */
|
||||||
if (!netFlagStunOk) {
|
if (!netFlagStunOk) {
|
||||||
netExtraAddressCheck();
|
netExtFinderAddressCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -755,6 +755,7 @@ void p3ConnectMgr::networkConsistencyCheck()
|
||||||
#endif
|
#endif
|
||||||
ownState.currentserveraddr = extAddr;
|
ownState.currentserveraddr = extAddr;
|
||||||
} else if (getExtFinderExtAddress(extAddr)) {
|
} else if (getExtFinderExtAddress(extAddr)) {
|
||||||
|
netExtFinderAddressCheck(); //so we put the extra address flag ok.
|
||||||
#ifdef CONN_DEBUG
|
#ifdef CONN_DEBUG
|
||||||
std::cerr << "p3ConnectMgr::networkConsistencyCheck() using getExtFinderExtAddress for ownState.serveraddr." << std::endl;
|
std::cerr << "p3ConnectMgr::networkConsistencyCheck() using getExtFinderExtAddress for ownState.serveraddr." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
@ -794,7 +795,7 @@ void p3ConnectMgr::networkConsistencyCheck()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3ConnectMgr::netExtraAddressCheck()
|
void p3ConnectMgr::netExtFinderAddressCheck()
|
||||||
{ struct sockaddr_in tmpip;
|
{ struct sockaddr_in tmpip;
|
||||||
if (getExtFinderExtAddress(tmpip)) {
|
if (getExtFinderExtAddress(tmpip)) {
|
||||||
#ifdef CONN_DEBUG
|
#ifdef CONN_DEBUG
|
||||||
|
|
|
@ -317,7 +317,7 @@ void netExtCheck();
|
||||||
void netUpnpInit();
|
void netUpnpInit();
|
||||||
void netUpnpCheck();
|
void netUpnpCheck();
|
||||||
|
|
||||||
void netExtraAddressCheck();
|
void netExtFinderAddressCheck();
|
||||||
void netUnreachableCheck();
|
void netUnreachableCheck();
|
||||||
|
|
||||||
/* Udp / Stun functions */
|
/* Udp / Stun functions */
|
||||||
|
|
|
@ -168,15 +168,20 @@ bool upnphandler::start_upnp()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//build port mapping config
|
//first of all, build the mappings
|
||||||
std::vector<CUPnPPortMapping> upnpPortMapping1;
|
std::vector<CUPnPPortMapping> upnpPortMapping1;
|
||||||
CUPnPPortMapping cUPnPPortMapping1 = CUPnPPortMapping(eport_curr, ntohs(localAddr.sin_port), "TCP", true, "tcp retroshare redirection");
|
CUPnPPortMapping cUPnPPortMapping1 = CUPnPPortMapping(eport_curr, ntohs(localAddr.sin_port), "TCP", true, "tcp retroshare redirection");
|
||||||
upnpPortMapping1.push_back(cUPnPPortMapping1);
|
upnpPortMapping1.push_back(cUPnPPortMapping1);
|
||||||
bool res = cUPnPControlPoint->AddPortMappings(upnpPortMapping1);
|
|
||||||
|
|
||||||
std::vector<CUPnPPortMapping> upnpPortMapping2;
|
std::vector<CUPnPPortMapping> upnpPortMapping2;
|
||||||
CUPnPPortMapping cUPnPPortMapping2 = CUPnPPortMapping(eport_curr, ntohs(localAddr.sin_port), "UDP", true, "udp retroshare redirection");
|
CUPnPPortMapping cUPnPPortMapping2 = CUPnPPortMapping(eport_curr, ntohs(localAddr.sin_port), "UDP", true, "udp retroshare redirection");
|
||||||
upnpPortMapping2.push_back(cUPnPPortMapping2);
|
upnpPortMapping2.push_back(cUPnPPortMapping2);
|
||||||
|
|
||||||
|
//attempt to remove formal port redirection rules
|
||||||
|
cUPnPControlPoint->DeletePortMappings(upnpPortMapping1);
|
||||||
|
cUPnPControlPoint->DeletePortMappings(upnpPortMapping2);
|
||||||
|
|
||||||
|
//add new rules
|
||||||
|
bool res = cUPnPControlPoint->AddPortMappings(upnpPortMapping1);
|
||||||
bool res2 = cUPnPControlPoint->AddPortMappings(upnpPortMapping2);
|
bool res2 = cUPnPControlPoint->AddPortMappings(upnpPortMapping2);
|
||||||
|
|
||||||
struct sockaddr_in extAddr;
|
struct sockaddr_in extAddr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue